SHARE
TWEET

Untitled

a guest Jun 29th, 2011 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. PF_walkmove
  3.  
  4. float(float yaw, float dist) walkmove
  5. */
  6. void
  7. PF_walkmove(void)
  8. {
  9.         edict_t *ent;
  10.         float yaw, dist;
  11.         vec3_t move;
  12.         dfunction_t *oldf;
  13.         int oldself;
  14.  
  15.         ent = PROG_TO_EDICT(pr_global_struct->self);
  16.         yaw = G_FLOAT(OFS_PARM0);
  17.         dist = G_FLOAT(OFS_PARM1);
  18.  
  19.         if(!((int)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
  20.                 G_FLOAT(OFS_RETURN) = 0;
  21.                 return;
  22.         }
  23.  
  24.         yaw = yaw * M_PI * 2 / 360;
  25.  
  26.         move[0] = cos(yaw) * dist;
  27.         move[1] = sin(yaw) * dist;
  28.         move[2] = 0;
  29.  
  30. // save program state, because SV_movestep may call other progs
  31.         oldf = pr_xfunction;
  32.         oldself = pr_global_struct->self;
  33.  
  34.         G_FLOAT(OFS_RETURN) = SV_movestep(ent, move, true);
  35.  
  36.  
  37. // restore program state
  38.         pr_xfunction = oldf;
  39.         pr_global_struct->self = oldself;
  40. }
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top