.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
Find any thing in a search radius (Groups : qc : Forum : vault() : Find any thing in a search radius) Locked
Thread Options
numbersix
numbersix quake-c coder++
Nov 28 2013 Anchor

I know you are all "dying" to know how functions like T_RadiusDamage operate.

QC manual:
Function: entity findradius (vector origin, float radius)
origin = origin of sphere
radius = radius of sphere
Returns a chain of entities that have their origins within a spherical area.
The entity returned is e, and the next in the chain is e.chain, until e == world.
Typical usage: find and harm the victims of an explosion.

// defs.qc:
.entity chain;
entity (vector org, float rad) findradius = #22;

// T_RadiusDamage fragment
void (entity inflictor, entity attacker, float damage, entity ignore) T_RadiusDamage =
{
local entity head;
// acquire an entity pointer value for head that is the start of a linked list in head.chain of a series of entities within damage+40 range of inflictor.origin
head = findradius(inflictor.origin, damage+40);

// loop through the linked list
while (head)
{
if (head != ignore) // ignore this thing - often the entity that took direct damage - it does not need damaged again
{

// function code segment does damage here
}
// get the next thing in the linked list
head = head.chain;
}
};



Notes:

The find test is made against the checked entities self.origin.

findradius does not detect all entites! Non-solid entities are NOT put in the list.

Edited by: numbersix

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.