Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. case "idle":
  2. {
  3. var search = false;
  4. if(npc_heat < 25){state="cold";update_count=0;}else{search=true}
  5. if(npc_heat > 75){state="hot";update_count=0;}else{search=true}
  6. if(npc_food < 60){state="hungry";update_count=0;}else{search=true}
  7. if(npc_thirst < 60){state="thirsty";update_count=0;}else{search=true}
  8. if(npc_anger > 25){state="angry";update_count=0;}else{search=true}
  9. if(npc_fear > 25){state="scared";update_count=0;}else{search=true}
  10. if(search){
  11. if ( ai_reproduce_cd <= 0 ){
  12. inst = collision_circle(x,y,1300,obj_npc_wolf,false,true);if ( inst == noone ){path_point[0]=0;path_point[1]=0;}
  13. if ( inst != noone ){
  14. if ( point_distance(x,y,inst.x,inst.y) < 1400 ){path_point[0]=floor(inst.x/16)*16;path_point[1]=floor(inst.y/16)*16;}else{path_point[0]=0;path_point[1]=0;}}
  15. if ( !ai_path_set ){ai_path_set=true;
  16. if ( path_point[0] != 0 && path_point[1] != 0 ){
  17. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,path_point[0],path_point[1],true);
  18. if(ai_test_path){path_start(ai_path_id,v_speed/2,0,true);}else{
  19. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,path_point[0],path_point[1],true);
  20. if(ai_test_path){path_start(ai_path_id,v_speed/2,0,true);}else{
  21. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,path_point[0],path_point[1],true);
  22. if(ai_test_path){path_start(ai_path_id,v_speed/2,0,true);}else{
  23. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,path_point[0],path_point[1],true);
  24. if(ai_test_path){path_start(ai_path_id,v_speed/2,0,true);}}}}
  25. }else{
  26. move_dir=random_range(move_dir-(30*ai_expand_search),move_dir+(30*ai_expand_search));ai_path_set=true;ai_dir = point_direction(x,y,x+lengthdir_x(200,move_dir),y+lengthdir_y(200,move_dir));
  27. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,x+lengthdir_x(200,move_dir),y+lengthdir_y(200,move_dir),true);ai_expand_search=1;
  28. if(ai_test_path){path_start(ai_path_id,v_speed/1.5,0,true);}else{ai_expand_search+=0.25;}
  29. }}else{
  30. update_count++;
  31. if(30 <= update_count){update_count=0;ai_path_set=false;}}
  32. inst = collision_circle(x,y,32,obj_npc_wolf,false,true);
  33. if ( inst != noone ){state="reproduce";update_count=0;path_end();ai_path_set=false;inst_cache=inst;}
  34. }else{
  35. if ( !ai_path_set ){ai_path_set=true;
  36. move_dir=random_range(move_dir-(30*ai_expand_search),move_dir+(30*ai_expand_search));ai_path_set=true;ai_dir = point_direction(x,y,x+lengthdir_x(200,move_dir),y+lengthdir_y(200,move_dir));
  37. ai_test_path=mp_grid_path(global.pathing_grid,ai_path_id,x,y,x+lengthdir_x(200,move_dir),y+lengthdir_y(200,move_dir),true);ai_expand_search=1;
  38. if(ai_test_path){path_start(ai_path_id,v_speed/2,0,true);}else{ai_expand_search+=0.25;}}
  39. update_count++;
  40. if(15 == update_count){update_count=0;ai_path_set=false;}}
  41. }
  42. break;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement