Page 1 of 1

Unit will not fire

Posted: 13 Oct 2006, 21:29
by MrSpontaneous
Well, I have been trying to finish up a unit, and it won't fire. I suspect its something really simple that I am simple overlooking.

Below are the units FBI and Script code respectivly. Also for good measure the weapon TDF.

Code: Select all

[UNITINFO]
	{
	//Internal settings
	unitname=AGOSEED;
	version=1;
	side=AGONY;
	objectname=AgoSeed.S3O;
	TEDClass=Seed;
	category=HOVER SEED AGONY BUILDER ALL;	

	//unit limitations and properties
	ActiveWhenBuilt=1;
	WorkerTime=50;
	builddistance=90;
	BuildTime=1;
	//SoundCategory=ARM_kbot;	
	SightDistance=600;
	radardistance=1200;
	MaxDamage=300;
	name=Agony Seed;
	description=:Creates Agony;
	
	//energy and metal related
	BuildCostEnergy=200;
	BuildCostMetal=400;
	EnergyMake=10;
 	MetalMake=5;

	//Pathfinding and related
	FootPrintX=3;
	FootPrintZ=3;
	MaxWaterDepth=0;
	MovementClass=AgonySeed;	
	mobilestandorders=1;
	standingmoveorder=1;
	ovradjust=1;
	smoothanim=1;

	//Abilities
	Builder=1;
	CanMove=1;
	CanPatrol=1;
	CanStop=1;
	canguard=1;
	maxvelocity=3;
	brakerate=0.5;
	acceleration=0.5;
	turnrate=1000;
	steeringmode=1;
	shootme=1;
	canreclamate=1;
	defaultmissiontype=Standby;
	maneuverleashlength=300;
	armourtype=Seed;
	canattack=1;
      canfly=1;
      cruisealt=30;
      autoheal=2;
      commander=1;
 	DontLand=1;
      ExplodeAs=;
      SelfDestructAs=;
      canhover=1;
      AirHoverFactor=0;  
 
	//Weapons and related
	weapon1=SeedZap;
	wpri_badtargetcategory=VTOL;
	nochasecategory=VTOL;
   	maxangledif1=10;
      HoverAttack=1;
	}

Code: Select all

#define TA			// This is a TA script

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

piece  base, arm1, arm2, arm3, arm4, point1, point2, point3, point4, point5, point6, point7, point8;

static-var  nano_changer, zap_changer, is_building;


SmokeUnit(healthpercent, sleeptime, smoketype)
{
	while( get BUILD_PERCENT_LEFT )
	{
		sleep 400;
	}
	while( TRUE )
	{
		healthpercent = get HEALTH;
		if( healthpercent < 66 )
		{
			smoketype = 256 | 2;
			if( Rand( 1, 66 ) < healthpercent )
			{
				smoketype = 256 | 1;
			}
			emit-sfx smoketype from base;
		}
		sleeptime = healthpercent * 50;
		if( sleeptime < 200 )
		{
			sleeptime = 200;
		}
		sleep sleeptime;
	}
}

MotionControl(moving, aiming, justmoved)
{
}

Create()
{
	nano_changer = 0;
	zap_changer = 0;
	is_building = 0;
	start-script SmokeUnit();
}

SetMaxReloadTime()
{
}

StartMoving()
{
}

StopMoving()
{
}

WhenBuilding()
{
  While(is_building == 1)
  {
  sleep 10;
  }
}

SweetSpot(piecenum)
{
	piecenum = base;
}

RestoreAfterDelay()
{
}

AimFromPrimary(piecenum)
{
	piecenum = base;
}

QueryPrimary(piecenum)
{

    if(zap_changer == 0)
    {
	piecenum = point5;
	}
    if(zap_changer == 1)
    {
	piecenum = point6;
	}	
	if(zap_changer == 2)
    {
	piecenum = point7;
	}
	if(zap_changer == 3)
    {
	piecenum = point8;
	}
	
	zap_changer = zap_changer + 1;
	
	if(zap_changer == 4)
	{
	  zap_changer = 0;
    }
	
	
}

AimPrimary(heading, pitch)
{
	signal 4;
	set-signal-mask 4;
	start-script WhenBuilding();
	turn base to y-axis heading speed <20>;
	turn base to x-axis pitch speed <20>;
	return (1);
}

FirePrimary()
{
}

