No cooldown if skill doesn't go through.
|
|
Alright so I have skills in my current project that have cooldowns so they cannot be continuously used repeatedly. The thing is that the cooldown system works fine. It's just that if you activate the skill but you don't have enough energy, you're doing something, etc., the cooldown will still activate even though the skill didn't activate due to whatever reason. So for example. A player uses a skill but doesn't have the energy cost to use the skill, the player won't be able to use the skill 'til the cooldown is over even though skill didn't go through. Here is the code for the activation of the skill:
proc/Activate(mob/User) if(User.Cooldown(src.name,src.Cooldown*10,src)) return 1 else if(usr.client) if(src.Cooldown>=10) src.overlays+=new/obj/Locked for(var/HK/H in usr.client.screen) if(H.skill==src) H.overlays+=new/obj/Locked if(src.name=="Skill1") User.Skill1(usr) return if(src.name=="Skill2") User.Skill2(usr) return
This code works perfectly fine for putting a limit to massing the Activate button but is there a way to make it so that if the skill doesn't fully activate because of not having a required stat or something, there won't be a cooldown? The last thing I'd want to resort to is setting a cooldown code into every skill.
|
Why are you breaking down every skill in a single proc? You continue this route you'll have 500+ lines of code in a single proc with nothing but a bunch of if/else for simple things. You should define a skill under an obj type and create a proc under the base "/obj/skil/proc/Skill_Use()" something like that and redefine it for each different skill type. Makes things A LOT easier down the road. IE: