5a08a3aad0
This way you can add/remove traits without fear of other sources overriding them. Now you can add TRAIT_STUNIMMUNE to somebody without what if hulk
Notable changes:
Fakedeath now updates instantly, instead of waiting for the next life tick.
Fakedeath now sets time of death when acquired.
Removed extremely snowflake code in reagents that checked if you had morphine to remove slow immunity and so on.
Hulk no longer overrides status_flag changes, in case there are any.
117 lines
3.9 KiB
Plaintext
117 lines
3.9 KiB
Plaintext
/obj/item/grenade
|
|
name = "grenade"
|
|
desc = "It has an adjustable timer."
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
icon = 'icons/obj/grenade.dmi'
|
|
icon_state = "grenade"
|
|
item_state = "flashbang"
|
|
lefthand_file = 'icons/mob/inhands/equipment/security_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/equipment/security_righthand.dmi'
|
|
throw_speed = 3
|
|
throw_range = 7
|
|
flags_1 = CONDUCT_1
|
|
slot_flags = SLOT_BELT
|
|
resistance_flags = FLAMMABLE
|
|
max_integrity = 40
|
|
var/active = 0
|
|
var/det_time = 50
|
|
var/display_timer = 1
|
|
|
|
/obj/item/grenade/suicide_act(mob/living/carbon/user)
|
|
user.visible_message("<span class='suicide'>[user] primes [src], then eats it! It looks like [user.p_theyre()] trying to commit suicide!</span>")
|
|
playsound(src, 'sound/items/eatfood.ogg', 50, 1)
|
|
preprime(user, det_time)
|
|
user.transferItemToLoc(src, user, TRUE)//>eat a grenade set to 5 seconds >rush captain
|
|
sleep(det_time)//so you dont die instantly
|
|
return BRUTELOSS
|
|
|
|
/obj/item/grenade/deconstruct(disassembled = TRUE)
|
|
if(!disassembled)
|
|
prime()
|
|
if(!QDELETED(src))
|
|
qdel(src)
|
|
|
|
/obj/item/grenade/proc/clown_check(mob/living/carbon/human/user)
|
|
if(user.has_trait(TRAIT_CLUMSY) && prob(50))
|
|
to_chat(user, "<span class='warning'>Huh? How does this thing work?</span>")
|
|
preprime(user, 5, FALSE)
|
|
return FALSE
|
|
return TRUE
|
|
|
|
|
|
/obj/item/grenade/examine(mob/user)
|
|
..()
|
|
if(display_timer)
|
|
if(det_time > 1)
|
|
to_chat(user, "The timer is set to [det_time/10] second\s.")
|
|
else
|
|
to_chat(user, "\The [src] is set for instant detonation.")
|
|
|
|
|
|
/obj/item/grenade/attack_self(mob/user)
|
|
if(!active)
|
|
if(clown_check(user))
|
|
preprime(user)
|
|
|
|
/obj/item/grenade/proc/log_grenade(mob/user, turf/T)
|
|
var/message = "[ADMIN_LOOKUPFLW(user)]) has primed \a [src] for detonation at [ADMIN_COORDJMP(T)]"
|
|
GLOB.bombers += message
|
|
message_admins(message)
|
|
log_game("[key_name(user)] has primed \a [src] for detonation at [get_area_name(T, TRUE)] [COORD(T)].")
|
|
|
|
/obj/item/grenade/proc/preprime(mob/user, delayoverride, msg = TRUE, volume = 60)
|
|
var/turf/T = get_turf(src)
|
|
log_grenade(user, T) //Inbuilt admin procs already handle null users
|
|
if(user)
|
|
add_fingerprint(user)
|
|
if(iscarbon(user))
|
|
var/mob/living/carbon/C = user
|
|
C.throw_mode_on()
|
|
if(msg)
|
|
to_chat(user, "<span class='warning'>You prime \the [src]! [det_time/10] seconds!</span>")
|
|
playsound(src, 'sound/weapons/armbomb.ogg', volume, 1)
|
|
active = TRUE
|
|
icon_state = initial(icon_state) + "_active"
|
|
addtimer(CALLBACK(src, .proc/prime), isnull(delayoverride)? det_time : delayoverride)
|
|
|
|
/obj/item/grenade/proc/prime()
|
|
|
|
/obj/item/grenade/proc/update_mob()
|
|
if(ismob(loc))
|
|
var/mob/M = loc
|
|
M.dropItemToGround(src)
|
|
|
|
|
|
/obj/item/grenade/attackby(obj/item/W, mob/user, params)
|
|
if(istype(W, /obj/item/screwdriver))
|
|
switch(det_time)
|
|
if ("1")
|
|
det_time = 10
|
|
to_chat(user, "<span class='notice'>You set the [name] for 1 second detonation time.</span>")
|
|
if ("10")
|
|
det_time = 30
|
|
to_chat(user, "<span class='notice'>You set the [name] for 3 second detonation time.</span>")
|
|
if ("30")
|
|
det_time = 50
|
|
to_chat(user, "<span class='notice'>You set the [name] for 5 second detonation time.</span>")
|
|
if ("50")
|
|
det_time = 1
|
|
to_chat(user, "<span class='notice'>You set the [name] for instant detonation.</span>")
|
|
add_fingerprint(user)
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/grenade/attack_hand()
|
|
walk(src, null, null)
|
|
..()
|
|
|
|
/obj/item/grenade/attack_paw(mob/user)
|
|
return attack_hand(user)
|
|
|
|
/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
|
|
var/obj/item/projectile/P = hitby
|
|
if(damage && attack_type == PROJECTILE_ATTACK && P.damage_type != STAMINA && prob(15))
|
|
owner.visible_message("<span class='danger'>[attack_text] hits [owner]'s [src], setting it off! What a shot!</span>")
|
|
prime()
|
|
return TRUE //It hit the grenade, not them
|