randomly choose the attacking/defending team


(FireFly) #1

I’m working on a new map and was wondering if it would be possible to randomly choose the attacking/defending team when the game starts.

First of all you would need double entities for both axis /allies objectives/ multiple TOI’s…With scripting you could disable (setstate command) entities, so that would not cause any problems…

One problem would be: how would the OBJDATA-file look like? My guess is both teams have the same objdata, for example take the objdata-file from the stock map “Radar”

// Axis Objective Descriptions
wm_objective_axis_desc 1 "Primary Objective:**Defend the Radar Installation's Main and Side Doors."


// Allied Objective Descriptions
wm_objective_allied_desc 1 "Primary Objective:**Dynamite the Radar Installation Doors."

It would look something similar to this, because you never know if axis or allies will be the attacking/defending team:

// Axis Objective Descriptions
wm_objective_axis_desc 1 "Primary Objective:**The attacking team must destroy the Main doors, Defending team must avoid this."


// Allied Objective Descriptions
wm_objective_allied_desc 1 "Primary Objective:**The attacking team must destroy the Main doors, Defending team must avoid this."

Doesn`t this also means that the camera´s at the limbo/menu must be pointed at the same Objective regardless if it´s a axis-allies obj?

The biggest problem would be the scripting, particular this part:

// 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

This event is within the game_manager part of the script, I really, really can´t see a way to change the attacking-defending team through scripting, or am I missing something…


(nUllSkillZ) #2

There’s trhe following action:


(global)accum <n> random <m>

Although I’m not sure what it does I think it generates a random number from <0> to that is assigned to accum .

Then you have:


(global)accum <n> trigger_if_equal <m> <s> <t>

which executes event in scriptblock

Try to use something like the following:


game_manager
{
	// ...
	(global)accum 1 random 1
	(global)accum 1 trigger_if_equal 0 game_manager axis_attack
	(global)accum 1 trigger_if_equal 1 game_manager allies_attack
	// ...

	trigger axis_attack
	{
		wm_set_defending_team 1
		wm_setwinner 1
	}

	trigger allies_attack
	{
		wm_set_defending_team 0
		wm_setwinner 0
	}
}

// ...

Edit:

I’ve done a quick search for random.
Out of the 2 sites I’ve found the following:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=4213&highlight=random

[edit1]
Two thoughts:

  • this map can not be played in stopwatch mode
  • you can also setstate the entities within the two triggers I’ve written above
    as an alternative you could call events out of these triggers that remove the entities
    [/edit1]

(FireFly) #3

(global)accum <n> trigger_if_equal <m> <s> <t>

I never heard of that scripting command before:This might be very usefull for future scripting

game_manager
{
// …
(global)accum 1 random 1
(global)accum 1 trigger_if_equal 0 game_manager axis_attack
(global)accum 1 trigger_if_equal 1 game_manager allies_attack
// …

trigger axis_attack
{
wm_set_defending_team 1
wm_setwinner 1
}

trigger allies_attack
{
wm_set_defending_team 0
wm_setwinner 0
}
}

Looking at it, this might work: I will have to do a testmap over the weekend, thanks for pointing me into the right direction…[/quote]


(TFate) #4

It should work perfectly. However, you don’t need globalaccums, just accums. Globalaccums will still work, though.

A great map that takes advantage of random accums is Baserace Beta2, which “randomly” generates the battleground in the center of the map. I heartily recommend taking a look at the .script and see how he does it. It’s really quite genius. :smiley:


(Ifurita) #5

also, take a look at the scripting in Vengeance_final (pcgamemods) as well as the source file, also on pcgamemods. We have our capturable objective randomly spawning in one of 3 bunkers


(nUllSkillZ) #6

I’ve tried to create something like a scripting reference here in the forum:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=9788&highlight=script+event