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;
90 float distance =
bound(0.001,
vlen(this.
origin - point), maximal_distance);
93 return direction * (1 - (distance / maximal_distance));
104 if(distance < ideal_distance)
107 return direction * (distance / ideal_distance);
111 return direction * (ideal_distance / distance);
128 if (
vdist(wander_point, >, threshold))
131 range =
bound(0, range, 1);
144 float distance =
max(
vlen(this.
origin - point), min_distance);
145 if (min_distance < distance)
148 return dodge_dir * (min_distance / distance);
158 vector push =
'0 0 0', pull =
'0 0 0';
164 if(flock_member !=
this)
165 if(flock_member.flock_id ==
this.flock_id)
168 push +=
steerlib_repel(
this, flock_member.origin,standoff) * separation_force;
169 pull +=
steerlib_arrive(
this, flock_member.origin + flock_member.velocity, _radius) * flock_force;
171 flock_member = flock_member.chain;
173 return push + (pull* (1 / ccount));
183 vector push =
'0 0 0', pull =
'0 0 0';
189 if(flock_member !=
this)
190 if(flock_member.flock_id ==
this.flock_id)
193 push +=
steerlib_repel(
this, flock_member.origin, standoff) * separation_force;
194 pull +=
steerlib_arrive(
this, flock_member.origin + flock_member.velocity, _radius) * flock_force;
196 flock_member = flock_member.chain;
202 return push + (pull * (1 / ccount));
213 vector force =
'0 0 0', center =
'0 0 0';
219 if(swarm_member.flock_id ==
this.flock_id)
222 center += swarm_member.origin;
223 force +=
steerlib_repel(
this, swarm_member.origin,standoff) * separation_force;
225 swarm_member = swarm_member.chain;
228 center *= 1 / ccount;
267 vector upwish =
v_up * (fup_left + fup_right);
268 vector downwish = v_down * (fdown_left + fdown_right);
269 vector leftwish = v_left * (fup_left + fdown_left);
272 return (upwish + leftwish + downwish + rightwish) * 0.25;
301 vector leftwish = v_left * f_left;
305 return normalize(leftwish + rightwish + frontwish);
311 vector u =
'0 0 1' * step_up;
312 vector d =
'0 0 1' * step_down;
322 for(
int i = 0; i < length; i += step)
326 tracebox(a + u,
'-4 -4 -4',
'4 4 4', b + u,
MOVE_NORMAL,
this);
336#ifdef BEAMSTEER_VISUAL
337 te_lightning1(
NULL,a+u,b+u);
338 te_lightning1(
NULL,b+u,b-d);
365 float bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
366 float bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
368 float p = bm_left + bm_right;
381 bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
382 bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
385 if(bm_left + bm_right < 0.15)
390 bm_right =
beamsweep(
this, this.
origin, vr, length, step, step_up, step_down);
391 bm_left =
beamsweep(
this, this.
origin, vl, length, step, step_up, step_down);
397 bm_forward *= bm_forward;
398 bm_right *= bm_right;
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const float MOVE_NOMONSTERS
float flock_id
flocking by .flock_id Group will move towards the unified direction while keeping close to eachother.
vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector vofs)
Steer towards the direction least obstructed.
vector steerlib_dodge(entity this, vector point, vector dodge_dir, float min_distance)
Dodge a point NOTE: doesn't work well.
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.
float beamsweep(entity this, vector from, vector dir, float length, float step, float step_up, float step_down)
vector steerlib_beamsteer(entity this, vector dir, float length, float step, float step_up, float step_down)
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.
vector steerlib_arrive(entity this, vector point, float maximal_distance)
Pull toward a point, The further away, the stronger the pull.
vector steerlib_standoff(entity this, vector point, float ideal_distance)
Try to keep at ideal_distance away from point.
vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense)
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.
vector steerlib_repel(entity this, vector point, float maximal_distance)
Move away from a point.
vector steerlib_attract(entity this, vector point, float maximal_distance)
Pull toward a point increasing the pull the closer we get.
vector steerlib_wander(entity this, float range, float threshold, vector oldpoint)
A random heading in a forward semicircle.
bool location_isok(vector point, bool waterok, bool air_isok)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()