mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Flash rebalance.
This commit is contained in:
@@ -11,10 +11,79 @@
|
||||
origin_tech = list(TECH_MAGNET = 2, TECH_COMBAT = 1)
|
||||
|
||||
var/times_used = 0 //Number of times it's been used.
|
||||
var/broken = 0 //Is the flash burnt out?
|
||||
var/broken = FALSE //Is the flash burnt out?
|
||||
var/last_used = 0 //last world.time it was used.
|
||||
var/max_flashes = 10 // How many times the flash can be used before needing to self recharge.
|
||||
var/halloss_per_flash = 30
|
||||
var/break_mod = 3 // The percent to break increased by every use on the flash.
|
||||
|
||||
var/can_break = TRUE // Can the flash break?
|
||||
var/can_repair = FALSE // Can you repair the flash?
|
||||
var/repairing = FALSE // Are we repairing right now?
|
||||
|
||||
var/safe_flashes = 2 // How many flashes are kept in 1% breakchance?
|
||||
|
||||
var/charge_only = FALSE // Does the flash run purely on charge?
|
||||
|
||||
var/base_icon = "flash"
|
||||
|
||||
var/obj/item/weapon/cell/power_supply //What type of power cell this uses
|
||||
var/charge_cost = 30 //How much energy is needed to flash.
|
||||
var/use_external_power = FALSE // Do we use charge from an external source?
|
||||
|
||||
var/cell_type = /obj/item/weapon/cell/device
|
||||
|
||||
/obj/item/device/flash/Initialize()
|
||||
..()
|
||||
power_supply = new cell_type(src)
|
||||
|
||||
/obj/item/device/flash/attackby(var/obj/item/W, var/mob/user)
|
||||
if(W.is_screwdriver() && broken)
|
||||
if(repairing)
|
||||
to_chat(user, "<span class='notice'>\The [src] is already being repaired!</span>")
|
||||
return
|
||||
user.visible_message("<span class='notice'>\The [user] starts trying to repair \the [src]'s bulb.</span>")
|
||||
repairing = TRUE
|
||||
if(do_after(user, (40 SECONDS + rand(0, 20 SECONDS)) * W.toolspeed) && can_repair)
|
||||
if(prob(30))
|
||||
user.visible_message("<span class='notice'>\The [user] successfully repairs \the [src]!</span>")
|
||||
broken = FALSE
|
||||
update_icon()
|
||||
playsound(src.loc, W.usesound, 50, 1)
|
||||
else
|
||||
user.visible_message("<span class='notice'>\The [user] fails to repair \the [src].</span>")
|
||||
repairing = FALSE
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/device/flash/update_icon()
|
||||
var/obj/item/weapon/cell/battery = power_supply
|
||||
|
||||
if(use_external_power)
|
||||
battery = get_external_power_supply()
|
||||
|
||||
if(broken || !battery || battery.charge < charge_cost)
|
||||
icon_state = "[base_icon]burnt"
|
||||
else
|
||||
icon_state = "[base_icon]"
|
||||
return
|
||||
|
||||
/obj/item/device/flash/get_cell()
|
||||
return power_supply
|
||||
|
||||
/obj/item/device/flash/proc/get_external_power_supply()
|
||||
if(isrobot(src.loc))
|
||||
var/mob/living/silicon/robot/R = src.loc
|
||||
return R.cell
|
||||
if(istype(src.loc, /obj/item/rig_module))
|
||||
var/obj/item/rig_module/module = src.loc
|
||||
if(module.holder && module.holder.wearer)
|
||||
var/mob/living/carbon/human/H = module.holder.wearer
|
||||
if(istype(H) && H.back)
|
||||
var/obj/item/weapon/rig/suit = H.back
|
||||
if(istype(suit))
|
||||
return suit.cell
|
||||
return null
|
||||
|
||||
/obj/item/device/flash/proc/clown_check(var/mob/user)
|
||||
if(user && (CLUMSY in user.mutations) && prob(50))
|
||||
@@ -29,31 +98,53 @@
|
||||
for(var/i=0, i < max_flashes, i++)
|
||||
if(last_used + 10 SECONDS > world.time)
|
||||
break
|
||||
|
||||
else if(use_external_power)
|
||||
var/obj/item/weapon/cell/external = get_external_power_supply()
|
||||
if(!external || !external.use(charge_cost)) //Take power from the borg or rig!
|
||||
break
|
||||
|
||||
else if(!power_supply || !power_supply.checked_use(charge_cost))
|
||||
break
|
||||
|
||||
last_used += 10 SECONDS
|
||||
times_used--
|
||||
|
||||
last_used = world.time
|
||||
times_used = max(0,round(times_used)) //sanity
|
||||
update_icon()
|
||||
|
||||
// Returns true if the device can flash.
|
||||
/obj/item/device/flash/proc/check_capacitor(var/mob/user)
|
||||
//spamming the flash before it's fully charged (60 seconds) increases the chance of it breaking
|
||||
//It will never break on the first use.
|
||||
if(times_used <= max_flashes)
|
||||
var/obj/item/weapon/cell/battery = power_supply
|
||||
|
||||
if(use_external_power)
|
||||
battery = get_external_power_supply()
|
||||
|
||||
if(times_used <= max_flashes && battery && battery.checked_use(charge_cost))
|
||||
last_used = world.time
|
||||
if(prob( round(times_used / 2) )) //if you use it 10 times in a minute it has a 5% chance to break.
|
||||
broken = 1
|
||||
if(prob( max(0, times_used - safe_flashes) * 2 + (times_used >= 1) ) && can_break) //if you use it 10 times in a minute it has a 30% chance to break.
|
||||
broken = TRUE
|
||||
if(user)
|
||||
to_chat(user, "<span class='warning'>The bulb has burnt out!</span>")
|
||||
icon_state = "flashburnt"
|
||||
update_icon()
|
||||
return FALSE
|
||||
else
|
||||
times_used++
|
||||
update_icon()
|
||||
return TRUE
|
||||
else //can only use it 10 times a minute
|
||||
else if(!charge_only) //can only use it 10 times a minute, unless it runs purely on charge.
|
||||
if(user)
|
||||
update_icon()
|
||||
to_chat(user, "<span class='warning'><i>click</i></span>")
|
||||
playsound(src.loc, 'sound/weapons/empty.ogg', 80, 1)
|
||||
return FALSE
|
||||
else if(battery && battery.checked_use(charge_cost + (round(charge_cost / 4) * max(0, times_used - max_flashes)))) // Using over your maximum flashes starts taking more charge per added flash.
|
||||
times_used++
|
||||
update_icon()
|
||||
return TRUE
|
||||
|
||||
//attack_as_weapon
|
||||
/obj/item/device/flash/attack(mob/living/M, mob/living/user, var/target_zone)
|
||||
@@ -206,6 +297,8 @@
|
||||
desc = "When a problem arises, SCIENCE is the solution."
|
||||
icon_state = "sflash"
|
||||
origin_tech = list(TECH_MAGNET = 2, TECH_COMBAT = 1)
|
||||
base_icon = "sflash"
|
||||
can_repair = FALSE
|
||||
|
||||
//attack_as_weapon
|
||||
/obj/item/device/flash/synthetic/attack(mob/living/M, mob/living/user, var/target_zone)
|
||||
@@ -213,11 +306,17 @@
|
||||
if(!broken)
|
||||
broken = 1
|
||||
to_chat(user, "<span class='warning'>The bulb has burnt out!</span>")
|
||||
icon_state = "flashburnt"
|
||||
update_icon()
|
||||
|
||||
/obj/item/device/flash/synthetic/attack_self(mob/living/carbon/user as mob, flag = 0, emp = 0)
|
||||
..()
|
||||
if(!broken)
|
||||
broken = 1
|
||||
to_chat(user, "<span class='warning'>The bulb has burnt out!</span>")
|
||||
icon_state = "flashburnt"
|
||||
update_icon()
|
||||
|
||||
/obj/item/device/flash/robot
|
||||
name = "mounted flash"
|
||||
can_break = FALSE
|
||||
use_external_power = TRUE
|
||||
charge_only = TRUE
|
||||
|
||||
Reference in New Issue
Block a user