Triggering Things in other Maps

From Dark Wiki

Jump to: navigation, search

originally written by Ishtvan (original Forum Post: http://modetwo.net/darkmod/index.php?showtopic=3718)

I was looking at doom3/base/def/target.def for the first time. It has some interesting things like:

entityDef target_levelTrigger {
   "editor_color"            "1 1 0"
   "editor_mins"            "-8 -8 -8"
   "editor_maxs"            "8 8 8"

   "editor_usage"                "Trigger this to trigger a trigger an upcoming map. It will be triggered when the player spawns"
   "editor_var levelName"        "level name to fire trigger in, this is the map name minus the path, i.e. admin"
   "editor_var triggerName"    "trigger name to fire"

   "spawnclass"            "idTarget_LevelTrigger"
}

Looking at how this works should tell us how to have something in one map effect something in another map. It's encourging that this is already built in. I'm guessing it just maintains a list of trigger states for each map in the persistent player data, and sets off those triggers when the player enters that map.

Just using this already existing capability, FM authors could do things like have a city HUB, and things you do in the city HUB effect the missions or vice versa (my personal fav. example being to find an off-duty guard in the city and bribe/blackmail him to call in sick during the mission). Or for a single mission that has load zones, you could do something like unlock a door in another zone. We could also do things like change the spawnpoint in the map when you go thru a particular exit, to create maps that are interconnected to eachother at several points... Branching storylines... The possibilities are pretty much infinite.

Btw, this is how idTarget_LevelTrigger works in the SDK:

/*
================
idTarget_LevelTrigger::Event_Activate
================
*/
void idTarget_LevelTrigger::Event_Activate( idEntity *activator ) {
   for( int i = 0; i < gameLocal.numClients; i++ ) {
       if ( gameLocal.entities[ i ] ) {
           idPlayer *player = static_cast< idPlayer* >( gameLocal.entities[i] );
           player->SetLevelTrigger( spawnArgs.GetString( "levelName" ), spawnArgs.GetString( "triggerName" ) );
       }
   }
}

As you can see it just sets a level trigger on the player, and when the player spawns in that map the next time, it must go thru and call those triggers. Those triggers could call custom scriptfunctions, so the things we could effect in antoher map are only limited by our imagination.

Personal tools