small scripting problem (should be very easy)

small scripting problem (should be very easy)

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

small scripting problem (should be very easy)

Post by Optimus Prime »

Hi

i want to make a unit which can be put off and on. While in on status, the unit shall become an extra turret and in off status the turret shall become invisible or so.
The problem now is, that this status shall not be influenced by moving. I scripted it like a solarpanel, but now when the unit moves, the unit gets his turret while in off status. So i need a script, that is only connected with the on/off button and not whith any move order.

Thnx for taking the time!
Last edited by Optimus Prime on 07 Mar 2006, 20:44, edited 1 time in total.
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

ok it was not a scripting problem but a unit.fbi missing tag (s).

mobilestandorders=1;
standingmoveorder=1;

these tags dont stand in the wiki and should be added... it took me 2 hours to found that.

Edit: hm no... strange! Now its again like before and sucks... :(
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

sorry but its probably not the tag that makes what i want.
The problem is still there and i have really no idea why this doesnt works :(
I tried to have a look at the movable radarjammer of xta or aa where exactly it works the way i need. I changed my script and the fbi so that it should work, but still the same problem. When clicking s (stop) or beginning to move, the script activate starts even if the unit is in off status.
Can anyone help me?

here comes the script:
#define TA // This is a TA script

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

piece groundplane, base, turbase, turret1, sleeve1, barrel1a, flare1a, barrel1b, flare1b, barrel1c, flare1c, turret2, barrel2a, flare2a, nanogun, nano, armormiddle, armorleft, armorright, turret3, sleeve3, barrel3, flash3, turret4, sleeve4, barrel4, flash4;

static-var gun_1, gun_2, RestoreDelay, shiphealth, loseweap, Static_Var_3, Static_Var_4, statechg_DesiredState, statechg_StateChanging, on_off;

// Signal definitions
#define SIG_AIM 2
#define SIG_AIM_2 4
#define SIG_AIM_3 8
#define SIG_AIM_4 16
#define SIG_ACTIVATE 32

#define SMOKEPIECE1 base

#include "SmokeUnit.h"

HitByWeapon()
{
shiphealth = get HEALTH;
if( shiphealth <= 32 AND loseweap == 0 )
{
loseweap = 1;
explode turret1 type SHATTER | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode sleeve1 type SHATTER | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode turbase type SHATTER | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
hide turret1;
hide sleeve1;
hide barrel1a;
hide barrel1b;
hide barrel1c;
hide turbase;
}
start-script RestoreWeaps();
}

/*
InitState()
{
statechg_DesiredState = TRUE;
statechg_StateChanging = FALSE;
}
*/

Activate()
{
signal SIG_ACTIVATE;
set-signal-mask SIG_ACTIVATE;
show armormiddle;
show armorleft;
show armorright;
move armorleft to x-axis [-10.0] speed [30.0];
move armorright to x-axis [10.0] speed [30.0];
wait-for-move armorleft along x-axis;
wait-for-move armorright along x-axis;
set ARMORED to 1;

}

Deactivate()
{
signal SIG_ACTIVATE;
set-signal-mask SIG_ACTIVATE;
move armorleft to x-axis [0.0] speed [30.0];
move armorright to x-axis [0.0] speed [30.0];
wait-for-move armorleft along x-axis;
wait-for-move armorright along x-axis;
hide armorleft;
hide armorright;
hide armormiddle;
set ARMORED to 0;

}


Create()
{
hide armorleft;
hide armorright;
hide armormiddle;
hide flare1b;
hide flare1c;
hide flare2a;
gun_1 = 0;
gun_2 = 0;
dont-cache armormiddle;
dont-cache armorleft;
dont-cache armorright;
dont-cache turret1;
dont-cache sleeve1;
dont-cache barrel1a;
dont-cache barrel1b;
dont-cache barrel1c;
dont-cache turbase;
RestoreDelay = 5000;
loseweap = 0;
// call-script InitState();
// start-script Deactivate();
start-script SmokeUnit();
set ARMORED to 0;
start-script SmokeUnit();
}

// this is new
i deleted all lines which are definitely not linked with the problem to make it easier for you to read.
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

am i doomed? :(
WTF doesnt it works for flying units??? When i remove the canfly=1; tag, all works fine. How can i work that on a flyinf unit?
Any reason why that doesnt works for flying units????? I hate you all :(
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

Ok, for flying units, in both OTA and therefore Spring, it calls the activate() function on take off and the deactivate() on landing, so that aircraft can have those animated opening and closing wings we are all so fond off (or rather, fail to notice amongst our mass of 200 hawks :wink: ), and the transports can have those fancy flames, etc etc.

I think you are doomed. And I hate you too! :cry: :wink:
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

I know that you need it for the animated starts and they are cool - i like them too, but wouldnt it be possible to have a tag for example "animatedStart=0" so that this is deaktivated? That would make all happy and i could make something really cool.

*me wishes this feature for the next version pleeeeeaaaaassseeeee*
Post Reply

Return to “Engine”