Merge pull request #13327 from KorPhaeron/reactive

check_shields() refactor
This commit is contained in:
duncathan salt
2015-12-07 19:58:17 -06:00
17 changed files with 114 additions and 82 deletions
+9 -4
View File
@@ -99,13 +99,15 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s
var/sharpness = IS_BLUNT
var/toolspeed = 1
var/block_chance = 0
var/hit_reaction_chance = 0 //If you want to have something unrelated to blocking/armour piercing etc. Maybe not needed, but trying to think ahead/allow more freedom
/obj/item/proc/check_allowed_items(atom/target, not_inside, target_self)
if(((src in target) && !target_self) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into))
return 0
else
return 1
/obj/item/device
icon = 'icons/obj/device.dmi'
@@ -315,6 +317,12 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s
// afterattack() and attack() prototypes moved to _onclick/item_attack.dm for consistency
/obj/item/proc/hit_reaction(mob/living/carbon/human/owner, attack_text = "the attack", final_block_chance = 0)
if(prob(final_block_chance))
owner.visible_message("<span class='danger'>[owner] blocks [attack_text] with [src]!</span>")
return 1
return 0
/obj/item/proc/talk_into(mob/M, input, channel, spans)
return
@@ -372,9 +380,6 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s
/obj/item/proc/ui_action_click()
attack_self(usr)
/obj/item/proc/IsShield()
return 0
/obj/item/proc/IsReflect(var/def_zone) //This proc determines if and at what% an object will reflect energy projectiles if it's in l_hand,r_hand or wear_suit
return 0
+1 -1
View File
@@ -288,7 +288,7 @@
origin_tech = null
attack_verb = list("attacked", "struck", "hit")
/obj/item/weapon/twohanded/dualsaber/toy/IsShield()
/obj/item/weapon/twohanded/dualsaber/toy/hit_reaction()
return 0
/obj/item/weapon/twohanded/dualsaber/toy/IsReflect()//Stops Toy Dualsabers from reflecting energy projectiles
@@ -55,15 +55,16 @@
embedded_impact_pain_multiplier = 10
flags = NOSHIELD
origin_tech = "magnets=3;syndicate=4"
block_chance = 50
var/hacked = 0
/obj/item/weapon/melee/energy/sword/New()
if(item_color == null)
item_color = pick("red", "blue", "green", "purple")
/obj/item/weapon/melee/energy/sword/IsShield()
/obj/item/weapon/melee/energy/sword/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(active)
return 1
return ..()
return 0
/obj/item/weapon/melee/energy/attack_self(mob/living/carbon/user)
@@ -136,7 +137,7 @@
icon_state = "esaw_0"
item_color = null
/obj/item/weapon/melee/energy/sword/cyborg/saw/IsShield()
/obj/item/weapon/melee/energy/sword/cyborg/saw/hit_reaction()
return 0
/obj/item/weapon/melee/energy/sword/saber
+9 -6
View File
@@ -1,5 +1,6 @@
/obj/item/weapon/shield
name = "shield"
block_chance = 50
/obj/item/weapon/shield/riot
name = "riot shield"
@@ -17,8 +18,6 @@
attack_verb = list("shoved", "bashed")
var/cooldown = 0 //shield bash cooldown. based on world.time
/obj/item/weapon/shield/riot/IsShield()
return 1
/obj/item/weapon/shield/riot/attackby(obj/item/weapon/W, mob/user, params)
if(istype(W, /obj/item/weapon/melee/baton))
@@ -49,8 +48,10 @@
attack_verb = list("shoved", "bashed")
var/active = 0
/obj/item/weapon/shield/energy/IsShield()
return (active)
/obj/item/weapon/shield/energy/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(active)
return ..()
return 0
/obj/item/weapon/shield/energy/IsReflect()
return (active)
@@ -91,8 +92,10 @@
w_class = 3
var/active = 0
/obj/item/weapon/shield/riot/tele/IsShield()
return (active)
/obj/item/weapon/shield/riot/tele/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(active)
return ..()
return 0
/obj/item/weapon/shield/riot/tele/attack_self(mob/living/user)
active = !active
+12 -9
View File
@@ -115,13 +115,16 @@
/obj/item/weapon/twohanded/offhand/wield()
qdel(src)
/obj/item/weapon/twohanded/offhand/IsShield()//if the actual twohanded weapon is a shield, we count as a shield too!
/obj/item/weapon/twohanded/offhand/hit_reaction()//if the actual twohanded weapon is a shield, we count as a shield too!
var/mob/user = loc
if(!istype(user)) return 0
if(!istype(user))
return 0
var/obj/item/I = user.get_active_hand()
if(I == src) I = user.get_inactive_hand()
if(!I) return 0
return I.IsShield()
if(I == src)
I = user.get_inactive_hand()
if(!I)
return 0
return I.hit_reaction()
///////////Two hand required objects///////////////
//This is for objects that require two hands to even pick up
@@ -209,6 +212,7 @@
origin_tech = "magnets=3;syndicate=4"
item_color = "green"
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
block_chance = 50
var/hacked = 0
/obj/item/weapon/twohanded/dualsaber/New()
@@ -240,11 +244,10 @@
else
user.adjustStaminaLoss(25)
/obj/item/weapon/twohanded/dualsaber/IsShield()
/obj/item/weapon/twohanded/dualsaber/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(wielded)
return 1
else
return 0
return ..()
return 0
/obj/item/weapon/twohanded/dualsaber/attack_hulk(mob/living/carbon/human/user) //In case thats just so happens that it is still activated on the groud, prevents hulk from picking it up
if(wielded)
+2 -6
View File
@@ -64,9 +64,7 @@
throwforce = 10
w_class = 3
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
/obj/item/weapon/claymore/IsShield()
return 1
block_chance = 50
/obj/item/weapon/claymore/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is falling on the [src.name]! It looks like \he's trying to commit suicide.</span>")
@@ -84,6 +82,7 @@
w_class = 3
hitsound = 'sound/weapons/bladeslice.ogg'
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
block_chance = 50
/obj/item/weapon/katana/cursed
slot_flags = null
@@ -92,9 +91,6 @@
user.visible_message("<span class='suicide'>[user] is slitting \his stomach open with the [src.name]! It looks like \he's trying to commit seppuku.</span>")
return(BRUTELOSS)
/obj/item/weapon/katana/IsShield()
return 1
/obj/item/weapon/wirerod
name = "wired rod"
desc = "A rod with some wire wrapped around the top. It'd be easy to attach something to the top bit."