OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: LAPD on 19 Jan 2003, 20:01:25

Title: CTF Problem
Post by: LAPD on 19 Jan 2003, 20:01:25
I was following the CTF tutorial by Backoff. My CTF is ready, and I played it with friends, but there is one bug: when someone takes the flag from a dead soldier there isn't a meesage that says "**** has the flag". It only appears if I lie down. I want it to be written right one you take the flag from the dead body. I guess this is the part that this problem is realted to: (if it isn't, go to the Editors Depot -> Multiplayer tutorials -> Capture the Flag tutorial by Backoff.

Quote
CTF Mechanism

Need three triggers: one to detect if someone take the flag, one if the owner is killed and one if the owner bring the flag to the goal:

Trigger 3

X: 0
Y: 0
Activate: Repeatedly
Text: Flag Taken
Condition: !FlagTaken AND (flagowner Flag1 in List PlayersList)
Activation: OwnerR = FlagOwner Flag1; FlagTaken = True; TitleText [ Format ["%1 has the flag", Name OwnerR], "PLAIN DOWN"]
Effect: anyone, sound: Ucapture

Note: you can't select sounds in the effect dialog box until you create the description.ext file.

Next Trigger will detect if the flag owner is killed:

Trigger 4

X: 0
Y: 0
Text: Owner Dead
CountDown: min 15, max 15, avg 15
Activate: Repeatedly
Condition: FlagTaken AND !(Alive OwnerR)
Activation: OwnerR setFlagowner Flag1; OwnerR = objNull; titletext ["The Flag return", "PLAIN DOWN"]; FlagTaken = False; "0" objStatus "Active";

The next one is used to detect if the owner is in the goal zone:

Trigger 5

X: 0
Y: 0
Text: Flag Capture
Activate: Repeatedly
Condition: FlagTaken AND (OwnerR distance Flag2 < 6)
Activation: kdo = OwnerR; OwnerR = objNull; Flag1 setflagowner objnull; titletext [ format["%1 capture the flag!", name kdo], "PLAIN DOWN"]; FlagTaken = False; kdo addscore 10;
Effect: anyone, sound: Uscore

Can anyone help me?
Title: Re:CTF Problem
Post by: LAPD on 20 Jan 2003, 16:29:56
Well, I understand it better. It dosen't show it when I lie down, only when the flag returns after 30 seconds and then immidiatly he write that "*** has the flag".
I want it to be written without the flag to get back after 30 seconds (30 seconds after the flag owner dies) , I want the players to know someone took the flag from the dead flag owner right when he took it.
So i tought about making another trigger.
In it's condition field i'll write that the flag was taken and the flag owner is dead.  In the On Activation field i'll write the things the makes the "***** has the flag" to be shown.
If no one takes the flag, then the flag returns 30 seconds after the flag owner died (Trigger 4, look at my post above).
So how can create the trigger which will be activated when the flag was taken from the dead owner and right when someone take it it says "***** has the flag"?
Note that trigger 4 returns the flag after 30 seconds so the trigger i want to create will work between this 30 seconds that you can take the flag from the dead owner.

I Hope this is a better explantion  :)
Title: Re:CTF Problem
Post by: Terox on 20 Jan 2003, 17:33:34
The problem i found with Karillions CTF system was

When a friendly player takes the flag from a dead flag runner, he cant score with it

This is the script I use, could somebody point me in the right direction for a fix please

Quote
CTF.sqs (this is the heart of the scoring and such)
 
;;CTF script by KaRRiLLioN
;;This selects the flag's name
 
_flag = _this select 0
?(isnull _flag):goto "end"
 
;;The following simply sets the textures on the flags and can be
;;changed to whatever you want.  You could actually
;;remove the ?(_flag==FlagW) and instead just put in  
;;FlagW SetFlagTexture "\Flags\Nato.jpg and do the same
;;for each one.
 
