Crash on fire

Crash on fire

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
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Crash on fire

Post by Guessmyname »

I have no idea what's causing this...

Basically, when the unit tries to fire (which is as soon as it is ordered to, pretty much), Spring crashes.

The Weapon

Code: Select all

[4burstSML]
{
name=Missiles;
rendertype=1;
lineofsight=1;
turret=1;
model=smlrocket;
range=600;
reloadtime=3.34;
weapontimer=5;
burst=4;
burstrate=0.25;
soundtrigger=1;
weaponvelocity=540;
startvelocity=450;
weaponacceleration=108;
turnrate=63000;
areaofeffect=48;
metalpershot=0;
soundstart=rockhvy2;
soundhit=xplomed2;
firestarter=70;
smokedelay=.1;
guidance=1;
tracks=1;
selfprop=1;
smoketrail=1;
tolerance=8000;
startsmoke=1;
impulsefactor=0.123;
impulseBoost=0.123;
craterMult=0;
craterBoost=0;
NoSelfDamage=1;
[DAMAGE]
{
default=40;
}

Code: Select all

[UNITINFO]
{
	Name=Interdictor;
	UnitName=GHE_INTESC;
	
	//    Required Tags
	BuildCostEnergy=5778;
	BuildCostMetal=294;
	BuildTime=13294;
	Category=GHE ESCORT WEAPON BIGSHIP;
	Description=Escort;
	FootprintX=3;
	FootprintZ=3;
	MaxDamage=857;
	ObjectName=GHE_INTESC;
	Side=ARM;
	SoundCategory=GHE_Ships;
	TEDClass=VTOL;
	
	//    Movement
	BrakeRate=4.41;
	Acceleration=0.24;
	CanMove=1;
	MaxVelocity=5.36;
	MaxSlope=10;
	TurnRate=792;
	
	//    Buildings
	
	//    Construction
	Builder=0;
	WorkerTime=0;
	
	//    Resources
	EnergyMake=0.8;
	EnergyStorage=0;
	EnergyUse=0.8;
	MetalStorage=0;
	
	//    Abilities
	CanAttack=1;
	CanFly=1;
	CanGuard=1;
	CanPatrol=1;
	CanStop=1;
	
	//    Sight/Radar
	SightDistance=550;
	
	//    Misc
	CruiseAlt=100;
	ExplodeAs=SMALLREACTOR;
	dontland=1;
	MaxWaterDepth=0;
	NoChaseCategory=STRIKECRAFT;
	SelfDestructAs=SMALLREACTOR;
	SmoothAnim=0;
	bmcode=1;
	noautofire=0;
	firestandorders=1;
	standingfireorder=2;
	mobilestandorders=1;
	standingmoveorder=1;
	idleAutoHeal=5;
	idleTime=1800;
	defaultmissiontype=VTOL_standby;
	steeringmode=1;
	scale=1;
	maneuverleashlength=1280;
	bankscale=1;
	seismicsignature=0;
	shownanoframe=0;

	//Weapons
	Weapon1=4burstSML;
		wpri_badTargetCategory=ESCORT;
//		OnlyTargetCategory1=BIGSHIP;
//	Weapon2=SMALLEX;
//		OnlyTargetCategory2=DOESNTEXIST;

	[SFXTypes]
		{
		explosiongenerator0=custom:SPARKS;
		}
}
Unit FBI

Code: Select all

// Thank's be to 'Argh' for his script repository. 

piece base, prow, bodyp1, bodyp2, bodyp3, SML1fp1, SML1fp2, SML2fp1, SML2fp2, smoke1, smoke2, smoke3;

static-var restore_delay, HealthLevel, fpuse;
#define	SIG_AIM1	2
#define SIG_HIT		4
#define	SIG_MOVE	8
#include "STANDARD_COMMANDS_GPL.h"

DamageEffects()
{
while(TRUE)
	{
	sleep 50;
	while( get BUILD_PERCENT_LEFT ) //Don't want it sparking and burning whilst it's being built...
		{
			sleep 400;
		}
	}
	HealthLevel = get HEALTH; //Get a percentage of the unit's health, quite handy for this sort of thing...
	if(HealthLevel < 100 || HealthLevel >= 75)
		{
		sleep 200;
		// do nothing if over 75% (three quarters) health
		}
	if(HealthLevel < 75 || HealthLevel >= 50)
		{
		emit-sfx 1024+0 from smoke1; //sparks
		sleep 200; //If I didn't add this, Spring would spawn smoke every milisecond. Which is a bad idea - much lag
		}
	if(HealthLevel < 50 || HealthLevel >= 25)
		{
		emit-sfx 1024+0 from smoke1; //sparks
		emit-sfx SFXTYPE_BLACKSMOKE from smoke1; //smoke
		emit-sfx SFXTYPE_BLACKSMOKE from smoke2; //smoke
		emit-sfx SFXTYPE_THRUST from smoke2; //fire
		sleep 200;
		}
	if(HealthLevel < 50 || HealthLevel >= 25)
		{
		emit-sfx 1024+0 from smoke1; //sparks
		emit-sfx SFXTYPE_BLACKSMOKE from smoke1; //smoke
		emit-sfx SFXTYPE_BLACKSMOKE from smoke2; //smoke
		emit-sfx SFXTYPE_THRUST from smoke1; //fire
		emit-sfx SFXTYPE_THRUST from smoke2; //fire
		emit-sfx SFXTYPE_THRUST from smoke3; //fire
		emit-sfx SFXTYPE_BLACKSMOKE from smoke3; //smoke
		sleep 200;
		}
}

Create()
	{
	restore_delay = 2000;
	start-script DamageEffects();
	fpuse=0;
	HealthLevel=100;
	}

SetMaxReloadTime(time)
	{
	restore_delay = time * 2;
	}

HitByWeapon(anglex,anglez) //this makes stuff happen when the ship is hit
{
    signal SIG_HIT; 
    set-signal-mask SIG_HIT;
	emit-sfx 1024+0 from smoke1; //sparks
	emit-sfx SFXTYPE_THRUST from smoke2; //fire
	emit-sfx 1024+0 from smoke3; //more sparks
	sleep 150;
}

RestoreAfterDelay()
	{
	sleep restore_delay;
	return 0;
	}

SweetSpot (piecenum)
	{
	piecenum = base;
	}

QueryPrimary (piecenum)
	{
	if(fpuse==0)
		{
		piecenum = SML1fp1;
		}
	if(fpuse==1)
		{	
		piecenum = SML1fp2;
		}
	if(fpuse==2)
		{	
		piecenum = SML2fp1;
		}
	if(fpuse==3)
		{	
		piecenum = SML2fp1;
		}
	}

AimFromPrimary (piecenum)
	{
	piecenum = prow;
	}

AimPrimary(heading, pitch)
	{
	signal SIG_AIM1;
	set-signal-mask SIG_AIM1;
	start-script RestoreAfterDelay();
	return(TRUE);
	}

FirePrimary()
	{
	if(fpuse==0)
		{
		emit-sfx 1024+2 from SML1fp1; //smoke
		fpuse=1;
		}
	if(fpuse==1)
		{
		emit-sfx 1024+2 from SML1fp2; //smoke	
		fpuse=2;	
		}
	if(fpuse==2)
		{
		emit-sfx 1024+2 from SML2fp1; //smoke	
		fpuse=3;	
		}
	if(fpuse==3)
		{
		emit-sfx 1024+2 from SML2fp2; //smoke	
		fpuse=0;	
		}
	return(0);
	}

Killed(severity, corpsetype)
	{
	if (severity <= 25)
		{
		corpsetype = 1;
		explode prow type	SHATTER | FIRE;
		emit-sfx 1024+0 from smoke1; //sparks
		emit-sfx SFXTYPE_BLACKSMOKE from smoke1; //smoke
		emit-sfx SFXTYPE_BLACKSMOKE from smoke2; //smoke
		emit-sfx SFXTYPE_THRUST from smoke1; //fire
		emit-sfx SFXTYPE_THRUST from smoke2; //fire
		emit-sfx SFXTYPE_THRUST from smoke3; //fire
		emit-sfx SFXTYPE_BLACKSMOKE from smoke3; //smoke
		emit-sfx 2048+1 from prow; //weapon explosion from the prow. Weapon16, so that it is constant for each ship
		sleep 500;
		explode bodyp1 type	SHATTER | FIRE;
		emit-sfx 2048+1 from bodyp1;
		explode bodyp2 type	SHATTER | FIRE;
		emit-sfx 2048+1 from bodyp2;
		explode bodyp3 type	SHATTER | FIRE;
		emit-sfx 2048+1 from bodyp3;
		emit-sfx 1024+0 from smoke1; //sparks
		emit-sfx SFXTYPE_BLACKSMOKE from smoke1; //smoke
		emit-sfx SFXTYPE_BLACKSMOKE from smoke2; //smoke
		emit-sfx SFXTYPE_THRUST from smoke1; //fire
		emit-sfx SFXTYPE_THRUST from smoke2; //fire
		emit-sfx SFXTYPE_THRUST from smoke3; //fire
		emit-sfx SFXTYPE_BLACKSMOKE from smoke3; //smoke
		return(0);
		}
	return(0);
	}
Ze Script
Andreask
Posts: 282
Joined: 16 Dec 2005, 21:08

Post by Andreask »

How about some Cash on Fire ???

:twisted:
User avatar
TheRegisteredOne
Posts: 398
Joined: 10 Dec 2005, 21:39

Post by TheRegisteredOne »

in fireprimary you had the script go through all the ifs as one if made the condition right for the other. you had the first if set fpuse to what would cause the second if to go off and etc. This cause queryprimary piecenum to change through all the points in 0 time everytime the unit fires. This might cause spring to crash depends on how spring handles such thing. You know, "++gun_1" at the end works much better.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

I'd use else statements though. Means less cycles.

I can only guess what makes it crash: it's the SPARK effect you are calling from within the script.

Also:
if(HealthLevel < 75 || HealthLevel >= 50)
{
emit-sfx 1024+0 from smoke1; //sparks
sleep 200; //If I didn't add this, Spring would spawn smoke every milisecond. Which is a bad idea - much lag
}

Triggers if either HealthLevel is below 75 OR greater or equal to 50. Which means it always triggers and emits your sparks. The || need to become && or AND (correct me if I'm wrong).
Now if the spark effect is broken (which is what I assume) then you have your reason why spring instantly crashes (because it's emitted right after spawning the unit, more or less). It's probably only a single argument in the SPARK explosion which breaks it.


Ugh, ignore the above. Sorry I'm tired.
It's the emit-sfx 1024+2 which makes spring crash. It wants to emit the explosion from explosiongenerator2 which does not exist in your FBI.

Code: Select all

   [SFXTypes]
      {
      explosiongenerator0=custom:SPARKS;
      } 
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Also, the weapon had a typo- 1 missing } to close it.

Code: Select all

4burstSML] 
{ 
name=Missiles; 
rendertype=1; 
lineofsight=1; 
turret=1; 
model=smlrocket; 
range=600; 
reloadtime=3.34; 
weapontimer=5; 
burst=4; 
burstrate=0.25; 
soundtrigger=1; 
weaponvelocity=540; 
startvelocity=450; 
weaponacceleration=108; 
turnrate=63000; 
areaofeffect=48; 
metalpershot=0; 
soundstart=rockhvy2; 
soundhit=xplomed2; 
firestarter=70; 
smokedelay=.1; 
guidance=1; 
tracks=1; 
selfprop=1; 
smoketrail=1; 
tolerance=8000; 
startsmoke=1; 
impulsefactor=0.123; 
impulseBoost=0.123; 
craterMult=0; 
craterBoost=0; 
NoSelfDamage=1; 
[DAMAGE] 
{ 
default=40; 
}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

I should also note, for the record, that you can use the more-readable "OR" instead of the dual-pipe "||" :-)
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

All above problems fixed! Thanks for the help!

Now, this little quirk has been a thorn in my side for quite a while now (it also exists in Epic Legions):

Image

Basically, it doesn't show the missile model.

I have a vague recollection that Spring only shows the base object on weapons. Is this true?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

yep
User avatar
Zoombie
Posts: 6149
Joined: 15 Mar 2005, 07:08

Post by Zoombie »

Is it just me or does that explosion look cool?
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

GMN seems to know what he's doing. :)
Oh is it an s3o model? Don't know if you need a hitsphere on it.

edit: Just figured, it's not an explosion, it's the smoke trail and flare.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

S3Os should have hitspheres defined. Set it to a minimum radius size of 8 for consistant hit results in Spring, even if that means the radius is larger than the shot by a bit. It'll also make sure the object shows up. And yeah, the root object is what's shown.
Post Reply

Return to “Game Development”