Someone needs to fix this script (i dont know whats wrong)

Someone needs to fix this script (i dont know whats wrong)

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Someone needs to fix this script (i dont know whats wrong)

Post by Optimus Prime »

History: In Final Frontier i wondered a long time, why several games crashed and now i have fixed the reason. I tested nearly 20 games and all crashed by using the lvl 2 bombers.
Most games I only used Bombers and let them attack each other or the ground.
I checked the Weapons and Unit FBIs, but nothing seems to be the reason for the crashes. Now the only chance are the scripts. Both units arm and core use nearly the same script. But the stealthed lvl 3 bombers dont use them and with them the game never crashed (till now).

So i will delete the lvl 2 bombers untill someone can help me to get them to work without crashing the game.

And here comes the script:

#define TA // This is a TA script

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

piece groundplane, base, bombbay, flare, turret2, plate2, sleeve2, barrel2, flare2;

static-var gun_1, gun_2, RestoreDelay;

// Signal definitions
#define SIG_AIM 2
#define SIG_AIM_2 4

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;
}
}

Create()
{

hide flare;
hide flare2;
gun_1 = 0;
gun_2 = 0;
RestoreDelay = 5000;
start-script SmokeUnit();
}

RestoreAfterDelay()
{
sleep RestoreDelay;
turn bombbay to y-axis <0.000000> speed <55.000000>;
turn turret2 to y-axis <0.000000> speed <55.000000>;
turn sleeve2 to x-axis <0.000000> speed <30.000000>;
gun_1 = 0;
gun_2 = 0;
}

//AimWeapon

AimWeapon1(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turn bombbay to y-axis heading speed <300.000000>;
wait-for-turn bombbay around y-axis;
start-script RestoreAfterDelay();
return (1);
}

AimWeapon2(heading, pitch)
{
signal SIG_AIM_2;
set-signal-mask SIG_AIM_2;
turn turret2 to y-axis heading speed <350.000000>;
turn sleeve2 to x-axis <0.000000> - pitch speed <300.000000>;
wait-for-turn turret2 around y-axis;
wait-for-turn sleeve2 around x-axis;
if( gun_2 == 0 )
{
wait-for-move barrel2 along z-axis;
}
start-script RestoreAfterDelay();
return (1);
}

//FireWeapon

FireWeapon1()
{
show flare;
sleep 75;
hide flare;
}

FireWeapon2()
{
if( gun_2 == 0 )
{
show flare2;
sleep 50;
hide flare2;
turn barrel2 to z-axis <90.000000> speed <350.00000>;
}
if( gun_2 == 1 )
{
show flare2;
sleep 50;
hide flare2;
turn barrel2 to z-axis <180.000000> speed <350.00000>;
}
if( gun_2 == 2 )
{
show flare2;
sleep 50;
hide flare2;
turn barrel2 to z-axis <270.000000> speed <350.00000>;
}
if( gun_2 == 3 )
{
show flare2;
sleep 50;
hide flare2;
turn barrel2 to z-axis <0.000000> speed <350.00000>;
}
gun_2 = gun_2 + 1;
if( gun_2 == 4 )
{
gun_2=0;
}
}

//AimFromWeapon

AimFromWeapon1(piecenum)
{
piecenum = bombbay;
}

QueryWeapon1(piecenum)
{
piecenum = flare;
}

AimFromWeapon2(piecenum)
{
piecenum = turret2;
}

QueryWeapon2(piecenum)
{
piecenum = flare2;
}


SweetSpot(piecenum)
{
piecenum = base;
}

Killed(severity, corpsetype)
{
hide flare;
hide flare2;
corpsetype = 3;
explode base type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
explode turret2 type SHATTER | EXPLODE_ON_HIT | BITMAP4;
}
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

if( gun_2 == 0 )
{
wait-for-move barrel2 along z-axis;
}

That's my guess at a quick glance. Could easily be wrong though. Try removing that if statement and trying it.
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

Shall i remove only the if statement or the whole 4 lines?

Edit: tested it by removing all 4 lines and it crashed again :(. So i think that there must be another reason.
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

I can't see anything wrong with that script. What is the name of the bombers? I should have some time this weekend to give them a good look.
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

its the corundin (undine) and armhhawk (hellhawk). It cant be the weapon fbi because the other bombers use the same weapons and dont crash the game. I looked the unit fbi too and found nothing special. So if its not the script, what else is there?
Ah and the game crashes randomly, so sometimes you can play with bombers fine and the other game it crashes fast. But i tested the game with only bombers and let them attack ground or units and all these games crased after some time (speed +3 ~ 5-10min)
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

Edit: Ok, I got the crash.
User avatar
Decimator
Posts: 1118
Joined: 24 Jul 2005, 04:15

Post by Decimator »

Sure the problem isn't the weapon?
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

Archangel of Death wrote:Edit: Ok, I got the crash.
will u tell it me? :)
Sure the problem isn't the weapon?


if it would be the weapon, why dont the other unit with the same weapon crash the game?
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

It only occurs while attacking, or possibly crashing since when there are more than one that happens alot. This does cut down on the possible problems. I still haven't found anything wrong though, and I'm running out of ideas. Almost time for random changes on this front :?
Post Reply

Return to “Engine”