?(_flag==FlagW):_flag setflagtexture "\Flags\Nato.jpg"
?(_flag==FlagE):_flag setflagtexture "\Flags\Ussr.jpg"
?(_flag==FlagR):_flag setflagtexture "\Flags\Pirates.jpg"
 
;;This just creates a name for when the flag is taken or
;;capped or dropped.
 
?(_flag==FlagW):_flagname="the NATO Flag"
?(_flag==FlagE):_flagname="the Soviet Flag"
?(_flag==FlagR):_flagname="the Resistance Flag"
 
;;This inits the flagside for each flag.
 
?(_flag==FlagW):_flag SetFlagSide WEST
?(_flag==FlagE):_flag SetFlagSide EAST
?(_flag==FlagR):_flag SetFlagSide RESISTANCE
 
;;this sets the flag owner to nobody
 
_flag setFlagOwner objNull
 
 
#start
~1
_flagowner=Flagowner _flag
?(isnull _flagowner):Goto "start"
 
?(Side _flagowner==WEST):_team="NATO"; _flagownerside=WEST
?(Side _flagowner==EAST):_team="Soviets"; _flagownerside=EAST
?(Side _flagowner==RESISTANCE):_team="Resistance"; _flagownerside=RESISTANCE
?!(Alive _flagowner):Goto "DeadHasFlag"
 
#FlagTaken
 
titletext[format["%1 (*%3*) has %2!",name _flagowner,_flagname,_team],"PLAIN DOWN"]
PlaySound "FlagTake"
 
Goto "loop"
 
;;the loop continues to check for whether the flagcarrier is
;;dead, or has capped the flag.  Once either happens, the
;;flag is returned
 
#loop
~1
?(!Alive _flagowner):goto "DeadHasFlag"
?(isnull Flagowner FlagW) and _flagownerside==WEST and _flagowner distance FlagW<5:goto "WCaps"
?(isnull Flagowner FlagE) and _flagownerside==EAST and _flagowner distance FlagE<5:goto "ECaps"
?(isnull Flagowner FlagR) and _flagownerside==RESISTANCE and _flagowner distance FlagR<5:goto "RCaps"
 
Goto "loop"
 
;;this increments the score by 1 point for whichever team
;;caps the flag.  You can change the +1 to +5 or whatever
;;you want for a scoring method.  The ?(local Server)
;;makes sure the score is only incremented by the server
;;so that it remains accurate.
 
#WCaps
titletext[format["%1 (*%3*) has captured %2!",name _flagowner,_flagname,_team],"PLAIN DOWN"]
?(local Server):WScore=WScore+1; PublicVariable "WScore"
PlaySound "Capture"
Goto "ShowScore"
 
#ECaps
titletext[format["%1 (*%3*) has captured %2!",name _flagowner,_flagname,_team],"PLAIN DOWN"]
?(local Server):EScore=EScore+1; PublicVariable "EScore"
PlaySound "Capture"
Goto "ShowScore"
 
#RCaps
titletext[format["%1 (*%3*) has captured %2!",name _flagowner,_flagname,_team],"PLAIN DOWN"]
?(local Server):RScore=RScore+1; PublicVariable "RScore"
PlaySound "Capture"
Goto "ShowScore"
 
#ShowScore
?(local Server):ShowScore=true; PublicVariable "ShowScore"
 
Goto "FlagReturn"
 
;;if flagcarrier dies, this resets the flag immediately to the  
;;flagpole.  You can delay this by any time you want by
;;adding a value in seconds just before where it says
;;goto "FlagReturn"
 
#DeadHasFlag
 
titletext[format["%1 (*%3*) has dropped %2",name _flagowner,_flagname,_team],"PLAIN DOWN"]
PlaySound "FlagTake"
 
;;~60 If you remove the ;; then the ~60 will delay the flag
;;returning to the flagpole by 60 seconds.  I leave this off
;;because sometimes someone will try to cap a flag that
;;is on a body and not get there before 60 seconds and the
;;flag disappears on them.
 
 
#FlagReturn
?(_flag==FlagW):_flag SetFlagSide WEST
?(_flag==FlagE):_flag SetFlagSide EAST
?(_flag==FlagR):_flag SetFlagSide RESISTANCE
 
_flag setFlagOwner objNull
_flagreturnmsg=format["%1 has been returned",_flagname]
Hint _flagreturnmsg
 
Goto "start"
 
#end
Exit
 
;;;;END of CTF.SQS


This comes with other supported scripts  but the problem is within this one somewhere
Title: Re:CTF Problem
Post by: LAPD on 20 Jan 2003, 19:21:04
Thanks Terox.  :)
I can't manage to put it in my mission.
I only need a trigger.
I'll put it shortly:

I need a trigger which is activated when someone take the flag from the dead owner and then a message shows someone took the flag (**** has the flag).
I guess that in the conditon field of the trigger i put:
Quote
FlagTaken AND !(Alive OwnerR)

I don't know what to put in the "on activation" field. I need to put there the things which say that if someone takes the flag from the dead body the message will be shown "**** has the flag".

In trigger 3 in the on activation field there is:
Quote
OwnerR = FlagOwner Flag1; FlagTaken = True; TitleText [ Format ["%1 has the flag", Name OwnerR], "PLAIN DOWN"]

I guess in the trigger I want there supposed to be something like that, just that the flagowner is not Flag1.

I hope you understands me  :)
I really want this last bug in my FF (Flag Fight) solved/.
Title: Re:CTF Problem
Post by: Pope_Zog on 22 Jan 2003, 12:25:26
Change the condition of trigger 3 to:

Quote
(!FlagTaken AND flagowner Flag1 in List PlayersList) OR (FlagTaken AND flagowner Flag1 in List PlayersList AND FlagOwner Flag1 != OwnerR)

Pope Zog
Title: Re:CTF Problem
Post by: LAPD on 22 Jan 2003, 15:25:08
Thanks mate  :).

I discovered a new problem  :-\.
When someone take the flag he preform the action of taking the flag.
My problem is that if you take the flag and being shot to death while taking the flag and preforming the action, it won't count that the flag was taken and the flag won't come back to the flag pole after 30 seconds.

Can anyone help me?

I think I need a trigger for it.

Modify: When I take the flag from a dead body the flag returns to the flag pole after a few seconds (depands how much time you took the flag after the flag owner was killed. return to flag pole set to 30 seconds).

How can i prevent this?
Trigger 4 controls the "return of the flag to the pole, should I change something in it's condition field (or something else)?
Title: Re:CTF Problem
Post by: Pope_Zog on 23 Jan 2003, 09:55:36
See my reply in the thread Don't Return the Flag! (http://www.ofpec.com/yabbse/index.php?board=7;action=display;threadid=4071;start=0)

Pope Zog
Title: Re:CTF Problem
Post by: LAPD on 23 Jan 2003, 16:22:12
Thanks, working great.  :)

But what about this:
Quote
When someone take the flag he preform the action of taking the flag.
My problem is that if you take the flag and being shot to death while taking the flag and preforming the action, it won't count that the flag was taken and the flag won't come back to the flag pole after 30 seconds.

Can anyone help me?

Thanks Pope Zog for replaying so far.  :)
Title: Re:CTF Problem
Post by: Terox on 23 Jan 2003, 17:35:15
#FlagReturn
?(_flag==FlagW):_flag SetFlagSide WEST
?(_flag==FlagE):_flag SetFlagSide EAST  
_flag setFlagOwner objNull
_flagreturnmsg=format["%1 \n has been returned",_flagname]
Hint _flagreturnmsg


This is part of a much larger script t6hat does everything for a ctf,

_flagname had previously been stated further up the script (Which is not shown here)


_flag setFlagOwner objNull

the above line is the statement  that you will be interested in
Title: Re:CTF Problem
Post by: LAPD on 23 Jan 2003, 20:39:25
I didn't undetstand what to do. Where should I put it?

By the way, my flag name is Flag1.

I hope it solves this problem:
Quote
When someone take the flag he preform the action of taking the flag.
My problem is that if you take the flag and being shot to death while taking the flag and preforming the action, it won't count that the flag was taken and the flag won't come back to the flag pole after 30 seconds.

Pope Zog helped me with the problem that if someone take the flag from a dead body the flag won't come back to the pole after a few seconds. My problem now is that right when you take the flag from the flagpole and being shot to death while preforming the action of taking the flag, it won't count that the flag was taken and the flag will stay with the dead body and won't come back to the flag pole. How can i fix this?
Title: Re:CTF Problem
Post by: Stix on 24 Jan 2003, 23:56:21
The problem i found with Karillions CTF system was

When a friendly player takes the flag from a dead flag runner, he cant score with it

This is the script I use, could somebody point me in the right direction for a fix pleaseThis comes with other supported scripts  but the problem is within this one somewhere


ew ew where can i get Kars CTF system?
Title: Re:CTF Problem
Post by: Pope_Zog on 25 Jan 2003, 11:06:57
> [...] right when you take the flag from the flagpole and being shot to death [...] the flag will stay with the dead body and won't come back to the flag pole.

Sorry to disappoint you, LAPD, but no matter how many times I replicate this situation, the guy who started taking the flag ends up with it on his corpse, and the flag always returns to the flagpole after the 30 seconds. (I don't know if I should use a :( or :) here ;))

Pope Zog
Title: Re:CTF Problem
Post by: LAPD on 25 Jan 2003, 16:50:39
that's exactly the problem.
He is shot to death while profrming the action and when he is dead it dosen't count that he took the flag. Also, the flag dosen't appear on his corpse, just when you get close to the corpse you can see the action "take flag", but you can't see it.

If you can make a trigger or something that says that the flag wasn't taken and someone died while trying taking the flag it will be good, but I don't think it's possible  :'(.

If it was supposed to be normal when this happends so i don't know what to do, it ain't normal in my mission.

I played the FLAGFIGHT3 map and when someone die there while taking the flag there is just the sound of taking the flag but it dosen't say "***** has the flag".
I wish I knew how to do that.
Title: Re:CTF Problem
Post by: LAPD on 26 Jan 2003, 21:12:53
Well, I found out that the flag does appear on the corpse, but it still dosen't return to the flag pole, since it dosen't count that the flag was taken.

Here is my trigger 3, which supposed to count that the flag was taken:
Quote
X axis: 2500    Y axis : 2500
Activation: Anybody, Repeatedly, Present

Condition: (!FlagTaken AND flagowner Flag1 in List PlayersList) OR (FlagTaken AND flagowner Flag1 in List PlayersList AND FlagOwner Flag1 != OwnerR)

On Activation: OwnerR = FlagOwner Flag1; FlagTaken = True; TitleText [ Format ["%1 has the flag!", Name OwnerR], "PLAIN DOWN"];

I guess it dosen't count it when you die while prefirmint the action of taking the flag, look if I can add something to the condition field or something else.

Hope this helps  :)
Title: Re:CTF Problem
Post by: Sol Fire on 27 Jan 2003, 06:23:02
I was following the CTF tutorial by Backoff.

from what i read of that Tutorial it isnt CTF it is Flag Fight.. for those of you confusing CTF with Flag Fight...

Flag fight involves no teams free for all action for 1 flag.. Team Flag Figh is a team based Flag Fight for one flag

Capture The Flag involves 2 (maybe more) teams who attempt to take the Enemy flag while protecting their own

Example.. im US.. your Russia.. i guard US flag and try to take Russia you Guard Russia and try to take US...

the only thing simular in my oppinion between CTF and Flag Fight is people fighting for flags

i hope the Tutorials called CTF but arnt CTF are fixed soon so people dont get confused and end up having a messed up mission trying to use 2 tutorials they thought were CTF bu one turns out to be Flag Fight not CTF... no offense to anyone and i know the Tutorials are damn good(i use them all myself) but for the sake of the Newbie's to OFP Editing.. it will save a lot of questions not getting ansewered because one person asks about CTF but is really using Flag Fight and the people trying to help are trying to fix a CTF problem not Flag Fight

Thank you :)
Title: Re:CTF Problem
Post by: Terox on 27 Jan 2003, 16:02:12
Here is my version of Karrilions CTF script
(You can take the flag from a dead flag runner and score with it)


I havent added the Show message.sqs, or the timer.sqs, just the part you are having problems with.

Simply delete the old ctf.sqs and replace it with this one


ctf.sqs
Quote
;;CTF.sqs (this is the heart of the scoring and such)
 
;;CTF script by KaRRiLLioN
;;Modified by terox with dead flag runner fix
;;This selects the flag's name
 
_flag = _this select 0
?(isnull _flag):goto "end"
 
?(_flag==FlagW):_flag SetFlagSide WEST
?(_flag==FlagE):_flag SetFlagSide EAST
FlagW setflagtexture "usa_vlajka.pac"
FlagE setflagtexture "\flags\vietnam.jpg"  
?(_flag==FlagW):_flagname="the GI Joes Flag"
?(_flag==FlagE):_flagname="the NVA's Flag"
_flag setFlagOwner objNull
goto "start"

#DeadHasFlag
_count = 1
?(isnull Flagowner FlagW) and _flagownerside==WEST:titletext[format["Hail the fallen HERO\n%1\n %2 is lying on his blood soaked corpse\n You have 60 seconds to retrieve it",name _flagowner,_flagname],"PLAIN DOWN"]
?(isnull Flagowner FlagE) and _flagownerside==EAST:titletext[format["Hail the fallen HERO\n%1\n %2 is lying on his blood soaked corpse\n You have 60 seconds to retrieve it",name _flagowner,_flagname],"PLAIN DOWN"]
#deadloop
~1
_count = _count + 1
_flagowner=Flagowner _flag
?(Alive _Flagowner):goto "start"
?(_count == 60):goto "flagreturn"
goto "deadloop"

 
#start
~1
_flagowner=Flagowner _flag
?(isnull _flagowner):Goto "start"
 
?(Side _flagowner==WEST):_team="GI Joes"; _flagownerside=WEST
?(Side _flagowner==EAST):_team="NVA"; _flagownerside=EAST
?!(Alive _flagowner):Goto "DeadHasFlag"
 
#FlagTaken
 
titletext[format["That awesome Warrior dude\n%1\n has taken %2!",name _flagowner,_flagname],"PLAIN DOWN"]
PlaySound "FlagTake"
Goto "loop"

 
 
;;the loop continues to check for whether the flagcarrier is
;;dead, or has capped the flag.  Once either happens, the
;;flag is returned
 
#loop
~1
?(!Alive _flagowner):goto "DeadHasFlag"
?(isnull Flagowner FlagW) and _flagownerside==WEST and _flagowner distance FlagW<4:goto "WCaps"
?(isnull Flagowner FlagE) and _flagownerside==EAST and _flagowner distance FlagE<4:goto "ECaps"

 
Goto "loop"
 
;;this increments the score by 1 point for whichever team
;;caps the flag.  You can change the +1 to +5 or whatever
;;you want for a scoring method.  The ?(local Server)
;;makes sure the score is only incremented by the server
;;so that it remains accurate.
 
#WCaps
?Side Player == West:titletext[format["Awesome Warrior\n%1\n has capped\n %2!",name _flagowner,_flagname],"PLAIN DOWN"]
?Side Player == East:titletext[format["Thay dirty stinking scumbag\n%1\n has capped\n our flag",name _flagowner],"PLAIN DOWN"]
?(local Server):WScore=WScore+5; PublicVariable "WScore"
PlaySound "Capture"
Goto "ShowScore"
 
#ECaps

