Inside3D tutorials.
Created By: Pastor
eMail: marklacroix@qtm.net
Difficulty Scale: Easy


Step 1
In this lesson we will make the nails stick into the walls. This is is made by editing the weapons.qc file, so open it up.


Step 2
Scroll down until after the launch_spike to spike_touch. Now what we have to do is take out the self.remove tag. Now when ever the nail gets to the wall,it will have hit nothing. But if you notice when it hits a monster, it just continues through to that self.remove. So we have to make it so the nail "sticks" in the body.

void() spike_touch =
{
local float rand;
        if (other == self.owner)
                return;

        if (other.solid == SOLID_TRIGGER)
                return; // trigger field, do nothing

        if (pointcontents(self.origin) == CONTENT_SKY)
        {
                remove(self);
                return;
        }
        
// hit something that bleeds
        if (other.takedamage)
        {
                spawn_touchblood (9);
                T_Damage (other, self, self.owner, 9);
                
                remove(self);   //add this so they don't float...
                return;         //add this to avoid errors
        }
        else
        {
                WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
                
                if (self.classname == "wizspike")
                        WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
                else if (self.classname == "knightspike")
                        WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
                else
                        WriteByte (MSG_BROADCAST, TE_SPIKE);
                WriteCoord (MSG_BROADCAST, self.origin_x);
                WriteCoord (MSG_BROADCAST, self.origin_y);
                WriteCoord (MSG_BROADCAST, self.origin_z);
        }

        self.velocity = '0 0 0';        //add this, it makes the nail stop

        self.nextthink = time + 10;     //add this, to prevent packet overflows
        self.think = SUB_Remove;        //add this for same reason as above

};


Step 3
And that's it! Pretty easy, eh? Compile it, and load it up the usual way. The only problem is that when you shoot a door and open it, the nails still float. But it is kinda cool to then shut the door and listen to 'em bounce around inside :) This bug is fixable, but it's much more complicated than this alone, maybe a later lesson...