How do you script random starting points for objectives?


(Ifurita) #1

I have 3 ammo bunkers. Currently, the objective sits in one of them. The entities are called:

warhead_trigger
warhead_cmarker

the CTF_blueflag entity doesn’t have a targetname, but I would call it, warhead_model.

So, how do I make it randomly spawn at one of the three bunkers, is it as easy as (I’m swagging this off the top of my head):


game_manager
{
spawn
     {
     set globalaccum 1 random 3 //generate a value from 1-3

     trigger bunker1check
     trigger bunker2check
     trigger bunker3check   
     }

trigger bunker1check
     {
     globalaccum 1 abort_if_not_equal 1

     setstate warhead_trigger1 default
     setstate warhead_cmarker1 default
     setstate warhead_model1 default
     }

... same for bunker2check and bunker3check

... assuming i start up all 3 sets as invisible

//end of game_manager section
}

All three would use the same script

Cheers


(nUllSkillZ) #2

I’ve found a link to a german RTCW-tutorial that covers this theme.
I will try to translate tomorrow:
Zufällige Dokument Positionen (random document positions)


(Ifurita) #3

hummer also did a concept RTCW-map with random obj locations, but I cannot remember the name of the map nor do I have the pk3 file anymore


(Ifurita) #4

I think I got most of it – the script is still in English. If I read right, then the script should look something like this:


game_manager
{

spawn
	{
	accum 2 set 0

	accum 2 random 3 //sets a random # from 1-3

	trigger game_manager random_location 
	} 

trigger random_bunker //triggers all locations check scripts 
   { 
    trigger game_manager remove_bunker01 
   trigger game_manager remove_bunker02 
   trigger game_manager remove_bunker03 
   } 

trigger remove_bunker01 //bunker #1 entities removed if RND not equal to 0 
   { 
    accum 2 abort_if_not_equal 0 
   wait 100 
   trigger warhead_trigger1 dontspawn 
   trigger warhead_cmarker1 dontspawn 
   trigger warhead_model1 dontspawn 
   } 

trigger remove_bunker02 //bunker #2 entities removed if RND not equal to 1 
   { 
    accum 2 abort_if_not_equal 1 
   wait 100 
   trigger warhead_trigger2 dontspawn 
   trigger warhead_cmarker2 dontspawn 
   trigger warhead_model2 dontspawn  
   } 

trigger remove_bunker03 //bunker #3 entities removed if RND not equal to 2 
   { 
    accum 2 abort_if_not_equal 2 
   wait 100 
   trigger warhead_trigger3 dontspawn 
   trigger warhead_cmarker3 dontspawn 
   trigger warhead_model3 dontspawn 
   } 

warhead_trigger1 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_cmarker1 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_model1 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_trigger2 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_cmarker2 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_model2 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_trigger3 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_cmarker3 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 

warhead_model3 //removes named entity 
   { 
    spawn 
      { 
      } 

   trigger dontspawn 
      { 
      remove
      } 
   } 


(nUllSkillZ) #5

The map in the german tutorial is named “Faustlager” mapped by NightWulf and Daywalker.
NightWulf (he is the author of the tutorial) says that the Q3 engine is not able to spawn documents using trigger.
He is using a “trick”.
All documents are in the map.
But they are covert by hollow brushes (func_static’s).
The documents are in the holes.
And then he removes one of the brushes ramdomly (this is how I understand the tutorial).


(Ifurita) #6

hmmmm, you could also setstate them to be invisible, which is how I envisioned to do it initially


(nUllSkillZ) #7

Summarisation and translation of the following RTCW-tutorial:
[MPModus] Zufällige Dokument Positionen by NightWulf

Remark:
I’ve pm’ed NightWulf at level-designer.de and have given him the link of this thread.

[MPModus]Random document positions

[ol]
[li]Introduction
[/li]First used in the map "Faustlager mapped by NightWulf and Daywalker.
Additional credits for XP-Cagey.
[li]Theorie & needed entities
[/li][list:1a230d6bb9]
[li]build a normal map
[/li][li]scripting is like for “stealable objectives”
[/li](it’s described in one of the other tutorials at level-designer.de)
[li]add as many objective spawnpoints (team_CTF_blue or red flag) as you desire
[/li][/ol]
[li]trick
[/li][ul]
[li]the documents always remain in the map.
[/li][li]they only will not be visible (naturally except one).
[/li][li]hide all the documents (for example in a crate).
[/li][li]select the whole object and make a “func_static”-entity.
[/li][li]every “func_static” has to get an unique scriptname (like create01, create02 und create03).
[/li][/ul]
[li]key / value pairs of the document-entities
[/li][ul]
[li]every document has to get an unique scriptname (like allied_obj1, allied_obj2 und allied_obj3).
[/li][li]the other key / value pairs are the same / identical.
[/li][/ul]
[li]Script
[/li]


game_manager
{
	spawn
	{
		...
		accum 2 set 0
		accum 2 random 3
		trigger game_manager random_location 
	}

	trigger random_location
	{ 
		trigger game_manager remove_create01
		trigger game_manager remove_create02
		trigger game_manager remove_create03 
	} 

	trigger remove_create01
	{ 
		accum 2 abort_if_not_equal 0
		wait 1
		trigger create01 dontspawn 
	}

	trigger remove_create02
	{ 
		accum 2 abort_if_not_equal 1
		wait 1
		trigger create02 dontspawn 
	}

	trigger remove_create03
	{ 
		accum 2 abort_if_not_equal 2
		wait 1
		trigger create03 dontspawn 
	}
}

// REMOVE ONE OF THE "func_static"'s
create01
{ 
	spawn
	{
	}

	trigger dontspawn
	{ 
		remove 
	} 
}

create02
{ 
	spawn
	{
	}

	trigger dontspawn
	{ 
		remove 
	} 
}

create03
{ 
	spawn
	{
	}

	trigger dontspawn
	{ 
		remove 
	} 
}

[/list:o:1a230d6bb9]


(SiliconSlick) #8

If setstate invisible/default works, it would probably be
more elegant code-wise. It would also allow you to
randomly pick a new spawn each time they were
dropped without having to respawn all your
entities. Of course, you have to alter your
original code a bit to not assume everything
is invisible to begin with and do the proper
setstate invisibles as well as the setstate
defaults (which would be more robost
code anyway though could grow quickly).

e.g.


trigger bunker1check
     {
     globalaccum 1 abort_if_not_equal 1
     trigger enable_warhead1
     trigger disable_warhead2
     trigger disable_warhead3
     }

trigger enable_warhead1{
     setstate warhead_trigger1 default
     setstate warhead_cmarker1 default
     setstate warhead_model1 default
     } 

trigger disable_warhead1{
     setstate warhead_trigger1 invisible
     setstate warhead_cmarker1 invisible
     setstate warhead_model1 invisible
     } 
...

SiliconSlick