|
|
This tutorial will show you how to make the a Targetting System which will really make the target easier to see in the dark. The code will search within a range that varies according to the players health for an entity that can take damage and is visible.
* I wrote this code in about 2 minutes including test time
* I'm not responsible for any trouble this may cause you
Step 1:
First, we need to make the damn function. So, open your weapons.qc and find the function W_WeaponFrame ();.
Now above that function add this one. This is our new and improved Target System...... yeah right!!!
void() target_system =
{
local float mega; // variable to see how far to find enemies
if (self.health >= 100) // Used to set how far to find enemies
mega = 600;
else if (self.health >= 90)
mega = 500;
else if (self.health >= 80)
mega = 400;
else if (self.health >= 70)
mega = 300;
else if (self.health >= 60)
mega = 200;
else
mega = 100;
local entity en1;
en1 = findradius (self.origin, mega); // find you some enemies
while (en1)
{
if ((en1.takedamage == DAMAGE_AIM && en1 != self) && visible(en1))
{
particle (en1.origin, '0 0 20', 244, 20); // make my beautiful effects
centerprint (self, "Enemy Target"); // reports any enemies found
}
en1 = en1.chain; // do over and find another
}
};
Step 2:
Now you actually need to look into the function W_WeaponFrame ();, and right after that first
bracket you need to add the following.
target_system ();
Step 3:
Now you can compile my wonderful code and play with the cool gadgets. That's about it for
right now. I'll give you some more tutorials later. Well.... c'ya!!!
|