[nexuiz-commits] r8207 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Nov 4 08:27:14 EST 2009


Author: tzork
Date: 2009-11-04 08:27:14 -0500 (Wed, 04 Nov 2009)
New Revision: 8207

Modified:
   trunk/data/qcsrc/server/steerlib.qc
   trunk/data/qcsrc/server/verbstack.qc
Log:
lib updates

Modified: trunk/data/qcsrc/server/steerlib.qc
===================================================================
--- trunk/data/qcsrc/server/steerlib.qc	2009-11-04 13:17:39 UTC (rev 8206)
+++ trunk/data/qcsrc/server/steerlib.qc	2009-11-04 13:27:14 UTC (rev 8207)
@@ -11,11 +11,13 @@
 /**
     Uniform push from a point
 **/
+#define steerlib_push(point) normalize(self.origin - point)
+/*
 vector steerlib_push(vector point)
 {
     return normalize(self.origin - point);
 }
-
+*/
 /**
     Pull toward a point, The further away, the stronger the pull.
 **/
@@ -156,6 +158,8 @@
     float distance;
 
     distance = max(vlen(self.origin - point),min_distance);
+    if (min_distance < distance)
+        return '0 0 0';
 
     return dodge_dir * (min_distance/distance);
 }
@@ -187,6 +191,36 @@
 }
 
 /**
+    flocking by .flock_id
+    Group will move towards the unified direction while keeping close to eachother.
+    xy only version (for ground movers).
+**/
+vector steerlib_flock2d(float radius, float standoff,float separation_force,float flock_force)
+{
+    entity flock_member;
+    vector push,pull;
+    float ccount;
+
+    flock_member = findradius(self.origin,radius);
+    while(flock_member)
+    {
+        if(flock_member != self)
+        if(flock_member.flock_id == self.flock_id)
+        {
+            ++ccount;
+            push = push + (steerlib_repell(flock_member.origin, standoff) * separation_force);
+            pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, radius) * flock_force);
+        }
+        flock_member = flock_member.chain;
+    }
+
+    push_z = 0;
+    pull_z = 0;
+
+    return push + (pull * (1 / ccount));
+}
+
+/**
     All members want to be in the center, and keep away from eachother.
     The furtehr form the center the more they want to be there.
 
@@ -220,6 +254,7 @@
 /**
     Steer towards the direction least obstructed.
     Run four tracelines in a forward funnel, bias each diretion negative if something is found there.
+    You need to call makevectors() (or equivalent) before this function to set v_forward and v_right
 **/
 vector steerlib_traceavoid(float pitch,float length)
 {
@@ -228,6 +263,7 @@
     vector upwish,downwish,leftwish,rightwish;
     vector v_left,v_down;
 
+
     v_left = v_right * -1;
     v_down = v_up * -1;
 
@@ -254,7 +290,6 @@
     fdown_right = trace_fraction;
 
     //te_lightning1(world,self.origin, trace_endpos);
-
     upwish    = v_up    * (fup_left   + fup_right);
     downwish  = v_down  * (fdown_left + fdown_right);
     leftwish  = v_left  * (fup_left   + fdown_left);
@@ -266,7 +301,7 @@
 
 /**
     Steer towards the direction least obstructed.
-    Run two tracelines in a forward trident, bias each diretion negative if something is found there.
+    Run tracelines in a forward trident, bias each direction negative if something is found there.
 **/
 vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
 {
@@ -339,6 +374,7 @@
     return 1;
 }
 
+//#define BEAMSTEER_VISUAL
 float beamsweep(vector from, vector dir,float length, float step,float step_up, float step_down)
 {
     float i;
@@ -369,10 +405,10 @@
 
         if(beamsweep_badpoint(trace_endpos,0))
             return i / length;
-
-        //te_lightning1(world,a+u,b+u);
-        //te_lightning1(world,b+u,b-d);
-
+#ifdef BEAMSTEER_VISUAL
+        te_lightning1(world,a+u,b+u);
+        te_lightning1(world,b+u,b-d);
+#endif
         a = trace_endpos;
     }
 
@@ -386,8 +422,18 @@
 
     dir_z *= 0.15;
     vr = vectoangles(dir);
-    vr_x *= -1;
+    //vr_x *= -1;
 
+    tracebox(self.origin , self.mins,self.maxs,self.origin +  (dir * length) ,MOVE_NOMONSTERS,self);
+    if(trace_fraction == 1.0)
+    {
+        //te_lightning1(self,self.origin,self.origin +  (dir * length));
+        return dir;
+    }
+
+
+
+
     makevectors(vr);
     bm_forward = beamsweep(self.origin, v_forward, length, step, step_up, step_down);
 

Modified: trunk/data/qcsrc/server/verbstack.qc
===================================================================
--- trunk/data/qcsrc/server/verbstack.qc	2009-11-04 13:17:39 UTC (rev 8206)
+++ trunk/data/qcsrc/server/verbstack.qc	2009-11-04 13:27:14 UTC (rev 8207)
@@ -2,9 +2,12 @@
 .entity verbs_idle;
 .entity verbs_attack;
 .entity verbs_move;
+//.entity vchain;
 
 /// This global gets set to the verb in question each time the stack manager calls verb_call
 entity verb;
+//.entity current_verb;
+//.float verb_done;
 
 /// Execure this verb
 #define VCM_DO     0
@@ -31,6 +34,54 @@
 /// verb_call(VCM_DO) returns this when a verb should be deleted by the stack manager
 #define VS_CALL_REMOVE    -3
 
+/*
+void verbstack_updatechain(entity stack)
+{
+    entity vrb, v;
+    if not (stack)
+        return;
+
+    dprint("verbstack_updatechain\n");
+
+    vrb = findchainentity(verbstack, stack);
+    if not (vrb)
+    {
+        stack.vchain = world;
+        return;
+    }
+
+    stack.vchain = vrb;
+    v = vrb;
+
+    while(vrb)
+    {
+        vrb = vrb.chain;
+
+
+    }
+}
+
+void verbstack_remove(entity vverb)
+{
+    entity vstack;
+    dprint("verbstack_remove\n");
+
+    vstack = verb.verbstack;
+    remove(vverb);
+    vverb.verbstack = world;
+    verbstack_updatechain(vstack);
+
+    //vverb.think = SUB_Remove;
+    //vverb.nextthink = time;
+}
+
+void verbstack_thinkremove()
+{
+    dprint("verbstack_thinkremove\n");
+    verbstack_remove(self);
+}
+*/
+
 /**
     Push a new verb onto the specified stack. Set vrb_life to make it time-limited.
 **/
@@ -50,12 +101,18 @@
     vrb.verb_call         = vrb_call;
     vrb.verb_static_value = val_static;
 
+    vrb.classname         = "verb";
+    stack.classname       = "verbstack";
+
     if(vrb_life)
     {
+        //vrb.think     = verbstack_thinkremove;
         vrb.think     = SUB_Remove;
         vrb.nextthink = time + vrb_life;
     }
 
+    //verbstack_updatechain(stack);
+
     return vrb;
 }
 
@@ -71,8 +128,11 @@
     oldself = self;
 
     vrb = findchainentity(verbstack,stack);
+    //vrb = stack.vchain;
+    //dprint("owner:", stack.owner.classname, " vsn:", stack.classname,"\n");
     while(vrb)
     {
+        //dprint("vn:", vrb.classname,"\n");
         verb  = vrb;
         vrb   = vrb.chain;
         self  = verb.owner;
@@ -151,7 +211,7 @@
         vrb   = vrb.chain;
         value = verb.verb_call(VCM_EVAL);
 
-        if(value > 0)
+        if(value < 0)
         {
             if(value == VS_CALL_REMOVE)
                 remove(verb);
@@ -197,4 +257,18 @@
     }
 
     self = oldself;
+
+    //stack.vchain = world;
 }
+
+void verbstack_doverb(entity vrb)
+{
+    float value;
+
+    verb  = vrb;
+    self  = verb.owner;
+    value = verb.verb_call(VCM_DO);
+
+    if(value == VS_CALL_REMOVE)
+        remove(vrb);
+}



More information about the nexuiz-commits mailing list