?Side Player == East:titletext[format["Awesome Warrior\n%1\n has capped\n %2!",name _flagowner,_flagname],"PLAIN DOWN"]
?Side Player == West:titletext[format["Thay dirty stinking scumbag\n%1\n has capped\n our flag",name _flagowner],"PLAIN DOWN"]
?(local Server):EScore=EScore+5; PublicVariable "EScore"
PlaySound "Capture"
Goto "ShowScore"
 

 
#ShowScore
?(local Server):ShowScore=true; PublicVariable "ShowScore"
 
Goto "FlagReturn"
 
 
#FlagReturn
?(_flag==FlagW):_flag SetFlagSide WEST
?(_flag==FlagE):_flag SetFlagSide EAST  
_flag setFlagOwner objNull
_flagreturnmsg=format["%1 \n has been returned",_flagname]
Hint _flagreturnmsg
 
Goto "start"
 
#end
Exit

This works fine

You will have to excuse the Vietnam flag, i copied this from a nam mission i am making


There is one slight error which i havent fixed yet (Just havent had time)
Sometimes when the following line is run

"titletext[format["Hail the fallen HERO\n%1\n %2 is lying on his blood soaked corpse\n You have 60 seconds to retrieve it",name _flagowner,_flagname],"PLAIN DOWN"]"

Instead of saying
"Hail the fallen hero
(Players Name)
the west flag is lying on his blood soaked corpse
You have 60 seconds to retrieve it"


It comes up with an error message where the players name should be

"Hail the fallen hero
(Error message here instead of players name)
the west flag is lying on his blood soaked corpse
You have 60 seconds to retrieve it"


However it doesnt stop the script from running and it only occasionally occurs
It simply just doesnt return the players name


The script is set up for a 60 second delay before the flag is returned
Title: Re:CTF Problem
Post by: Pope_Zog on 27 Jan 2003, 16:46:56
LAPD, try calling this script when Trigger 4 is activated:

Code: [Select]
; Wait a few seconds before proceeding.
~4

; If the soldier was killed in the process of taking the flag, return it immediately.
? OwnerR distance Flag1 < 8 : goto "ReturnFlag"

; Wait for so many seconds before returning the flag.
~20

; If the flag has been taken by someone else, just exit.
? alive flagOwner Flag1 : exit

#ReturnFlag

Flag1 setFlagowner objNull;
OwnerR = objNull;
titletext ["The Flag return", "PLAIN DOWN"];
FlagTaken = False;
"0" objStatus "Active";

Pope Zog
Title: Re:CTF Problem
Post by: Pope_Zog on 27 Jan 2003, 16:54:24
Terox, the variable _flagowner hasn't been declared or used or set when you display the message. You can fix this by changing:

Quote
#DeadHasFlag
_count = 1
?(isnull Flagowner FlagW) and _flagownerside==WEST:titletext[format["Hail the fallen HERO\n%1\n %2 is lying on his blood soaked corpse\n You have 60 seconds to retrieve it",name _flagowner,_flagname],"PLAIN DOWN"]
etc.

to:

Quote
#DeadHasFlag
_flagowner=Flagowner _flag
_count = 1
?(isnull Flagowner FlagW) and _flagownerside==WEST:titletext[format["Hail the fallen HERO\n%1\n %2 is lying on his blood soaked corpse\n You have 60 seconds to retrieve it",name _flagowner,_flagname],"PLAIN DOWN"]

OR by changing name _flagowner to name (Flagowner _flag) where you display the messages.

Pope Zog
Title: Re:CTF Problem
Post by: LAPD on 27 Jan 2003, 18:05:38
It dosen't work.  :(

The script is based that if the flag owner die in the area of the flag the flag will come back immediately, but as i said, it dosen't count that he took the flag until he actually finish doing the action of taking the flag. Well, it's not a big problem, since if a player comes to the area of the flag he can take the flag from the body just like from the flag pole.

Thanks anyway Pope Zog and Terox  :).

P.S:  I'll keep the topic open for Terox to reply to Pope Zog.
Title: Re:CTF Problem
Post by: Terox on 28 Jan 2003, 16:42:56
Thanks for fix Pope