on/offing shields using script
Moderator: Moderators
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
on/offing shields using script
is it possible to turn a shield/weapon off with a script? i tried altering an annihilator thinking that the weapon is disabled when it's 'off' in its folded up state, but the shield (replacement weapon) just followed the flare position & stayed active.
i know i could just make the flare jump a mile underground to hide the shield, but it would still be charging up while it's off.
is there a better way to do this?
i know i could just make the flare jump a mile underground to hide the shield, but it would still be charging up while it's off.
is there a better way to do this?
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
No, that was the answer. return a weapon as false in the AimWeaponX() function and it won't fire. This includes disabling shields. For example, if you want to hook the shield to the on/off button:
AimWeapon1() {
if(get ACTIVATION) {
return TRUE;
}
if(!get ACTIVATION) {
return FALSE;
}
}
(since scriptor doesn't support else, you have to do it that way)
Just make sure you also do "set ACTIVATION to FALSE;" in Create() or set ActivateWhenBuilt=0; in the FBI (I'd trust the script function more) just so the shield doesn't activate while the unit is under construction. If you want to turn it on when it's done building:
Create() {
set ACTIVATION to FALSE;
while(get BUILD_PERCENT_LEFT) {
sleep 500;
}
set ACTIVATION to TRUE;
}
and voila.
AimWeapon1() {
if(get ACTIVATION) {
return TRUE;
}
if(!get ACTIVATION) {
return FALSE;
}
}
(since scriptor doesn't support else, you have to do it that way)
Just make sure you also do "set ACTIVATION to FALSE;" in Create() or set ActivateWhenBuilt=0; in the FBI (I'd trust the script function more) just so the shield doesn't activate while the unit is under construction. If you want to turn it on when it's done building:
Create() {
set ACTIVATION to FALSE;
while(get BUILD_PERCENT_LEFT) {
sleep 500;
}
set ACTIVATION to TRUE;
}
and voila.
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
so i take it there's no way to on/off a unit via script as we don't have any way of feeding back values like energy into the script...
i can turn on/off shields manually now but i really want it automated as it imposes conditions where the shields can constantly drain E and stop working if they don't get enough of it. at the moment they just carry on working
i can turn on/off shields manually now but i really want it automated as it imposes conditions where the shields can constantly drain E and stop working if they don't get enough of it. at the moment they just carry on working

Hmm... do metal extractors still shut off in Spring when they don't have enough energy? If they do, I'd head straight to their script to figure out what's going on :)
About the var names: The COB format doesn't really store the names. Scriptor's able to guess at some of them based on how they're used, but most of the time it can't.
And yeah, "return FALSE" is the same thing as "return(0)".
About the var names: The COB format doesn't really store the names. Scriptor's able to guess at some of them based on how they're used, but most of the time it can't.
And yeah, "return FALSE" is the same thing as "return(0)".
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
nope, i've been up that avenue. they stop working but they don't turn off when the energy runs out (they're still spinning). I assume it's hardcoded behaviour for things that are 'on' to stay on but stop working.Gnome wrote:Hmm... do metal extractors still shut off in Spring when they don't have enough energy? If they do, I'd head straight to their script to figure out what's going on :)
looks like this is going to be a dead end unless the scripts can check energy requirements. i suppose that won't happen as they are (and should be) checked in the weapon and unit parts...the problem is with the shield being a psuedo-weapon - i think it should be an ability of the unit instead.
thanks for the help
