on/offing shields using script

on/offing shields using script

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
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

on/offing shields using script

Post 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?
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

return FALSE;
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

heh, i must've sounded like i knew what i was talking about...

does that go in the queryprimary bit?
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

I think he might be saying no.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

Das Bruce wrote:I think he might be saying no.
ah ok... :roll:
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

great, thanks very much! :o
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

Hehe, oops.
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

I sense some great things coming.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post 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?
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post 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 :|
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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)".
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post 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.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post 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 :(
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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 ;)
Post Reply

Return to “Game Development”