Flying stuff!
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
Flying stuff!
No, not airplanes, rockets, or hang gliders (those don't actually fly anyway).
I didn't know if this would be worthy of making an entire tutorial for in the tutorials section, just because it's so short, so I posted it here to induce a higher rate of postage (39 cents, can you believe it?) in the forums.
In combat.qc, find
Now add a dir vector, and a bit of code inside an else {} after the if (head.takedamage). It should look like this:
The new code first gets the direction in which the object needs to be thrown, making sure it's not throwing it at the ground (which wouldn't work very well, because in most cases it's already on the ground).
Next, the velocity is applied to the item being thrown, and the FL_ONGROUND flag is removed, so that it can fly properly.
Now compile, fire up your Quake mod, drop several grenades near each other, and watch the magic!
Note that you can change the *12 to a different value to adjust how much they fly.
I didn't know if this would be worthy of making an entire tutorial for in the tutorials section, just because it's so short, so I posted it here to induce a higher rate of postage (39 cents, can you believe it?) in the forums.
In combat.qc, find
- Code: Select all
/*
============
T_RadiusDamage
============
*/
void(entity inflictor, entity attacker, float damage, entity ignore) T_RadiusDamage =
{
local float points;
local entity head;
local vector org;
head = findradius(inflictor.origin, damage+40);
while (head)
{
if (head != ignore)
{
if (head.takedamage)
{
org = head.origin + (head.mins + head.maxs)*0.5;
points = 0.5*vlen (inflictor.origin - org);
if (points < 0)
points = 0;
points = damage - points;
if (head == attacker)
points = points * 0.5;
if (points > 0)
{
if (CanDamage (head, inflictor))
{ // shambler takes half damage from all explosions
if (head.classname == "monster_shambler")
T_Damage (head, inflictor, attacker, points*0.5);
else
T_Damage (head, inflictor, attacker, points);
}
}
}
}
head = head.chain;
}
};
Now add a dir vector, and a bit of code inside an else {} after the if (head.takedamage). It should look like this:
- Code: Select all
/*
============
T_RadiusDamage
============
*/
void(entity inflictor, entity attacker, float damage, entity ignore) T_RadiusDamage =
{
local float points;
local entity head;
local vector org, dir;
head = findradius(inflictor.origin, damage+40);
while (head)
{
if (head != ignore)
{
if (head.takedamage)
{
org = head.origin + (head.mins + head.maxs)*0.5;
points = 0.5*vlen (inflictor.origin - org);
if (points < 0)
points = 0;
points = damage - points;
if (head == attacker)
points = points * 0.5;
if (points > 0)
{
if (CanDamage (head, inflictor))
{ // shambler takes half damage from all explosions
if (head.classname == "monster_shambler")
T_Damage (head, inflictor, attacker, points*0.5);
else
T_Damage (head, inflictor, attacker, points);
}
}
}
else if (head.movetype == MOVETYPE_BOUNCE)
{
dir = head.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
if (dir_z <= 0)
dir_z = 8;
else
dir_z = dir_z + 8;
dir = normalize(dir);
head.velocity = head.velocity + dir*damage*12;
if (head.flags & FL_ONGROUND)
head.flags = head.flags - FL_ONGROUND;
}
}
head = head.chain;
}
};
The new code first gets the direction in which the object needs to be thrown, making sure it's not throwing it at the ground (which wouldn't work very well, because in most cases it's already on the ground).
Next, the velocity is applied to the item being thrown, and the FL_ONGROUND flag is removed, so that it can fly properly.
Now compile, fire up your Quake mod, drop several grenades near each other, and watch the magic!
Note that you can change the *12 to a different value to adjust how much they fly.
Last edited by Entar on Tue Aug 29, 2006 3:50 pm, edited 1 time in total.
-

Entar - Posts: 439
- Joined: Fri Nov 05, 2004 7:27 pm
- Location: At my computer
This qualifies as being worthy of being placed in the tutorials section. I might do it later if I can find the time, real life has been an absolute biatch lately though... :/
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
i think this works the best, without changing TOO much gameplay behavior, also the head != inflictor fixes the explosion...

- Code: Select all
if ((head.movetype == MOVETYPE_BOUNCE) && (head != inflictor))
{
dir = head.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
if (dir_z <= 0)
dir_z = 8;
else
dir_z = dir_z + 8;
dir = normalize(dir);
head.velocity = head.velocity + dir*damage*2;
if (head.flags & FL_ONGROUND)
head.flags = head.flags - FL_ONGROUND;
}
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest