mob/var
list/abilities
list/cooldowns
ability
parent_type = /obj
proc
cooldown_timer(mob/caster)
var cd = cooldown - round((cooldown * (caster.apply_sub_stat_boost(caster.haste) / 100)))
cd = cd * 10 + world.time
if(!caster.cooldowns) caster.cooldowns = list()
if(!(src in caster.cooldowns))
caster.cooldowns.Add(src)
on_cooldown(caster, cd)
on_cooldown(mob/caster, cooling_duration)
set waitfor = 0
var/obj/T = new/obj/effects/timer(src)
T.icon_state = "[round((world.time / cooling_duration) * 28)]"
caster << "icon_state1: [T:icon_state]"
while(cooling_duration > world.time)
T.icon_state = "[round((world.time / cooling_duration) * 28)]"
caster << "icon_state2: [T.icon_state]" // I used this line to figure out the icon_state based on the previous line.
sleep(world.tick_lag * 10)
if(cooling_duration < world.time)
caster.cooldowns.Remove(src)
del(T)
Problem description: I have been attacking this for quite awhile now but I can't seem to figure out the problem. I have a timer.dmi file and I want it's icon_state to change depending the ability's cooldown duration. I can't seem to get the timer.dmi to appear on top of the ability and the icon_states begin from 15-27 out of 1-28.
What it looks like you are doing is placing the timer object in src's (which is an ability) contents list, which doesn't seem like what you want to do at all. If the timer is intended to be an overlay of some sort, which I'm assuming it is, you'd have to use client.screen and place it where your ability GUI is, or use an image object. I think the latter is the better route, but either would suffice.