QueryNanoPiece(piecenum)
{
	if( nano_changer == 0 )
	{
		piecenum = point1;
	}
	if( nano_changer == 1 )
	{
		piecenum = point2;
	}
	if( nano_changer == 2 )
	{
		piecenum = point3;
	}
	if( nano_changer == 3 )
	{
		piecenum = point4;
	}
	nano_changer = nano_changer + 1;
	
	if(nano_changer == 4)
	  {
	  nano_changer = 0;
	  }
	
}

StartBuilding(heading, pitch)
{
    is_building = 1;
	turn base to y-axis heading speed <200>;
	turn base to X-axis pitch speed <200>;
	wait-for-turn base around y-axis;
	set INBUILDSTANCE to 1;
}

StopBuilding()
{
	set INBUILDSTANCE to 0;
    turn base to y-axis <0> speed <200>;
    turn base to X-axis <0> speed <200>;
    is_building = 0;

	signal 8;
	set-signal-mask 8;
}

Killed(severity, corpsetype)
{
	if( severity <= 25 )
	{
		corpsetype = 1;
		explode base type BITMAPONLY | BITMAP1;
		explode arm1 type SHATTER;
		explode arm3 type SHATTER;
		explode arm4 type SHATTER;
		explode arm2 type SHATTER;
		return (0);
	}
	if( severity <= 50 )
	{
		corpsetype = 2;
		explode base type BITMAPONLY | BITMAP1;
		explode arm1 type SHATTER;
		explode arm3 type SHATTER;
		explode arm4 type SHATTER;
		explode arm2 type SHATTER;
		return (0);
	}
	if( severity <= 99 )
	{
		corpsetype = 3;
		explode base type BITMAPONLY | BITMAP1;
		explode arm1 type SHATTER;
		explode arm3 type SHATTER;
		explode arm4 type SHATTER;
		explode arm2 type SHATTER;
		return (0);
	}
	corpsetype = 3;
	explode base type BITMAPONLY | BITMAP1;
}

Code: Select all

[SeedZap]
{
name=LightningGun;
rendertype=7;
lineofsight=1;
turret=0;
range=600;
reloadtime=.4;
weaponvelocity=400;
targetMoveError=0.3;
areaofeffect=8;
duration=10;
soundtrigger=1;
energypershot=5;
tolerance=600;
//soundstart=lghthvy1;
//soundhit=lashit;
firestarter=90;
beamweapon=1;
rbgcolor=.9 .4 .4;
explosiongaf=fx;
explosionart=explode5;
waterexplosiongaf=fx;
waterexplosionart=h2oboom1;
startsmoke=1;
[DAMAGE]
{
default=10;
}
}
Thanks

Posted: 13 Oct 2006, 21:48
by KDR_11k
Where's the origin of the base piece? It needs line of sight to the target since it's the AimFrom piece.

Posted: 13 Oct 2006, 21:56
by MrSpontaneous
The center of the model. (I wanted it to aim its body at the target, considering its guns are fixed around the main body in a forward position)

Posted: 14 Oct 2006, 01:13
by SpikedHelmet
Change turret=0; to turret=1;. Although your model doesn't have a turret, technically, the base has become the turret.

Try changing QueryPrimary to this:

Code: Select all

QueryPrimary(piecenum) 
{ 

    if( zap_changer == 0 ) 
    { 
   piecenum = point5; 
   zap_changer = 1;
    } 
    if( zap_changer == 1 ) 
    { 
   piecenum = point6; 
   zap_changer = 2;
    }    
   if( zap_changer == 2 ) 
    { 
   piecenum = point7; 
   zap_changer = 3;
    } 
   if( zap_changer == 3 ) 
    { 
   piecenum = point8; 
   zap_changer = 0;
    }   
}

Also, I'm going to take a leap and guess that you want the unit to physically turn itself rather than simply use its base like a turret (which has to reset every time it moves). If this is the case, remove the two animation lines from AimPrimary; add this line to your fbi: "weaponmaindir1=0 0 1;", make sure turret=1; in the weapon .tdf, and that just might work.

Posted: 17 Oct 2006, 02:57
by MrSpontaneous
Unfortunatly that did not work. The problem seems to be something to do with the unit perpetually aiming. its not the code to keep it from firing while shooting, as temporarly removed that and the problem persisted.


Thanks for the help