8 #define steerlib_pull(ent,point) normalize(point - (ent).origin) 17 #define steerlib_push(ent,point) normalize((ent).origin - point) 29 float distance =
bound(0.001,
vlen(this.
origin - point), maximal_distance);
31 return direction * (distance / maximal_distance);
39 float distance =
bound(0.001,
vlen(this.
origin - point), maximal_distance);
42 return direction * (1 - (distance / maximal_distance));
47 float distance =
bound(0.00001,
vlen(this.
origin - point), max_distance);
50 float influense = 1 - (distance / max_distance);
51 influense = min_influense + (influense * (max_influense - min_influense));
53 return direction * influense;
91 float distance =
bound(0.001,
vlen(this.
origin - point), maximal_distance);
94 return direction * (1 - (distance / maximal_distance));
105 if(distance < ideal_distance)
108 return direction * (distance / ideal_distance);
112 return direction * (ideal_distance / distance);
129 if (
vdist(wander_point, >, threshold))
132 range =
bound(0, range, 1);
135 wander_point = wander_point +
randomvec() * (range * 128) -
randomvec() * (range * 128);
145 float distance =
max(
vlen(this.
origin - point), min_distance);
146 if (min_distance < distance)
149 return dodge_dir * (min_distance / distance);
159 vector push =
'0 0 0', pull =
'0 0 0';
165 if(flock_member !=
this)
166 if(flock_member.flock_id ==
this.flock_id)
169 push = push + (
steerlib_repel(
this, flock_member.origin,standoff) * separation_force);
170 pull = pull + (
steerlib_arrive(
this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
172 flock_member = flock_member.chain;
174 return push + (pull* (1 / ccount));
184 vector push =
'0 0 0', pull =
'0 0 0';
190 if(flock_member !=
this)
191 if(flock_member.flock_id ==
this.flock_id)
194 push = push + (
steerlib_repel(
this, flock_member.origin, standoff) * separation_force);
195 pull = pull + (
steerlib_arrive(
this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
197 flock_member = flock_member.chain;
203 return push + (pull * (1 / ccount));
214 vector force =
'0 0 0', center =
'0 0 0';
220 if(swarm_member.flock_id ==
this.flock_id)
223 center = center + swarm_member.origin;
224 force = force + (
steerlib_repel(
this, swarm_member.origin,standoff) * separation_force);
226 swarm_member = swarm_member.chain;
229 center = center * (1 / ccount);
268 vector upwish =
v_up * (fup_left + fup_right);
269 vector downwish = v_down * (fdown_left + fdown_right);
270 vector leftwish = v_left * (fup_left + fdown_left);
273 return (upwish + leftwish + downwish + rightwish) * 0.25;
302 vector leftwish = v_left * f_left;
306 return normalize(leftwish + rightwish + frontwish);
312 vector u =
'0 0 1' * step_up;
313 vector d =
'0 0 1' * step_down;
323 for(
int i = 0; i < length; i += step)
326 vector b = a + dir * step;
327 tracebox(a + u,
'-4 -4 -4',
'4 4 4', b + u,
MOVE_NORMAL,
this);
337 #ifdef BEAMSTEER_VISUAL 338 te_lightning1(
NULL,a+u,b+u);
339 te_lightning1(
NULL,b+u,b-d);
366 float bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
367 float bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
369 float p = bm_left + bm_right;
382 bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
383 bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
386 if(bm_left + bm_right < 0.15)
391 bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
392 bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
398 bm_forward *= bm_forward;
399 bm_right *= bm_right;
float flock_id
flocking by .flock_id Group will move towards the unified direction while keeping close to eachother...
vector steerlib_repel(entity this, vector point, float maximal_distance)
Move away from a point.
bool location_isok(vector point, bool waterok, bool air_isok)
vector steerlib_attract(entity this, vector point, float maximal_distance)
Pull toward a point increasing the pull the closer we get.
vector steerlib_flock(entity this, float _radius, float standoff, float separation_force, float flock_force)
vector steerlib_traceavoid(entity this, float pitch, float length)
Steer towards the direction least obstructed.
const float MOVE_NOMONSTERS
float beamsweep(entity this, vector from, vector dir, float length, float step, float step_up, float step_down)
vector steerlib_arrive(entity this, vector point, float maximal_distance)
Pull toward a point, The further away, the stronger the pull.
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector steerlib_beamsteer(entity this, vector dir, float length, float step, float step_up, float step_down)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense)
vector steerlib_standoff(entity this, vector point, float ideal_distance)
Try to keep at ideal_distance away from point.
vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector vofs)
Steer towards the direction least obstructed.
vector steerlib_wander(entity this, float range, float threshold, vector oldpoint)
A random heading in a forward semicircle.
vector steerlib_swarm(entity this, float _radius, float standoff, float separation_force, float swarm_force)
All members want to be in the center, and keep away from eachother.
vector steerlib_dodge(entity this, vector point, vector dodge_dir, float min_distance)
Dodge a point NOTE: doesn't work well.
vector steerlib_flock2d(entity this, float _radius, float standoff, float separation_force, float flock_force)
flocking by .flock_id Group will move towards the unified direction while keeping close to eachother...