Fixes issues with raider equipping

Fixes raiders not being able to ever spawn with guns that cannot be equipped to the belt, despite those gun types being in the raider_guns list.
Fixes raiders spawning with guns for which they have no ammo.
Fixes taj/unathi raiders having a 2/3 chance of spawning without any shoes.
This commit is contained in:
mwerezak
2015-07-04 13:48:44 -04:00
parent fad0a712d8
commit c1bbc5c3a6
3 changed files with 95 additions and 14 deletions

View File

@@ -26,7 +26,8 @@ var/datum/antagonist/raider/raiders
var/list/raider_shoes = list(
/obj/item/clothing/shoes/jackboots,
/obj/item/clothing/shoes/sandal,
/obj/item/clothing/shoes/workboots,
/obj/item/clothing/shoes/brown,
/obj/item/clothing/shoes/laceup
)
@@ -42,7 +43,6 @@ var/datum/antagonist/raider/raiders
/obj/item/clothing/head/pirate,
/obj/item/clothing/head/bandana,
/obj/item/clothing/head/hgpiratecap,
/obj/item/clothing/head/flatcap
)
var/list/raider_suits = list(
@@ -87,6 +87,12 @@ var/datum/antagonist/raider/raiders
/obj/item/weapon/gun/projectile/pirate
)
var/list/raider_holster = list(
/obj/item/clothing/accessory/holster/armpit,
/obj/item/clothing/accessory/holster/waist,
/obj/item/clothing/accessory/holster/hip
)
/datum/antagonist/raider/New()
..()
raiders = src
@@ -195,14 +201,18 @@ var/datum/antagonist/raider/raiders
var/new_glasses = pick(raider_glasses)
var/new_helmet = pick(raider_helmets)
var/new_suit = pick(raider_suits)
var/new_gun = pick(raider_guns)
player.equip_to_slot_or_del(new new_shoes(player),slot_shoes)
if(!player.shoes)
//If equipping shoes failed, fall back to equipping sandals
var/fallback_type = pick(/obj/item/clothing/shoes/sandal, /obj/item/clothing/shoes/jackboots/unathi)
player.equip_to_slot_or_del(new fallback_type(player), slot_shoes)
player.equip_to_slot_or_del(new new_uniform(player),slot_w_uniform)
player.equip_to_slot_or_del(new new_glasses(player),slot_glasses)
player.equip_to_slot_or_del(new new_helmet(player),slot_head)
player.equip_to_slot_or_del(new new_suit(player),slot_wear_suit)
player.equip_to_slot_or_del(new new_gun(player),slot_belt)
equip_weapons(player)
var/obj/item/weapon/card/id/id = create_id("Visitor", player)
id.name = "[player.real_name]'s Passport"
@@ -215,6 +225,70 @@ var/datum/antagonist/raider/raiders
return 1
/datum/antagonist/raider/proc/equip_weapons(var/mob/living/carbon/human/player)
var/new_gun = pick(raider_guns)
var/new_holster = pick(raider_holster) //raiders don't start with any backpacks, so let's be nice and give them a holster if they can use it.
var/turf/T = get_turf(player)
var/obj/item/primary = new new_gun(T)
var/obj/item/clothing/accessory/holster/holster = null
//Give some of the raiders a pirate gun as a secondary
if(prob(60))
var/obj/item/secondary = new /obj/item/weapon/gun/projectile/pirate(T)
if(!(primary.slot_flags & SLOT_HOLSTER))
holster = new new_holster(T)
holster.holstered = secondary
secondary.loc = holster
else
player.equip_to_slot_or_del(secondary, slot_belt)
if(primary.slot_flags & SLOT_HOLSTER)
holster = new new_holster(T)
holster.holstered = primary
primary.loc = holster
else if(!player.belt && (primary.slot_flags & SLOT_BELT))
player.equip_to_slot_or_del(primary, slot_belt)
else if(!player.back && (primary.slot_flags & SLOT_BACK))
player.equip_to_slot_or_del(primary, slot_back)
else
player.put_in_any_hand_if_possible(primary)
//If they got a projectile gun, give them a little bit of spare ammo
equip_ammo(player, primary)
if(holster)
var/obj/item/clothing/under/uniform = player.w_uniform
if(istype(uniform) && uniform.can_attach_accessory(holster))
uniform.attackby(holster, player)
else
player.put_in_any_hand_if_possible(holster)
/datum/antagonist/raider/proc/equip_ammo(var/mob/living/carbon/human/player, var/obj/item/weapon/gun/gun)
if(istype(gun, /obj/item/weapon/gun/projectile))
var/obj/item/weapon/gun/projectile/bullet_thrower = gun
if(bullet_thrower.magazine_type)
player.equip_to_slot_or_del(new bullet_thrower.magazine_type(player), slot_l_store)
if(prob(20)) //don't want to give them too much
player.equip_to_slot_or_del(new bullet_thrower.magazine_type(player), slot_r_store)
else if(bullet_thrower.ammo_type)
var/obj/item/weapon/storage/box/ammobox = new(get_turf(player.loc))
for(var/i in 1 to rand(3,5) + rand(0,2))
new bullet_thrower.ammo_type(ammobox)
player.put_in_any_hand_if_possible(ammobox)
return
if(istype(gun, /obj/item/weapon/gun/launcher/grenade))
var/list/grenades = list(
/obj/item/weapon/grenade/empgrenade,
/obj/item/weapon/grenade/smokebomb,
/obj/item/weapon/grenade/flashbang
)
var/obj/item/weapon/storage/box/ammobox = new(get_turf(player.loc))
for(var/i in 1 to 7)
var/grenade_type = pick(grenades)
new grenade_type(ammobox)
player.put_in_any_hand_if_possible(ammobox)
/datum/antagonist/raider/proc/equip_vox(var/mob/living/carbon/human/player)
var/uniform_type = pick(list(/obj/item/clothing/under/vox/vox_robes,/obj/item/clothing/under/vox/vox_casual))

View File

@@ -174,16 +174,8 @@
if(M.equip_to_appropriate_slot(newitem))
return newitem
if(istype(M.back,/obj/item/weapon/storage))
var/obj/item/weapon/storage/backpack = M.back
if(backpack.contents.len < backpack.storage_slots)
newitem.loc = M.back
return newitem
if(M.equip_to_storage(newitem))
return newitem
// Try to place it in any item that can store stuff, on the mob.
for(var/obj/item/weapon/storage/S in M.contents)
if (S.contents.len < S.storage_slots)
newitem.loc = S
return newitem
newitem.loc = get_turf(M.loc)
return newitem

View File

@@ -73,6 +73,21 @@ var/list/slot_equipment_priority = list( \
return 0
/mob/proc/equip_to_storage(obj/item/newitem)
// Try put it in their backpack
if(istype(src.back,/obj/item/weapon/storage))
var/obj/item/weapon/storage/backpack = src.back
if(backpack.contents.len < backpack.storage_slots)
newitem.loc = src.back
return 1
// Try to place it in any item that can store stuff, on the mob.
for(var/obj/item/weapon/storage/S in src.contents)
if (S.contents.len < S.storage_slots)
newitem.loc = S
return 1
return 0
//These procs handle putting s tuff in your hand. It's probably best to use these rather than setting l_hand = ...etc
//as they handle all relevant stuff like adding it to the player's screen and updating their overlays.