Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NOTHING_SPECIAL 0
- #define RELOAD_GUN 1
- #define HEAL_MARINE 2
- #define GETTING_GUN 3
- /mob/living/carbon/human/AI //It's like AI xenomorphs but now humans
- name = "boi" //Placeholder name, name is applied dynamically when this is created
- role = "Marine" //Type of thing it is, can be a medic, leader or engineer
- a_intent = "hurt" //All shall die
- var/doingaction = 0 //If it's doing an action that has a delay IE dousing an object in acid, certain abilities
- 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
- var/mob/living/carbon/human/target_mob
- var/mob/living/carbon/human/LeaderToFollow //A mob that this AI will follow
- var/obj/item/weapon/gun/thegun //This is my gun, it's good
- /obj/item/weapon/gun/rifle/m41a/gyro //Starts with a gyro, for AI marines
- starting_attachment_types = list(/obj/item/attachable/gyro)
- /mob/living/carbon/human/AI/New()
- ..()
- name = "AI [role] Number [rand(1, 999999)]
- ConsiderMovement()
- equip_to_slot_or_del(new /obj/item/device/radio/headset/distress/PMC(), WEAR_EAR)
- equip_to_slot_or_del(new /obj/item/clothing/under/marine/veteran/PMC(), WEAR_BODY)
- equip_to_slot_or_del(new /obj/item/clothing/suit/storage/marine/veteran/PMC(), WEAR_JACKET)
- equip_to_slot_or_del(new /obj/item/clothing/gloves/marine/veteran/PMC(), WEAR_HANDS)
- equip_to_slot_or_del(new /obj/item/clothing/head/helmet/marine/veteran/PMC(), WEAR_HEAD)
- equip_to_slot_or_del(new /obj/item/clothing/shoes/veteran/PMC(), WEAR_FEET)
- equip_to_slot_or_del(new /obj/item/clothing/mask/gas/PMC(), WEAR_FACE)
- equip_to_slot_or_del(new /obj/item/storage/backpack/satchel(), WEAR_BACK)
- equip_to_slot_or_del(new /obj/item/storage/belt/gun/m4a3/vp70(), WEAR_WAIST)
- equip_to_slot_or_del(new /obj/item/weapon/gun/rifle/m41a/gyro(), WEAR_J_STORE)
- //equip_to_slot_or_del(new /obj/item/weapon/gun/smg/m39/elite(), WEAR_J_STORE)
- //equip_to_slot_or_del(new /obj/item/storage/pouch/firstaid/full(), WEAR_L_STORE)
- //equip_to_slot_or_del(new /obj/item/storage/pouch/magazine/large/pmc_m39(), WEAR_R_STORE)
- /mob/living/carbon/human/AI/proc/ConsiderMovement() //Ah damm not this again
- if(stat == DEAD || !src)
- return //Ded forever feelsbad
- if(canmove)
- if(doingaction)
- switch(doingaction)
- if(RELOAD_GUN)
- HandleReload()
- if(GETTING_GUN) //Get the damm gun
- if(queuedmovement)
- CustomMove(src, get_step(src, queuedmovement), queuedmovement)
- else
- var/turf/turftogun = get_step(src, get_turf(thegun))
- CustomMove(src, turftogun, get_dir(src, thegun))
- if(NOTHING_SPECIAL) //Follow the leader time if possible
- if(queuedmovement)
- CustomMove(src, get_step(src, queuedmovement), queuedmovement)
- else
- if(LeaderToFollow)
- if(LeaderToFollow && get_dist(src, LeaderToFollow) < 14) //Follow the leader!
- var/turf/turftoleader = get_step_to(src, LeaderToFollow, rand(3, 4)) //Keep some distance
- CustomMove(src, turftoleader, get_dir(src, turftoleader))
- if(RUN_AWAY) //Target mob is way too close, we gotta run away and kite it
- if(queuedmovement)
- CustomMove(src, get_step(src, queuedmovement), queuedmovement)
- else
- var/turf/turfaway = get_step_to(src, target_mob, rand(3, 4)) //Keep some distance
- CustomMove(src, turfaway, get_dir(src, turfaway))
- ConsiderActions()
- spawn(move_to_delay + movement_delay() + 1) //Worst way to program a AI for 500 points
- ConsiderMovement()
- /mob/living/carbon/human/AI/proc/ConsiderActions() //Special things like healing or throwing things or repairing
- return
- /mob/living/carbon/human/AI/proc/ConsiderAttack() //We gotta be shooting something man
- if(target_mob && thegun) //We want to see if the gun is in our hands, wielded, loaded with ammo and actually shoot
- if(get_inactive_hand() == thegun || get_active_hand() == thegun) //See if the guns already in the hand
- thegun.wield() //Hacky
- if(!able_to_fire) //If this doesn't work, there's a **high** chance it gotta be reloaded
- HandleReload()
- thegun.Fire(target_mob, src) //Finally we can shoot the gun and hope it kills
- else //Gun ain't in hand but it exists, grab the gun that's hopefully in the suit storage
- if(get_dist(src, thegun) < 2)
- put_in_hands(thegun)
- ConsiderAttack()
- else //Gun is far away, we gotta pick up the damm gun by getting close to it
- doingaction = GETTING_GUN
- return
- else //No gun? screwed marine
- return
- /mob/living/carbon/human/AI/proc/HandleReload()
- say(pick("RELOADING!", "SWAPPING MAGS!", "COVER ME I'M RELOADING!", "SWITCHING MAGS!"))
- unload(src, TRUE, TRUE) //Chances are there could still be a magazine inside
- var/obj/item/ammo_magazine/rifle/mag = new/obj/item/ammo_magazine/rifle()
- replace_magazine(src, mag)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement