mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-28 14:36:23 +01:00
Makes Technomancer use modifiers, fixes a few bugs
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
var/stacks = MODIFIER_STACK_FORBID // If true, attempts to add a second instance of this type will refresh expire_at instead.
|
||||
var/flags = 0 // Flags for the modifier, see mobs.dm defines for more details.
|
||||
|
||||
var/light_color = null // If set, the mob possessing the modifier will glow in this color. Not implemented yet.
|
||||
var/light_range = null // How far the light for the above var goes. Not implemented yet.
|
||||
var/light_intensity = null // Ditto. Not implemented yet.
|
||||
var/mob_overlay_state = null // Icon_state for an overlay to apply to a (human) mob while this exists. This is actually implemented.
|
||||
|
||||
// Now for all the different effects.
|
||||
// Percentage modifiers are expressed as a multipler. (e.g. +25% damage should be written as 1.25)
|
||||
var/max_health_flat // Adjusts max health by a flat (e.g. +20) amount. Note this is added to base health.
|
||||
@@ -29,6 +34,8 @@
|
||||
var/incoming_healing_percent // Adjusts amount of healing received.
|
||||
var/outgoing_melee_damage_percent // Adjusts melee damage inflicted by holder by a percentage. Affects attacks by melee weapons and hand-to-hand.
|
||||
var/slowdown // Negative numbers speed up, positive numbers slow down movement.
|
||||
var/haste // If set to 1, the mob will be 'hasted', which makes it ignore slowdown and go really fast.
|
||||
var/evasion // Positive numbers reduce the odds of being hit by 15% each. Negative numbers increase the odds.
|
||||
|
||||
/datum/modifier/New(var/new_holder)
|
||||
holder = new_holder
|
||||
@@ -44,12 +51,18 @@
|
||||
to_chat(holder, on_expired_text)
|
||||
on_expire()
|
||||
holder.modifiers.Remove(src)
|
||||
if(mob_overlay_state) // We do this after removing ourselves from the list so that the overlay won't remain.
|
||||
holder.update_modifier_visuals()
|
||||
qdel(src)
|
||||
|
||||
// Override this for special effects when it gets removed.
|
||||
/datum/modifier/proc/on_expire()
|
||||
return
|
||||
|
||||
// Called every Life() tick. Override for special behaviour.
|
||||
/datum/modifier/proc/tick()
|
||||
return
|
||||
|
||||
/mob/living
|
||||
var/list/modifiers = list() // A list of modifier datums, which can adjust certain mob numbers.
|
||||
|
||||
@@ -64,13 +77,16 @@
|
||||
// Get rid of anything we shouldn't have.
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
M.check_if_valid()
|
||||
// Remaining modifiers will now receive a tick(). This is in a second loop for safety in order to not tick() an expired modifier.
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
M.tick()
|
||||
|
||||
// Call this to add a modifier to a mob. First argument is the modifier type you want, second is how long it should last, in ticks.
|
||||
// The SECONDS/MINUTES macro is very helpful for this. E.g. M.add_modifier(/datum/modifier/example, 5 MINUTES)
|
||||
/mob/living/proc/add_modifier(var/modifier_type, var/expire_at = null)
|
||||
// First, check if the mob already has this modifier.
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
if(ispath(modifier_type, M.type))
|
||||
if(istype(modifier_type, M))
|
||||
switch(M.stacks)
|
||||
if(MODIFIER_STACK_FORBID)
|
||||
return // Stop here.
|
||||
@@ -89,6 +105,8 @@
|
||||
if(mod.on_created_text)
|
||||
to_chat(src, mod.on_created_text)
|
||||
modifiers.Add(mod)
|
||||
if(mod.mob_overlay_state)
|
||||
update_modifier_visuals()
|
||||
|
||||
// Removes a specific instance of modifier
|
||||
/mob/living/proc/remove_specific_modifier(var/datum/modifier/M, var/silent = FALSE)
|
||||
@@ -97,10 +115,17 @@
|
||||
// Removes all modifiers of a type
|
||||
/mob/living/proc/remove_modifiers_of_type(var/modifier_type, var/silent = FALSE)
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
if(ispath(modifier_type, M.type))
|
||||
if(istype(M, modifier_type))
|
||||
M.expire(silent)
|
||||
|
||||
// Removes all modifiers, useful if the mob's being deleted
|
||||
/mob/living/proc/remove_all_modifiers(var/silent = FALSE)
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
M.expire(silent)
|
||||
M.expire(silent)
|
||||
|
||||
// Checks if the mob has a modifier type.
|
||||
/mob/living/proc/has_modifier_of_type(var/modifier_type)
|
||||
for(var/datum/modifier/M in modifiers)
|
||||
if(istype(M, modifier_type))
|
||||
return TRUE
|
||||
return FALSE
|
||||
Reference in New Issue
Block a user