daily pastebin goal
95%
SHARE
TWEET

tacstrike enemy sgs code

snake5 Jun 13th, 2015 249 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global TSEnemy = {};
  2.  
  3. function TSEnemy_Create( eptr, pos, vdir )
  4. {
  5.         E =
  6.         {
  7.                 // enemy pointer for additional queries
  8.                 eptr = eptr,
  9.                
  10.                 // set before tick
  11.                 position = pos,
  12.                 viewdir = vdir,
  13.                
  14.                 // read after tick
  15.                 i_crouch = false,
  16.                 i_move = vec2(0,0),
  17.                
  18.                 // coroutine + timer
  19.                 resume_delay = 0.0,
  20.                 coro_ai_main = co_create( function( E ){ E.AI_proc(); } ),
  21.                
  22.                 // global systems
  23.                 move_to_target = null,
  24.         };
  25.         E = class( E, TSEnemy );
  26.         co_resume( E.coro_ai_main, E );
  27.         return E;
  28. }
  29.  
  30. function TSEnemy.destroy()
  31. {
  32. }
  33.  
  34. function TSEnemy.tick( deltaTime )
  35. {
  36.         this.resume_delay -= deltaTime;
  37.         if( this.resume_delay <= 0.0 )
  38.         {
  39.                 this.resume_delay = toreal( co_resume( this.coro_ai_main ) );
  40.         }
  41.        
  42.         if( this.move_to_target !== null )
  43.         {
  44.                 this.i_move = vec2( this.move_to_target - this.position );
  45.         }
  46. }
  47.  
  48. function TSEnemy.AI_proc()
  49. {
  50.         yield();
  51.         for(;;)
  52.         {
  53.                 cp = vec3(-2.5,2.5,0);
  54.                 this.move_to_target = cp+vec3(1,0,0);yield(1);
  55.                 this.move_to_target = cp+vec3(0,1,0);yield(1);
  56.                 this.move_to_target = cp+vec3(-1,0,0);yield(1);
  57.                 this.move_to_target = cp+vec3(0,-1,0);yield(1);
  58.                 // TODO
  59.                 yield();
  60.         }
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top