Territory Capture script problems


(TNR360) #1

game_manager
{
	spawn
	{
	wait 50
	
		// Game rules
		wm_axis_respawntime	20
		wm_allied_respawntime	20
		wm_number_of_objectives 7
		wm_set_round_timelimit	60
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies -1=None)
		wm_setwinner	0
		
		wm_number_of_objectives 5
		//Allied objectives
		wm_objective_status 1 1 0 //Capture flag one
		wm_objective_status 2 1 0 //Capture flag two
		wm_objective_status 3 1 0 //Capture flag three
		wm_objective_status 4 1 0 //Capture flag four
		wm_objective_status 5 1 0 //Capture flag five
		//End of Allied obj's. Start of axis.
		wm_objective_status 1 0 1 //Defend flag one
		wm_objective_status 2 0 1 //Defend flag two
		wm_objective_status 3 0 1 //Defend flag three
		wm_objective_status 4 0 1 //Defend flag four
		wm_objective_status 5 0 1 //Defend flag five
		//End of Axis obj's
	}
	
	trigger check_win1 //Checks to see who should win 
	{
	globalaccum 1 abort_if_less_than 3 //If allies don't have less than 3 flags...
	wm_setwinner 1 //Sets the winner to allies 
	}
	trigger check_win2 //Checks to see who should win
	{
	globalaccum 0 abort_if_less_than 3 //If axis don't have less than 3 flags...
	wm_setwinner 0 //Sets the winner to axis
	}
}	

MGNB_flag
{
	spawn
	{
		wait 100
		accum 0 set 0 //Axis have flag
	}
	
	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		globalaccum 0 inc -1 //Axis capture amounts down one
		globalaccum 1 inc 1 //Allied capture amounts up one
		wm_announce "Allies have captured the machine gun nest bulding!"
		wm_objective_status 1 1 1 //Allies have done obj one
		wm_objective_status 1 0 0 //Axis havn't done obj one
		alertentity MGNB_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
	
	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0
		globalaccum 0 inc 1 //Axis capture amounts down one
		globalaccum 1 inc -1 //Allied capture amounts up one
		wm_announce "Axis reclaimed the machine gun nest bulding!"
		wm_objective_status 1 1 0 //Allies havn't done obj one
		wm_objective_status 1 0 1 //Axis have done obj one
		alertentity MGNB_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
}

factory_flag
{
spawn
	{
		wait 100
		accum 0 set 0 //Axis have flag
	}
	
	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		globalaccum 0 inc -1 //Axis capture amounts down one
		globalaccum 1 inc 1 //Allied capture amounts up one
		wm_announce "Allies have captured the factory!"
		wm_objective_status 2 1 1 //Allies have done obj one
		wm_objective_status 2 0 0 //Axis havn't done obj one
		alertentity factory_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
	
	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0
		globalaccum 0 inc 1 //Axis capture amounts down one
		globalaccum 1 inc -1 //Allied capture amounts up one
		wm_announce "Axis reclaimed the factory!"
		wm_objective_status 2 1 0 
		wm_objective_status 2 0 1 
		alertentity factory_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
}
apartment_flag
{
spawn
	{
		wait 100
		accum 0 set 0 //Axis have flag
	}
	
	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		globalaccum 0 inc -1 //Axis capture amounts down one
		globalaccum 1 inc 1 //Allied capture amounts up one
		wm_announce "Allies have captured the apartment!"
		wm_objective_status 3 1 1 
		wm_objective_status 3 0 0 
		alertentity apartment_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
	
	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0
		globalaccum 0 inc 1 //Axis capture amounts down one
		globalaccum 1 inc -1 //Allied capture amounts up one
		wm_announce "Axis reclaimed the apartment!"
		wm_objective_status 3 1 0 //Allies havn't done obj one
		wm_objective_status 3 0 1 //Axis have done obj one
		alertentity apartment_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
}
policestation_flag //Note: This was originally also called apartment_flag XD
{
spawn
	{
		wait 100
		accum 0 set 0 //Axis have flag
	}
	
	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		globalaccum 0 inc -1 //Axis capture amounts down one
		globalaccum 1 inc 1 //Allied capture amounts up one
		wm_announce "Allies have captured the policestation!"
		wm_objective_status 4 1 1 //Allies have done obj one
		wm_objective_status 4 0 0 //Axis havn't done obj one
		alertentity policestation_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
	
	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0
		globalaccum 0 inc 1 //Axis capture amounts down one
		globalaccum 1 inc -1 //Allied capture amounts up one
		wm_announce "Axis reclaimed the policestation!"
		wm_objective_status 4 1 0 //Allies havn't done obj one
		wm_objective_status 4 0 1 //Axis have done obj one
		alertentity policestation_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
}

house_flag
{

spawn
	{
		wait 100
		accum 0 set 0 //Axis have flag
	}
	
	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		globalaccum 0 inc -1 //Axis capture amounts down one
		globalaccum 1 inc 1 //Allied capture amounts up one
		wm_announce "Allies have captured the house!"
		wm_objective_status 5 1 1 //Allies have done obj one
		wm_objective_status 5 0 0 //Axis havn't done obj one
		alertentity house_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
	
	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0
		globalaccum 0 inc 1 //Axis capture amounts down one
		globalaccum 1 inc -1 //Allied capture amounts up one
		wm_announce "Axis reclaimed the house!"
		wm_objective_status 5 1 0 //Allies havn't done obj one
		wm_objective_status 5 0 1 //Axis have done obj one
		alertentity house_wobj
		trigger game_manager check_win1
		trigger game_manager check_win2
	}
}

I cant find whats wrong here…

I want it so if allies have3 or more flags at end of round ALLIES WIN

if axis has 3 or more AXIS WIN

if nobody has touched any flags axis win

there is no specific order

I just cant find the error


(==Troy==) #2

Lol, use the script I used in my map (http://www.splashdamage.com/forums/viewtopic.php?t=16776&start=0)

It defenitely works :stuck_out_tongue: Had the same probs.

Here is the one. It does have scoreboard stuff, but easy to locate it.

Deleted, wrong script lol :P 


(TNR360) #3

no you got it wrong :lol:

its a territory capture script

you touch a flag the position becomes yours team with most territory at map end wins

think something like this —


(==Troy==) #4

domination you mean? Oh, ok , Ill look at the script.


(S14Y3R) #5

try something like this in your game_manager

game_manager
{
   spawn
   {
      wait 500
      wm_set_round_timelimit   2
      wm_axis_respawntime    2
      wm_allied_respawntime   2
      wm_setwinner 0 

      accum 1 set 0
   }

   trigger allies_captured      // update allies captured
   {
      accum 1 inc 1

      //wm_teamvioceannounce "ally_capture" 
      wm_announce "^1the Allies have Captured a Flag!!!"

      trigger game_manager check_game
   }

   trigger axis_captured      // update axis captured
   {
      accum 1 inc -1

      //wm_teamvioceannounce "axxy_capture"
      wm_announce "^1the Axis have Captured a Flag!!!"

      trigger game_manager check_game
   }

   trigger check_game
   {
	   accum 1 abort_if_equal 0 //is still a tie, so game can end wm_setwinner 0 already set

	   accum 1 trigger_if_equal 3 game_manager allies_win

	   accum 1 trigger_if_equal -3 game_manager axis_win

   }

   trigger allies_win
   {
      wm_announce "^1Allies have Captured 3 Flags!!!!"
      wm_setwinner 1   // allies win.
      wm_endround      // end game.
   }

   trigger axis_win
   {
      wm_announce "^1Axis have Captured 3 Flags!!!!"
      wm_setwinner 0   // axis win.
      wm_endround      // end game.
   }
}

and just call : trigger game_manager allies_captured /or axis_captured

It can get confusing with multiple flags all trying to keep track of globalaccum values.


(TNR360) #6

hmm
I dont want it to end with just 3 flags

I need it as I said, nothing else will satisfy me :stuck_out_tongue:

thanks for helping anyway


(kamikazee) #7

It’s quite logical, you set wm_setwinner to “0”:

// Winner on expiration of round timer (0=Axis, 1=Allies -1=None)
      wm_setwinner   0 

(TNR360) #8

that makes sense now I just noticed I messed up one of the script names :stuck_out_tongue:


(C) #9

I want it so if allies have3 or more flags at end of round ALLIES WIN

if axis has 3 or more AXIS WIN

if nobody has touched any flags axis win

there is no specific order

is ^^that^^ the same as vvthisvv: ??

game_manager
{
	// at round-start, the following trigger will be executed by ET..
	spawn
	{
		// ...
		// Your existing spawn event code goes here..
		// ...
	}

	// at round-end, the following trigger will be executed by ET..
	trigger timelimit_hit
	{
		// the winner could be the allies, if they captured 3 flags minimum
		trigger check_winner
		wm_endround
	}

	//Check if allies have captured at least 3 flags..
	trigger check_winner
	{
		// set winning team: 0=axis, 1=allies,-1=none
		wm_setwinner 0
		globalaccum 1 abort_if_less_than 3
		wm_setwinner 1 //Sets the winner to allies
	}
}

You should also delete these lines from any of Your existing allied_capture and axis_capture trigger-routines.

      trigger game_manager check_win1 
      trigger game_manager check_win2 

This way, You only check for a winner at round-end, and not at every single flag-capture.

I have some trouble understanding this “shady-acres” line:?:

if nobody has touched any flags axis win

To TNR360: … my solution is like kamikazee’s solution: Axis win by default.
…otherwise You would need some extra code to keep track of any flag-captures…probably by using an extra globalaccum.


(TNR360) #10

I got it sorted out and axis win by default

oh and also what difference does it make to have a checkwin at every flag and at round end?


(nUllSkillZ) #11

Drakir made a map where the teams have to “capture” flags.
Can’t remember the name of the map.
And his homepage seems to be unavailable.


(S14Y3R) #12

Once a flag is captured you have to know how many flags have been captured so you know how many more you need to capture. If you don’t know, how the hell’s your script supposed to know? That’s what accum values are for.

Ever try: \g_scriptdebug 1? oh wait, there’s a trick to that, you need to watch your console ~~~~~~~

If you can read this, thank a teacher.

If you’re reading this in English, thank a soldier.

If you can’t understand this, read a tutorial.

what difference does it make to have a checkwin at every flag and at round end?

hmm… Why do I need to know how many flags are in play, and how many have been captured…?

I thought you got this working after discovering your typo…


(C) #13

S14Y3R said:

Ever try: \g_scriptdebug 1? oh wait, there’s a trick to that, you need to watch your console

also type the following into the console, to display these debug-messages onto the screen:
/con_drawnotify 1

TNR360:

oh and also what difference does it make to have a checkwin at every flag and at round end?

Obviously, the result would be the same, but with less code execution…
The “timelimit_hit” event gets executed only once every game, at the moment when You want to know the winner.


(TNR360) #14

it does work C just pointed out I can use less code