Page 1 of 1

on/offing shields using script

Posted: 31 Jul 2006, 10:32
by unpossible
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?

Posted: 31 Jul 2006, 10:34
by Gnomre
return FALSE;

Posted: 31 Jul 2006, 10:52
by unpossible
heh, i must've sounded like i knew what i was talking about...

does that go in the queryprimary bit?

Posted: 31 Jul 2006, 10:54
by Das Bruce
I think he might be saying no.

Posted: 31 Jul 2006, 10:56
by unpossible
Das Bruce wrote:I think he might be saying no.
ah ok... :roll:

Posted: 31 Jul 2006, 11:07
by Gnomre
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.

Posted: 31 Jul 2006, 11:21
by unpossible
great, thanks very much! :o

Posted: 31 Jul 2006, 11:30
by Das Bruce
Hehe, oops.

Posted: 31 Jul 2006, 11:41
by Neddie
I sense some great things coming.

Posted: 31 Jul 2006, 12:23
by unpossible
seems to be working ok(ish).

do i need scripts that check if the unit is actvated to force the unit 'off' when it runs out of energy?

oh yeah - how come scriptor loses the names of a lot of variables when it descripts .cobs?

edit: also are TRUE, FALSE, 1 and 0 all interchangable?

Posted: 31 Jul 2006, 15:37
by unpossible
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 :|

Posted: 31 Jul 2006, 22:30
by Gnomre
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)".

Posted: 31 Jul 2006, 22:33
by Dragon45
IIRC, stuff shutting down automaticlaly when not enough energy is beind used is engine behavior, not script behavior O_o - if that's what you're saying.

Posted: 31 Jul 2006, 22:36
by unpossible
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 :)
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.

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 :(

Posted: 31 Jul 2006, 22:55
by Gnomre
I actually prefer it being a weapon. It makes it easier to control, plus you can mount multiple shields. In any case, go request the energy call from the script ;)