ID:1623584
 
(See the best response by FishMan123.)
erb
Slash()
set category = "Fighting"
usr.verbs+=/mob/person/verb/Slash
if
usr.verbs-=/mob/person/verb/Slash
flick("slash",usr)
if(!attacking)
usr<<"[usr]: Energy blast"
var/obj/T = new/obj/turd(usr.loc)
attacking = 1
spawn(10)
attacking = 0
walk(T,usr.dir)









This is my code to have my sword do an energy blast, and im trying to have it were you can only use said energy blast only if you have the sword equipped but I ran into trouble, how do i fix it?
Best response
mob/var/sword_isEquipped = FALSE

mob/verb
equip_sword()
usr.sword_isEquipped = TRUE

Slash()
if(!usr.sword_isEquipped)return //checks to see if the sword is equipped, if not, cancel the proceeding
// do your thing here

Please keep in mind that this is a VERY general code, and is only meant to guide you in the correct direction..

You should probably have your attack verb standardized to something like:

mob/var/Weapon_Equipped = null

mob/verb
Equip_Sword()
usr.Weapon_Equipped = "Sword"
Attack()
switch(usr.Weapon_Equipped)
if("Sword")
//do sword stuff here


Again, this is very generalized code that is only meant to guide you toward the correct path. You are advised to not copy and paste, as this can be much more efficient.