Inside3D tutorials.
Created By: SHaDoW.STaLKeR (Evan)
eMail: evan@patriot.net
Difficulty Scale: Easy


Step 1
This tutorial teaches how to make a detonatable hologram. I think its kinda kewl. Anyway, open the file weapons.qc and scroll down to the ImpulseCommands section, we will start there first. Since you don't want to be able to drop more than one hologram and don't want to be able to detonate a hologram that doesn't exist I used IF statements. Add this code into the ImpulseCommand function. The comments will explain the entire section.
    if (self.impulse == 40) //If IMPULSE 40 is typed at console
    {
        if (holoOn == 0) //If the float holoOn is equal to 0
        {
            holo (); //Call the function holo to create a hologram
            holoOn = 1; //Set holoOn to 1 to indicate the hologram is activated
        }
        else //If holoOn is not equal to 0
            sprint (self,"Hologram Already Activated...\n"); //Print an error message
    }
    if (self.impulse == 41) //If IMPULSE 41
    {
        if (holoOn == 1) //If the holoOn is set to 1
        {
            DetHolo (); //Call the DetHolo function to detonate a hologram
            holoOn = 0; //Sets holoOn to 0 to indicate there is no longer a hologram active
        }
        else //If holoOn is not set to 1
            sprint (self,"No Hologram Activated...\n"); //Print an error message
    }


Step 2
By now you're probably wondering where the float holoOn came from and where the functions holo() and DetHolo() came from. Well, that's simple, they don't exist yet. Second, we'll initialize holoOn by scrolling back up to the very top of your the weapons.qc file. This line needs to be added at the VERY top, line 1. It doesn't really NEED to be on line 1, but that way it won't be in any functions and will be a global variable.
float holoOn = 0;     //This float will act as an indicator 0 means
                      //that the hologram is off, 1 meaning it is on


Step 3
Ok.. now onto the functions used in step 1. Scroll down to the ImpulseCommand function again and directly above it you will add this code. The comments are very in depth, but for your information the think part is very similar to that of the pipebomb if you remember. I left out the .nextthink, so that another function could detonate it.
void () holo =
{
   local entity      hologram;  //Declares an entity called hologram

   hologram = spawn (); //Spawns the entity with the following settings
   hologram.origin = self.origin; //Spawns it at the player's current position
   hologram.velocity = aim (self, 1000); //Gives the object a velocity
   hologram.velocity = (hologram.velocity * 550); //Makes velocity slow so it moves slightly
   hologram.solid = SOLID_BBOX; //Makes the hologram solid to object other than yourself
   hologram.movetype = MOVETYPE_TOSS; //Tosses the hologram
   setmodel (hologram,"progs/player.mdl"); //Set it to look like the player
   hologram.frame = 13; //Frame 13 is the player stand position
   setsize (hologram,VEC_HULL_MIN,'16 16 40'); //Sets size of hologram
   hologram.owner = self; //Marks it as yours
   hologram.classname = "hologram"; //Give the object the classname "hologram"

   hologram.think = GrenadeExplode; //called when the command to nextthink is given
   sprint (self,"Hologram Activated...\n"); //Print to screen that the Hologram is Activated
};


Step 4
Wait, your not done yet. Now that you have a hologram, you need a way to detonate it. You've already written the ImpulseCommand so now you must write the function. Directly above the function writen in Step 3 add the function below. Look familiar, it should if you read the pipebomb tutorial.
void() DetHolo =
{
        local entity    holo; //Declares the entity holo

        holo = findradius (self.origin, 10000); //Finds everything within a 10000 radius
        while(holo) //Loops through everything put in the missile entity
        {
                if((holo.classname == "hologram") && (holo.owner == self)) //Checks holo owner
                        holo.nextthink = time; //sends the message that it is time to react
                holo = holo.chain; //links every hologram found so they all go BOOM!
        }
};


Step 5
That's it. Compile it, run it, and have fun. You can now create a hologram and detonate it when IMPULSE 40 and IMPULSE 41 are typed into the console. You can also BIND them to keys. For example, typing BIND X "IMPULSE 41" and BIND Z "IMPULSE 40" at the console to make it so that pressing X will detonate the hologram and Z will create one.