View Full Version : Spell Costing Health

Lightning Blade
11-09-2013, 12:15 PM
I was bored and though of the class expire wanted to make, and i though of the health cost, and it found a way to do it.


I will admit this is not the best way to do it, but it's not the worst either :S.

UPDATE: i tried another way too.



11-09-2013, 01:05 PM
The second script wont work due to rather obvious reasons ;3
(IE; player not defined outside of the function)

Lightning Blade
11-09-2013, 01:14 PM
Well, it's not calling it outside the function. It's only calling it inside.

11-09-2013, 01:34 PM
I would guess this is how rochet2 ment it should be now they all can use player:

function HealthCostingSpell(event, player, spell, spellcheck)
local SpellID = 100 -- Spell ID
local damage = 1000
local caster = spell:GetCaster()
local spell = spell:GetEntry()
local health = player:GetHealth()
local healthCost = health - damage

if(spell == SpellID) then
player:DealDamage(player, healthCost)

- - - Updated - - -

Also i think the rules says that you should test the scripts first

Lightning Blade
11-09-2013, 01:51 PM
I am aware of what Rochet2 meant, but it makes no sense. Anyways they should work. ^^

11-09-2013, 01:52 PM
You are calling player outside the function whenever you try to localize a variable outside of the function by using a player method.

11-09-2013, 04:42 PM
I corrected your script, since the variables were kinda pointless since you don't have but only one place to use them. Also, if you look at the server hook on "PLAYER_EVENT_ON_SPELL_CAST", the spell variable is pushing the actual spell class, not the spellId. Also, you can't use the same variable names.

function HealthCostingSpell(event, player, spell, spellcheck)
if(spell:GetEntry() == 10000) then -- Change SpellId
player:DealDamage(player, player:GetHealth() - 1000) -- Possible fail if the player's health isn't over 1000 since we're using - 1000?

You should test your script before releasing;

Anyways they should work. ^^

Isn't the words of a tester. XD

Nonetheless, thanks for trying and sharing.

Lightning Blade
11-10-2013, 05:05 PM

- - - Updated - - -

i find it funny i release something, Tommy optimize the code and get " thanked " -.-

11-10-2013, 05:25 PM
Well your code didn't work whatsoever, so it would be irrelevant if someone gave you thanks for bad code. No need to be mad, you have to learn to test everything before releasing.

11-10-2013, 05:25 PM
Your code didn't work, nor should you post untested code as a release :P

Lightning Blade
11-10-2013, 05:34 PM
I'm not mad at all, and my first script should work. Indeed i have to learn. But nothing is worse than releasing something trying to learn and then, someone who is top expert whos making the lua engine gets the credits. But whatever, thanks for fixing the code.

11-10-2013, 05:37 PM
If you had tested your code before releasing, it wouldn't have been an issue :P