Files
kiwistation/code/game/objects/items/grenades/grenade.dm
T
vuonojenmustaturska 8ddc9677c7 examine-code refactor (#44636)
* 1/4 done? maybe?

* more

* stuff

* incremental stuff

* stuff

* stuff & things

* mostly done but not yet

* stuffing

* stuffing 2: electric boogaloo

* Git Commit and the Kingdom of the Crystal Skull

* make it actually compile

* found more stuff

* fixes

* fix AI laws appearing out of order

* fix windows

* should be the remaining stuff

* this time for real

* i guess it should compile too

* fix sechuds
2019-06-19 22:07:57 +02:00

132 lines
4.6 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 = ITEM_SLOT_BELT
resistance_flags = FLAMMABLE
max_integrity = 40
var/active = 0
var/det_time = 50
var/display_timer = 1
var/clumsy_check = GRENADE_CLUMSY_FUMBLE
/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)
var/clumsy = HAS_TRAIT(user, TRAIT_CLUMSY)
if(clumsy && (clumsy_check == GRENADE_CLUMSY_FUMBLE))
if(prob(50))
to_chat(user, "<span class='warning'>Huh? How does this thing work?</span>")
preprime(user, 5, FALSE)
return FALSE
else if(!clumsy && (clumsy_check == GRENADE_NONCLUMSY_FUMBLE))
to_chat(user, "<span class='warning'>You pull the pin on [src]. Attached to it is a pink ribbon that says, \"<span class='clown'>HONK</span>\"</span>")
preprime(user, 5, FALSE)
return FALSE
return TRUE
/obj/item/grenade/examine(mob/user)
. = ..()
if(display_timer)
if(det_time > 0)
. += "The timer is set to [DisplayTimeText(det_time)]."
else
. += "\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)
log_bomber(user, "has primed a", src, "for detonation")
/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(msg)
to_chat(user, "<span class='warning'>You prime [src]! [capitalize(DisplayTimeText(det_time))]!</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(!active)
if(W.tool_behaviour == TOOL_MULTITOOL)
var/newtime = text2num(stripped_input(user, "Please enter a new detonation time", name))
if (newtime != null && user.canUseTopic(src, BE_CLOSE))
change_det_time(newtime)
to_chat(user, "<span class='notice'>You modify the time delay. It's set for [DisplayTimeText(det_time)].</span>")
if (round(newtime * 10) != det_time)
to_chat(user, "<span class='warning'>The new value is out of bounds. The lowest possible time is 3 seconds and highest is 5 seconds. Instant detonations are also possible.</span>")
return
else if(W.tool_behaviour == TOOL_SCREWDRIVER)
change_det_time()
to_chat(user, "<span class='notice'>You modify the time delay. It's set for [DisplayTimeText(det_time)].</span>")
else
return ..()
/obj/item/grenade/proc/change_det_time(time) //Time uses real time.
if(time != null)
if(time < 3)
time = 3
det_time = round(CLAMP(time * 10, 0, 50))
else
var/previous_time = det_time
switch(det_time)
if (0)
det_time = 30
if (30)
det_time = 50
if (50)
det_time = 0
if(det_time == previous_time)
det_time = 50
/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
/obj/item/grenade/afterattack(atom/target, mob/user)
. = ..()
if(active)
user.throw_item(target)