Home   Help Search Login Register  

Author Topic: Cap & Hold script troubles  (Read 1428 times)

0 Members and 1 Guest are viewing this topic.

B-2-0

  • Guest
Cap & Hold script troubles
« on: 20 May 2003, 20:58:25 »
Hi guys! :)

Ok, i am making a 5 flag C&H following a tutorial and everything was working fine until today i came across Tacticians new example mission, template scripts etc.  (i think the first tute i was following may have been an earlier one by Tactician actually).

Having read how good is suposedly is i decided to base my map on it so i changed all the scripting which just left the flag triggers and the GL named server...... All it says in the tute is that the scripts can be implemented straight in as long as the flag triggers are correct but it doesn't actually tell u the parameters for them so i wondered if one of u would maybe please take a looksee :)

Now, everything looks ok to me....except for one thing....i can't take the flags....kind of a big problem really aint it! ::)

Anyway....here is what i've got.....see what u think....
------------------------------------------------------------------------
First i have a GL called Server. (This isn't actually mentioned in the second tute)
                                                 (Neither are the flag triggers)
------------------------------------------------------------------------

Next i have 5 flags....

Name: Flag1, Flag2, Flag3, Flag4, Flag5.
Init: this setflagside RESISTANCE; this setflagtexture "Black"

------------------------------------------------------------------------

Next, 3 triggers for each flag (I'll work with Flag5 here)



The East capture trig...

Activated by: East, present, repeatedly
Name: Ecap5
Condition: !isNull (flagOwner Flag5) == EAST
On activation: [Flag5, EAST] exec "capture.sqs"



The West capture trig.....  the same but mirrored obviously.




The Return trig....

Activation: None, Repeatedly
Timeout: 3, 3, 3
Name: Return5
Condition: !isNull (flagOwner Flag5)
On Activation: Flag5 setflagowner objNull

------------------------------------------------------------------------
;capture.sqs

_flag = _this select 0
_side = _this select 1

?(_side == WEST): goto "West"
?(_side == EAST): goto "East"
exit

#West
?!(local Server): goto "Westclient"
WestScore = WestScore + 1
WestArray = WestArray + [_flag]
EastArray = EastArray - [_flag]
PublicVariable "WestScore"
#Westclient
(flagOwner _flag) setflagowner objNull
_flag setflagowner objNull
~0.2
_flag setflagtexture "\Flags\unitedkingdom.jpg"
_flag setflagside WEST
goto "end"

#East
?!(local Server): goto "Eastclient"
EastScore = EastScore + 1
EastArray = EastArray + [_flag]
WestArray = WestArray - [_flag]
PublicVariable "EastScore"
#Eastclient
(flagOwner _flag) setflagowner objNull
_flag setflagowner objNull
~0.2
_flag setflagtexture "rus_vlajka.pac"
_flag setflagside EAST
goto "end"

#end
?(local Server): [_flag, _side] exec "control.sqs"
~1.5
hint format["West: %1\nEast: %2", WestScore, EastScore]
Exit

------------------------------------------------------------------------

;control.sqs

?!(local Server): exit

_flag = _this select 0
_side = _this select 1

#start
~90
?(_side == West): _ar = WestArray
?(_side == East): _ar = EastArray
?!(_flag in _ar): exit

?(_side == West): WestScore = WestScore + 1
?(_side == East): EastScore = EastScore + 1
?(_side == West): PublicVariable "WestScore"
?(_side == East): PublicVariable "EastScore"
goto "start"

------------------------------------------------------------------------

;return.sqs
_flag = _this select 0
~5
?(!isnull (flagOwner _flag)): goto "return"
Exit

#return
(flagOwner _flag) SetFlagOwner objNull
_flag SetFlagOwner objNull
exit

------------------------------------------------------------------------
;init.sqs

param1 = 1800
WestScore = 0
EastScore = 0
WestArray = []
EastArray = []

------------------------------------------------------------------------
 :o PHEW!!!  Ok, so where have i gone wrong ???
Many, many thanks for taking the time to read this and the lucky brainiac will get a thank-you on my briefing ;D

Pope_Zog

  • Guest
Re:Cap & Hold script troubles
« Reply #1 on: 22 May 2003, 10:23:23 »
Just a few observations:

The East capture trig...

Activated by: East, present, repeatedly
Name: Ecap5
Condition: !isNull (flagOwner Flag5) == EAST
On activation: [Flag5, EAST] exec "capture.sqs"

I assume you're looking for the condition where there is an owner of Flag5 and he's EAST?
Don't you get an error report here? Try this condition instead:

!isNull (flagOwner Flag5) && side (flagOwner Flag5) == EAST

The Return trig....

Activation: None, Repeatedly
Timeout: 3, 3, 3
Name: Return5
Condition: !isNull (flagOwner Flag5)
On Activation: Flag5 setflagowner objNull

Is three seconds enough time for the player to take the flag? Won't the animation just stop because the flag owner is cleared immediately? Do you really need this trigger? (I see you clear the flag owner in your capture script so perhaps you don't.)

;capture.sqs

[clippety clip... snip snip]

(flagOwner _flag) setflagowner objNull

This line doesn't make sense. (flagOwner _flag) returns a unit, so you're setting the flag owner of a unit to null. You don't need this - a unit doesn't have this function.

;control.sqs

?!(local Server): exit

_flag = _this select 0
_side = _this select 1

#start
~90
?(_side == West): _ar = WestArray
?(_side == East): _ar = EastArray
?!(_flag in _ar): exit

?(_side == West): WestScore = WestScore + 1
?(_side == East): EastScore = EastScore + 1
?(_side == West): PublicVariable "WestScore"
?(_side == East): PublicVariable "EastScore"
goto "start"

Everything may work smoothly here, however, I'd recommend you declare the variable _ar before using it. You could add the line _ar = [] after you've extracted _flag and _side.

I don't know if this will resolve your problem, but it may get you further along the way.

Pope Zog

B-2-0

  • Guest
Re:Cap & Hold script troubles
« Reply #2 on: 22 May 2003, 18:38:31 »
I'll tell you what....you guys here at OFPEC never cease to amaze me....Zog, you were absolutely spot-on dude!! ;D  Muchas Gracias amigo!! :thumbsup: :cheers:

I amended quotes 1,2 'n' 3 as they were my triggers from the previous version i was using but i left the last one as it was becuse that was how it was done in Tacticians script.

It works fine now (well in the editor anyway!)  Once i have everything else sorted beta tests should point out anything else that may be wrong.

Thanx very much dude, if i met you in the street i would grab you and kiss you and.....*ahem*......well.....you get the picture, lol ;D

 :toocool:

B-2-0

  • Guest
Re:Cap & Hold script troubles
« Reply #3 on: 22 May 2003, 20:30:34 »
Hmmm.....ok, it worked the first time i tried it but now i have saved it and tried it again, the flag just stays on the soldier :-\

Any ideas ???

B-2-0

  • Guest
Re:Cap & Hold script troubles
« Reply #4 on: 22 May 2003, 21:23:23 »
Ok, i replaced the Return triggers and now it works fine again, i can take the flag and it returns as the coresponding country etc.  BUT after a certain amount of time (I made it around 2 minutes give or take) i can take the flag and it returns to the pole but it is still black!!

Which sorta means i don't capture the flag, i just borrow it for a while and then put it back which doesn't really make for a good game does it!! lol  ;)

Any ideas ???

« Last Edit: 24 May 2003, 14:38:04 by B-2-0 »

B-2-0

  • Guest
Re:Cap & Hold script troubles
« Reply #5 on: 24 May 2003, 19:48:51 »
Can anyone help??? :'(

If u need me to send you the mission/scripts etc. let me know!