Tank shooting improperly

Tank shooting improperly

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
mualjtaulur
Posts: 20
Joined: 29 Mar 2006, 21:36

Tank shooting improperly

Post by mualjtaulur »

I have this proplem.
I have searched from the forums but couldn't find help.


Image

Tank is shooting alright but it spawns the "projectile" from base and not from the barrels where the flare is set.

Here's the script, I've been looking and looking and comparing it but nothing seems to be wrong, scriptor doesn't give errors or anything.
So what's the proplem?
#define TA // This is a TA script

#include "sfxtype.h"
#include "exptype.h"

piece base, body, nanoturret, gunturret, barrel_left, barrel_right, nanolath, nanospray, flare_left, flare_right, aimpoint;

static-var fire;

#define SIG_AIM 2
#define SMOKEPIECE1 body
#include "exptype.h"
#include "sfxtype.h"
#include "smokeunit.h"

Create()
{
hide flare_left;
hide flare_right;
start-script SmokeUnit();
}

SweetSpot(piecenum)
{
piecenum=body;
}

QueryNanoPiece(piecenum)
{
piecenum=nanospray;
}

RestorePosition()
{
turn nanoturret to y-axis <0.000000> speed <90.000000>;
turn gunturret to y-axis <0.000000> speed <80.000000>;
wait-for-turn nanoturret around y-axis;
wait-for-turn gunturret around y-axis;
}

StartBuilding(Func_Var_1, Func_Var_2)
{
turn nanoturret to y-axis Func_Var_1 speed <120.000000>;
wait-for-turn nanoturret around y-axis;
set INBUILDSTANCE to 1;
}

AimFromPrimary(piecenum)
{
piecenum=aimpoint;
}

QueryPrimary(piecenum)
{
piecenum=fire;
}

AimPrimary(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turn gunturret to y-axis heading speed <120.000000>;
wait-for-turn gunturret around y-axis;
return (1);
}

FirePrimary()
{
if (fire == 0)
{
move barrel_left to z-axis [-1.000000] speed [500.000000];
show flare_left;
wait-for-move barrel_left along z-axis;
move barrel_left to z-axis [0.000000] speed [4.000000];
sleep 100;
hide flare_left;
}
if (fire == 1)
{
move barrel_right to z-axis [-1.000000] speed [500.000000];
show flare_right;
wait-for-move barrel_right along z-axis;
move barrel_right to z-axis [0.000000] speed [4.000000];
sleep 100;
hide flare_right;
}
fire = !fire;
}

TargetCleared(Func_Var_1)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
call-script RestorePosition();
}

StopBuilding()
{
turn nanoturret to y-axis <0.000000> speed <120.000000>;
set INBUILDSTANCE to 0;
}

Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1;
explode body type BITMAPONLY | BITMAP1;
explode gunturret type BITMAPONLY | BITMAP1;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode body type BITMAPONLY | BITMAP1;
explode gunturret type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode body type BITMAPONLY | BITMAP1;
explode gunturret type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
return (0);
}
corpsetype = 3;
explode body type BITMAPONLY | BITMAP1;
explode gunturret type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
}
.MJJNL.
Posts: 105
Joined: 18 Apr 2006, 18:14

Post by .MJJNL. »

well i found 1 thing it can be the origin (non moveble thing) is at the wrong place. Download upspring and load your model and go too object>Approximate Object origins (and textures your model or retexture your model :wink: )
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Post by Masse »

yeah... i had that same problem once and it was my flare's origin that was in wrong place :wink: took hours to figure that :lol: there should be easy way to move origin that would make everything way simplier
User avatar
mualjtaulur
Posts: 20
Joined: 29 Mar 2006, 21:36

Post by mualjtaulur »

Seems like my tank is shooting from the origin point of "body" any ideas what could cause this?

Secondly, tank is shooting fine with other scriptfile so the problem must be in there.. must keep searching.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

You are trying to shoot from a peice called 'fire', while fire is actually a variable set to 0 or 1. Try something like this in the QueryPrimary bit:

Code: Select all

QueryPrimary(piecenum)
{
  if (fire==0)
    {
    piecenum=barrel_left;
    }
  if (fire==1)
    {
    piecenum=barrel_right;
    }
}
I think this looks right, but im not actually a coder so it mightnt be.
User avatar
mualjtaulur
Posts: 20
Joined: 29 Mar 2006, 21:36

Post by mualjtaulur »

That helped, everything is working like a charm.
Thanks for your help people.
User avatar
TheRegisteredOne
Posts: 398
Joined: 10 Dec 2005, 21:39

Post by TheRegisteredOne »

either that, or move your barrel_left and barrel_right to the front of the objects list

piece flare_left, flare_right, base, body, nanoturret, gunturret, barrel_left, barrel_right, nanolath, nanospray, aimpoint;
Post Reply

Return to “Game Development”