Doom3world

The world is yours! Doom 3 - Quake 4 - ET:QW - Prey - Rage
It is currently Sat Nov 10, 2007 11:05 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Tutorial: Random monster events using triggers & scripts
PostPosted: Mon Jul 31, 2006 10:08 am 
Offline
picked up 100 armour

Joined: Fri Jan 06, 2006 5:10 pm
Posts: 133
Location: Purgatory
In this quick tutorial I will briefly describe how to add random monster events to a map without having to make them teleport in like most random scripts do. Ok, this is really simple(sorry I can't give screenshots, but they shouldn't be needed). Also I will assume you know *somewhat* about using scripts in a map.

1. Create a box room (or wherever you wish to produce this horrible trap within your map).
2. Place a trigger_once somewhere that you know the player is going to step through.
3. Then place 4 imps and give them all the K/Vs "hide" "1" and "no_idle_chatter" "1".
4. Then in the trigger_once give it K/V "call" "impset1".
5. Make a script file for your map.(you *may* need to link it in Doom_main.script)
6. Within this script file add this code:

Code:
   void impset1() {
      float randomnumber = 100 - 1;         //random number - 1 (this is necessary)
      float x = 0;               //temp counting var (this is necessary even though you don't see it)
      float random_x = int(sys.random(randomnumber));   // generate the random number

      if ( random_x < 25)
      {
         sys.trigger ($monster_demon_imp_1);
      }
      if (( 24 < random_x ) && ( random_x < 50 ))
      {
         sys.trigger ($monster_demon_imp_2);
      }
      if (( 49 < random_x ) && ( random_x < 75 ))
      {
         sys.trigger ($monster_demon_imp_3);
      }
      if (74 < random_x)
      {
         sys.trigger ($monster_demon_imp_4);
      }
      //sys.print("And the number is: " + random_x + "\n");
   }

   void main() {
      // main does nothing(except laugh at all unsuspecting players from the shadows!!)
   }


That's all there is to it! I am sure there is a better way to do the above math, but I have been working on this for hours and it works perfectly so who cares? Anyways... now you can add random monster events to your map! :twisted: There's no longer any excuse not to! Many thanks to The Happy Friar for helping me on this! :D

Side note: You can make them also spawn in or whatever. By the way, this will also work for random sounds, hallucinations, etc. Although for random sound effects it would be easier to make a .sndshd file with a list of sounds then have the speaker in your map play off the shader file.

Btw, on another note. How does the "random_delay" work, is a "delay" also required for this? I am trying to figure this one out. If anyone can tell me that would be great.

On a final note:(damn. There sure are alot of "notes" here :P ) I will be adding this type of stuff to vanilla DooM 3. Look forward to my Ultra-Scariness mod where you'll never be able to memorize where the monsters in the Single Player levels are ever again! (unless of course you cheat and look at the scripts :roll: )

Peace out for now... (and GO MAKE SOME COOL MAPS... ) :)

_________________
"You got the Shotgun!" :D


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 5:29 am 
Offline
picked up 100 armour

Joined: Fri Jan 06, 2006 5:10 pm
Posts: 133
Location: Purgatory
I am going to also note that I found that this only works by using trigger_touch or trigger_relay(maybe a few others). Trying to use call when an entity is killed doesn't seem to work, so beware of this. I am not entirely sure why though.

_________________
"You got the Shotgun!" :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group