scripting triggers

Have a question, suggestion, or comment about Aleph One's features and functionality (Lua, MML, the engine itself, etc)? Post such topics here.

scripting triggers

Post Dec 21st '15, 10:23

I was playing some Doom II for kicks today, looking for level-making inspirations, and while the engines between Doom and Marathon are seemingly similar, there is one noticeable thing that Doom can do which Marathon cannot--killing a boss, or perhaps all the monsters on a map, will trigger an action. For instance, in the classic Dead Simple, once you finish killing the Mancubui, the arena opens and around the perimeter are a group of arachnotrons. Once you kill them, the stairs surrounding the exit raise and you can leave the level.

Is there any way through scripting that a Marathon map can do these actions? In particular, can you assign a certain task to activate a tag? For instance, can we script Tag 1 to activate when you kill a particular, say, Mother of all Hunters. Or perhaps have a tag activate when you complete the level objective (extermination, repair, etc)?

Side note: the Xbox-only Doom II episode No Rest For The Living has some serious kick-ass level design. Some of the best I've seen in Doom or Marathon, or any retro-era FPS. I am considering attempting to remake a couple of these levels, specifically March of the Demons, or maybe Vivisection. Awesome topography and bitchin set pieces.

Thanks, and may happy holidays be upon you all!

Post Dec 21st '15, 14:00

You can do all those things with Lua.
User avatar


Post Dec 22nd '15, 01:46

The following Lua script illustrates 4 examples along the lines of what you are requesting:
Code: Select all
Triggers = {}
--called every time any monster is killed
function Triggers.monster_killed(monster, aggressor_player, projectile)
   --activate Tag 1 every time a Mother of all Hunters monster is killed
   if monster.type=="mother of all hunters" then
      Tags[1].active = true
      Players.print"Mother of all Hunters killed"
   --activate Tag 2 when all Juggernauts killed
   if not Tags[2]._done and (monster.type=="minor juggernaut" or monster.type=="major juggernaut") then
      local num = 0 --count number of juggernauts in level
      for m in Monsters() do
         --monster killed has not been removed from Monsters list yet: m~=monsters exludes it
         if (m.type=="minor juggernaut" or m.type=="major juggernaut") and m~=monster then
            num = num + 1
      Players.print("Number of Juggernauts remaining: "..num)
      if num==0 then
         Tags[2].active = true --enable tag 2
         --Note: ._done is a custom field (name it whatever you want)
         Tags[2]._done = true ; --used to stop checking once the tag is activated
         Players.print"All Juggernauts killed"
   --activate Tag 3 after 5 second delay from when first Mother of all Cyborgs monster is killed
    --._done ensures only happens once. Not necessary if only one Mother of all Cyborgs in level
   if not Tags[3]._done and monster.type=="mother of all cyborgs" then
      Tags[3]._delay = Game.ticks + 150 --store game time 150 ticks from now; 150 ticks is 5 sec
      Players.print"Mother of all Cyborgs killed; 5 second delay started"

function Triggers.idle() --called every tick
   --once delay for activation of tag 3 set, every tick check for expiration
   if Tags[3]._delay and Game.ticks>=Tags[3]._delay then
      Tags[3].active = true
      Tags[3]._delay = nil --clear value to stop doing check each tick
      Players.print"5 second delay expired; activating tag 3"
   --activate Tag 4 if all level objectives are complete
   if not Tags[4]._done and Level.calculate_completion_state()=="finished" then
   --Note: completion state can also be "unfinished" or "failed"
      Tags[4].active = true
      Tags[4]._done = true --stop doing check every tick
      Players.print"All objectives complete"
User avatar


Return to Aleph One Discussion

Who is online

Users browsing this forum: No registered users