SHARE
TWEET

Untitled

a guest Jul 11th, 2017 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Luca Test script monster random-move
  2. void* x=0;
  3. void* y=0;
  4. void* spawn_x=0;
  5. void* spawn_y=0;
  6.  
  7. #define WALK_LIMIT 150
  8.  
  9. //KaSahto setzt die Events von selber..
  10. void onRandomWalk(void* monster)
  11. {
  12.     int* mob_x=get(monster,x);
  13.     int* mob_y=get(monster,y);
  14.  
  15.     int mob_spawn_x=*get(monster,spawn_x);
  16.     int mob_spawn_y=*get(monster,spawn_y); 
  17.  
  18.     char walk_x=rand();
  19.     char walk_y=rand();
  20.     int  walk_dist=rand()%25+25;
  21.     int dist=(int)walk_x*(int)walk_x+(int)walk_y*(int)walk_y+1; //+1 damit nie 0
  22.     walk_x=((int)walk_x*walk_dist)/dist;
  23.     walk_y=((int)walk_y*walk_dist)/dist;
  24.  
  25.     int new_x=*mob_x + walk_x;
  26.     int new_y=*mob_y + walk_y;
  27.    
  28.     if (((new_x-WALK_LIMIT) >  mob_spawn_x)||
  29.         ((new_x+WALK_LIMIT) <  mob_spawn_x))
  30.         walk_x=-walk_x;
  31.  
  32.     if (((new_y-WALK_LIMIT) >  mob_spawn_y)||
  33.         ((new_y+WALK_LIMIT) <  mob_spawn_y))
  34.         walk_y=-walk_y;
  35.  
  36.     *mob_x+=walk_x;
  37.     *mob_y+=walk_y;
  38.     sendMove(monster, walk_x, walk_y, false);
  39. }
  40.  
  41. const char* init(int state)
  42. {
  43.     //wird von jeden neuen script-instance aufgerufen
  44.     if ((x=getVariable("x")) == 0)
  45.         return "x wurde nicht gefunden";
  46.     if ((y=getVariable("y")) == 0)
  47.         return "y wurde nicht gefunden";
  48.     if ((x=getVariable("spawn_x")) == 0)
  49.         return "spawn_x wurde nicht gefunden";
  50.     if ((y=getVariable("spawn_y")) == 0)
  51.         return "spawn_y wurde nicht gefunden";
  52. }
  53.  
  54. void deinit()
  55. {
  56.     //wird aufgerufen wenn script entladet wird..
  57. }
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