Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. #define NOTHING_SPECIAL 0
  2. #define RELOAD_GUN 1
  3. #define HEAL_MARINE 2
  4. #define GETTING_GUN 3
  5.  
  6. /mob/living/carbon/human/AI //It's like AI xenomorphs but now humans
  7. name = "boi" //Placeholder name, name is applied dynamically when this is created
  8. role = "Marine" //Type of thing it is, can be a medic, leader or engineer
  9. a_intent = "hurt" //All shall die
  10. var/doingaction = 0 //If it's doing an action that has a delay IE dousing an object in acid, certain abilities
  11. var/queuedmovement //The direction you want the AI to go on next, if it wanted to go NW the CustomMove() will go North then West
  12. var/mob/living/carbon/human/target_mob
  13. var/mob/living/carbon/human/LeaderToFollow //A mob that this AI will follow
  14. var/obj/item/weapon/gun/thegun //This is my gun, it's good
  15.  
  16. /obj/item/weapon/gun/rifle/m41a/gyro //Starts with a gyro, for AI marines
  17. starting_attachment_types = list(/obj/item/attachable/gyro)
  18.  
  19. /mob/living/carbon/human/AI/New()
  20. ..()
  21. name = "AI [role] Number [rand(1, 999999)]
  22. ConsiderMovement()
  23. equip_to_slot_or_del(new /obj/item/device/radio/headset/distress/PMC(), WEAR_EAR)
  24. equip_to_slot_or_del(new /obj/item/clothing/under/marine/veteran/PMC(), WEAR_BODY)
  25. equip_to_slot_or_del(new /obj/item/clothing/suit/storage/marine/veteran/PMC(), WEAR_JACKET)
  26. equip_to_slot_or_del(new /obj/item/clothing/gloves/marine/veteran/PMC(), WEAR_HANDS)
  27. equip_to_slot_or_del(new /obj/item/clothing/head/helmet/marine/veteran/PMC(), WEAR_HEAD)
  28. equip_to_slot_or_del(new /obj/item/clothing/shoes/veteran/PMC(), WEAR_FEET)
  29. equip_to_slot_or_del(new /obj/item/clothing/mask/gas/PMC(), WEAR_FACE)
  30. equip_to_slot_or_del(new /obj/item/storage/backpack/satchel(), WEAR_BACK)
  31. equip_to_slot_or_del(new /obj/item/storage/belt/gun/m4a3/vp70(), WEAR_WAIST)
  32. equip_to_slot_or_del(new /obj/item/weapon/gun/rifle/m41a/gyro(), WEAR_J_STORE)
  33. //equip_to_slot_or_del(new /obj/item/weapon/gun/smg/m39/elite(), WEAR_J_STORE)
  34. //equip_to_slot_or_del(new /obj/item/storage/pouch/firstaid/full(), WEAR_L_STORE)
  35. //equip_to_slot_or_del(new /obj/item/storage/pouch/magazine/large/pmc_m39(), WEAR_R_STORE)
  36.  
  37. /mob/living/carbon/human/AI/proc/ConsiderMovement() //Ah damm not this again
  38. if(stat == DEAD || !src)
  39. return //Ded forever feelsbad
  40. if(canmove)
  41. if(doingaction)
  42. switch(doingaction)
  43. if(RELOAD_GUN)
  44. HandleReload()
  45.  
  46. if(GETTING_GUN) //Get the damm gun
  47. if(queuedmovement)
  48. CustomMove(src, get_step(src, queuedmovement), queuedmovement)
  49. else
  50. var/turf/turftogun = get_step(src, get_turf(thegun))
  51. CustomMove(src, turftogun, get_dir(src, thegun))
  52.  
  53. if(NOTHING_SPECIAL) //Follow the leader time if possible
  54. if(queuedmovement)
  55. CustomMove(src, get_step(src, queuedmovement), queuedmovement)
  56. else
  57. if(LeaderToFollow)
  58. if(LeaderToFollow && get_dist(src, LeaderToFollow) < 14) //Follow the leader!
  59. var/turf/turftoleader = get_step_to(src, LeaderToFollow, rand(3, 4)) //Keep some distance
  60. CustomMove(src, turftoleader, get_dir(src, turftoleader))
  61.  
  62. if(RUN_AWAY) //Target mob is way too close, we gotta run away and kite it
  63. if(queuedmovement)
  64. CustomMove(src, get_step(src, queuedmovement), queuedmovement)
  65. else
  66. var/turf/turfaway = get_step_to(src, target_mob, rand(3, 4)) //Keep some distance
  67. CustomMove(src, turfaway, get_dir(src, turfaway))
  68.  
  69. ConsiderActions()
  70. spawn(move_to_delay + movement_delay() + 1) //Worst way to program a AI for 500 points
  71. ConsiderMovement()
  72.  
  73.  
  74. /mob/living/carbon/human/AI/proc/ConsiderActions() //Special things like healing or throwing things or repairing
  75. return
  76.  
  77. /mob/living/carbon/human/AI/proc/ConsiderAttack() //We gotta be shooting something man
  78. if(target_mob && thegun) //We want to see if the gun is in our hands, wielded, loaded with ammo and actually shoot
  79. if(get_inactive_hand() == thegun || get_active_hand() == thegun) //See if the guns already in the hand
  80. thegun.wield() //Hacky
  81. if(!able_to_fire) //If this doesn't work, there's a **high** chance it gotta be reloaded
  82. HandleReload()
  83. thegun.Fire(target_mob, src) //Finally we can shoot the gun and hope it kills
  84.  
  85. else //Gun ain't in hand but it exists, grab the gun that's hopefully in the suit storage
  86. if(get_dist(src, thegun) < 2)
  87. put_in_hands(thegun)
  88. ConsiderAttack()
  89. else //Gun is far away, we gotta pick up the damm gun by getting close to it
  90. doingaction = GETTING_GUN
  91. return
  92. else //No gun? screwed marine
  93. return
  94.  
  95. /mob/living/carbon/human/AI/proc/HandleReload()
  96. say(pick("RELOADING!", "SWAPPING MAGS!", "COVER ME I'M RELOADING!", "SWITCHING MAGS!"))
  97. unload(src, TRUE, TRUE) //Chances are there could still be a magazine inside
  98. var/obj/item/ammo_magazine/rifle/mag = new/obj/item/ammo_magazine/rifle()
  99. replace_magazine(src, mag)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement