Map script help please - hold flag win


(fliquid) #1

I need some help with this script, I am new to scripting.
I need this script to end with the team holding the flag to be the winners.


game_manager
{
	spawn
	{
		wait 50
		wm_axis_respawntime 10		// Axis respawn time
		wm_allied_respawntime 10	// Allied respawn time
		wm_set_round_timelimit 15	// Map timelimit
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team 0
		
		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner 0
	}
}

//======================================================
neutral_flag
{
	spawn
{

accum 0 set 2 // Who owns flag: 0-Axis, 1-Allied, 2-Nobody

}

trigger axis_capture // Touched by an Axis playerstart

{

accum 0 abort_if_equal 0 // do Axis own flag?

accum 0 trigger_if_equal 1 neutral_flag axis_reclaim // Reclaimed from Allies

accum 0 set 0 // Axis own the flag

wm_announce "Axis have captured the Forward Flag!"

}

trigger axis_reclaim

trigger allied_capture // Touched by an allied playerstart

{

accum 0 abort_if_equal 1 // do Allies own flag?

accum 0 set 1 // Allied own the flag

wm_announce "Allies have captured the Forward Flag!"

} 	
	}

	trigger checkgame
	{
		accum 1 abort_if_not_equal 1

		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 1

		// End the round
		wm_endround
}

I dont understand why only axis win even if allies have the flag.
Please help me, I will understand if you give me the sollution.


(-SSF-Sage) #2

Tell us EXACTLY what you want. For your script: check the { and } 's again. (Althought it won’t make it work. :slight_smile: )

Do you want the game end when the flag is captured?
Or the team that has it when the round ends?
Or who has it the longest time etc.?


(fliquid) #3

[QUOTE={SSF}Sage;174712]Tell us EXACTLY what you want. For your script: check the { and } 's again. (Althought it won’t make it work. :slight_smile: )

Do you want the game end when the flag is captured?
Or the team that has it when the round ends?
Or who has it the longest time etc.?[/QUOTE]

lol sometimes when something is clear in the head, the output lacks the full picture. :slight_smile:
Sorry. :wink:

The team that has it the when the round ends.


(-SSF-Sage) #4

Try something like this: //should work :smiley:


game_manager
{
	spawn
	{
		wait 50
		wm_axis_respawntime 10		// Axis respawn time
 		wm_allied_respawntime 10	// Allied respawn time
		wm_set_round_timelimit 15	// Map timelimit
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team 0
		
		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner -1 //map won't end before the flag is taken. Change if you don't want such behavior.
	}
}

//======================================================
neutral_flag //assuming the scriptname of the flag is neutral_flag
{
	spawn
        {
        wait 200
        accum 0 set 2 // Who owns flag: 0-Axis, 1-Allied, 2-Nobody
         }

         trigger axis_capture // Touched by an Axis player
         {
         accum 0 abort_if_equal 0 // do Axis own flag?

         accum 0 set 0 // Axis own the flag

         wm_announce "Axis have captured the Forward Flag!"
         wm_setwinner 0 //axis will win when the round expires, unless allied capture
         }

         trigger allied_capture // Touched by an allied player
         {
         accum 0 abort_if_equal 1 // do Allies own flag?

         accum 0 set 1 // Allied own the flag

         wm_announce "Allies have captured the Forward Flag!"
         wm_setwinner 1 //allies will win when the round expires, unless axis capture
         } 	
}


(fliquid) #5

Great job! That did the trick! :slight_smile:


(fliquid) #6

But there i one thing missing, if someone wants this in a cycle the map won’t end.
It has to be a tie when no one takes the flag.
Could you provide me with the additional code for that?


(-SSF-Sage) #7

There is no such a thing in ET as a tie from one round. So basicly you have three choises.
wm_setwinner -1 or 0 or 1.

-1 is tie, but note the game won’t end as you discovered already. The other options to set winner are 0 and 1 which are axis or allies won. When you have the value set to 0 or 1, the game will end when the script triggers command wm_endround, or the round expires. But there’s no help for -1. So you need to deside what you do, or perhaps have some other things that would count it in case the flag won’t be captured.

Edit. And in case the round expires and the flag hasn’t been captured, it will just keep going and going, until some1 capture the flag, which instantly ends the game and declares winner.

EDIT2. I WAS wrong.


(Flippy) #8

I’m sure you can end a round as a draw, by setting wm_setwinner to -1, right?
When you set it to -1 at map start, the timelimt_hit trigger won’t get called, but if you set it to 0 or 1 first, and to -1 in the timelimt_hit trigger, I believe the match ends in a draw.
I’m sure I’ve seen it before.

You can try this by setting ‘wm_setwinner’ to 0 or 1, doesn’t matter, in the above script provided by Sage (in the game_manager spawn part I mean).
Then, create a new trigger in the game_manager called ‘timelimit_hit’, and check the state of the flag there. If the flag is not captured, set wm_setwinner to -1 and call wm_endround.

Something like this maybe:
(Note, I have only added the timelimit_hit part and changed the wm_setwinner at the start)
(I also changed accum to globalaccum)

game_manager
{
	spawn
	{
		wait 50
		wm_axis_respawntime 10		// Axis respawn time
 		wm_allied_respawntime 10	// Allied respawn time
		wm_set_round_timelimit 15	// Map timelimit
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team 0
		
		// Winner on expiration of round timer (0=Axis, 1=Allies)
                // EDITED!
		wm_setwinner 0 // set to 0 or 1, does not matter
	}

        trigger timelimit_hit
        {
                // Abort if flag is captured
                globalaccum 0 abort_if_not_equal 2
                wm_setwinner -1
                wait 500
                wm_endround
        }
}

//======================================================
neutral_flag //assuming the scriptname of the flag is neutral_flag
{
	spawn
        {
        wait 200
        globalaccum 0 set 2 // Who owns flag: 0-Axis, 1-Allied, 2-Nobody
         }

         trigger axis_capture // Touched by an Axis player
         {
         globalaccum 0 abort_if_equal 0 // do Axis own flag?

         globalaccum 0 set 0 // Axis own the flag

         wm_announce "Axis have captured the Forward Flag!"
         wm_setwinner 0 //axis will win when the round expires, unless allied capture
         }

         trigger allied_capture // Touched by an allied player
         {
         globalaccum 0 abort_if_equal 1 // do Allies own flag?

         globalaccum 0 set 1 // Allied own the flag

         wm_announce "Allies have captured the Forward Flag!"
         wm_setwinner 1 //allies will win when the round expires, unless axis capture
         } 	
}

Not sure if it will work but its worth a try.
I’m not sure what happens if you abort the timelimit_hit trigger but I think it will just end the game as usual.

So, as soon as a team caps the flag, globalaccum 0 is updated, AND the current winner (the team that will win once the time has run out) is set.
Once the time has run out, the timelimit_hit trigger is called (automatically, there is no trigger in the script doing that) (as long as wm_setwinner was set to 0 or 1 first).
In this trigger, if a flag has been captured (, globalaccum 0 is NOT 2) the execution thread is cancelled and I expect the game will end with the current winner.
If the flag is ‘blank’, or not captured, globalaccum 0 will be 2 and the thread will not be aborted, setting the winner to -1 (draw) and ending the round.


(-SSF-Sage) #9

I was wrong. wm_endround will end the game even if it’s -1. It says it is a tie. :wink: Btw check out the trigger timelimit_hit again ;). With that globalaccum it won’t ever get executed. Nice work flippy. Again lazyness hit me, I should have tested it in the first place. I just assumed it wouldn’t work cos I thought wm_endround is kinda same as the round expiration.

So it should work. Aslong as you change that globalaccum in trigger timelimit_hit.


(fliquid) #10

Flippy, your version of the script makes the outcome with axis or allies holding flag winner blank top area of the screen. So no one wins and not a tie.

And with no players ingame only spec the same result comes out.
I think something is going very wrong somewhere. I used sage’s suggested fixes of your script version btw.

Sorry Flippy, but I rather have Sage helping me again. :slight_smile:


(-SSF-Sage) #11

Weird. I will test this out of curiosity when I’m home later on (I’m at work atm). I thought there is a possibility it won’t work like that, but we will see it today evening. If it doesn’t work, there is a workaround, but it would disable using of timelimit command ingame to change the timelimit. Oh yeah an you shouldn’t filter helpers, especially Flippy. :slight_smile:

Btw. Is it a trickjump map? :stuck_out_tongue:


(fliquid) #12

[QUOTE={SSF}Sage;174808]Weird. I will test this out of curiosity when I’m home later on (I’m at work atm). I thought there is a possibility it won’t work like that, but we will see it today evening. If it doesn’t work, there is a workaround, but it would disable using of timelimit command ingame to change the timelimit. Oh yeah an you shouldn’t filter helpers, especially Flippy. :slight_smile:

Btw. Is it a trickjump map? :P[/QUOTE]

No not a tj map, and there was no offense towards flippy.
He will still be in the map credits. :slight_smile:


(fliquid) #13

Test version runs on my clans server now: 91.198.27.28:27960
Anyone have a look please for any suggestions. I will remove it in a few days then release the final version.
This has been my first project, I left it rather unfinished after recieving a lot of negative comments.
But this version is a lot differend compared to the original.


(Flippy) #14

Yeah sorry I meant globalaccum 0 obviously. I edited my post.

Can you see if it works for you now?

What do you mean exactly with blank area, no one wins and not a tie?
If nobody wins (a tie), the place where it usually says “Axis wins” or “Allies wins” (or something of that kind) will most probably just say nothing. I’m not sure though, it might say “Tied” or something.
But if you used the script as I posted, you will indeed always get a tie as a result because of a tiny typo (globalaccum 2 instead of globalaccum 0).

Try it again please, it might work now! I can’t test it for myself since I don’t even have ET anymore :stuck_out_tongue:


(-SSF-Sage) #15

It works like a charm. I visited your server btw and had a look at your pk3. Firstable don’t include .srf and .prt files. The script the pk3 has is my version, not Flippy’s. I assume you just haven’t changed the pk3 yet. Oh yeah and Flippy fixed his script, so try it. I tested without the flag and the method works. Flippy: shit happens. :wink:

Edit: also check your maps/opposites_2008 folder (lightmaps), it has script file too (shouldn’t affect tho), but remove it anyway. :slight_smile: