Page 2 of 2

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 1:52 pm
by Jabantiz
SpellHeal looks to be a copy and paste of SpellDamage, we don't have to do the math.random for either, we can just pass the min/max values, so we can pass a heal amount the same way we pass damage if you want to

Code: Select all

SpellHeal("Heal", math.random(minVal, maxVal))
Code to show SpellDamage takes the same params:

Code: Select all

int EQ2Emu_lua_SpellDamage(lua_State* state){
	if(!lua_interface)
		return 0;
	Spawn* target = lua_interface->GetSpawn(state);
	LuaSpell* luaspell = lua_interface->GetCurrentSpell(state);
	if(!luaspell)
		return 0;
	Spawn* caster = luaspell->caster;
	sint32 type = lua_interface->GetSInt32Value(state, 2);
	int32 min_damage = lua_interface->GetInt32Value(state, 3);
	int32 max_damage = lua_interface->GetInt32Value(state, 4);	

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 2:07 pm
by Jabantiz
Jabantiz wrote:I believe I have also run into the same issue with SpellDamage, a self buff with a proc, calling SpellDamage from the proc function appears to damage the caster, target of the spell, I hesitate to change the param order of this function as it has been used a lot already.
After looking into it some more there is to much stuff that will need to be bypassed for SpellDamage to work for proc damage, going to have to make a new lua function, probably ProcDamage, this will also solve the problem of proc's from items.

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 4:07 pm
by John Adams
Jabantiz wrote:Code to show SpellDamage takes the same params
Either I have no idea what you're talking about, or you're not taking the time to read what I am saying ;)

I'm not suggesting there be 1 parameter for function cast(). cast should still be (Target, Caster, Type, Min, Max).

When we call SpellDamage, it is done like SpellDamage(Target, Type, Amount), and that is 1 value of damage based on a math.random() we did in LUA - not in C++. I do not want to random between 2 values in C++ (for this specific type of min/max) unless you're telling me there is no other way to do it.

If SpellHeal is a copy/paste of SpellDamage, then this is how SpellHeal should already work. If this is how SpellHeal works, cool - then back to my original question of why it's SpellHeal("Heal", HealAmt, HealAmt) when that is NOT how SpellDamage() is called.

It should be SpellHeal(Target, "Heal", Amount) -- period. Where Amount = math.random(Min, Max), or just like the SpellDamage example:

Code: Select all

SpellHeal(Target, HealType, math.random(MinHeal, MaxHeal))
Are we having 2 different conversations? Cuz that never happens :oops:

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 4:27 pm
by Jabantiz
SpellDamage takes 2 damage params, a min and a max, the max being an optional param, I posted the code of SpellDamage to show SpellHeal is the same, I have not made changes to SpellDamage, as far as I know it has always been like that. I understand how we call SpellDamage(), calling SpellHeal() the same way will work. There is the option to pass min max to the server core and it will do the random for you.

As for 1 parameter I meant this particular spell only has heal amount, not min Heal max Heal

Didn't mean to cause confusion, just to clarify
SpellDamage - nothing was changed
SpellHeal - works the same as SpellDamage

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 4:58 pm
by John Adams
Well, as you know it takes very little to confuse me ;) Thanks for the clarification.

So, after all is said and done, you're saying that SpellDamage(Target, Type, Amount) will do exactly "Amount", and is the way I've always known to trigger spell damage.

BUT! Optionally, we could do SpellDamage(Target, Type, SpellDataMin, SpellDataMax) WITHOUT doing math.random(SpellDataMin, SpellDataMax), and it is the exact same thing?

If so, then okay. Why didn't you just say so? :mrgreen: :mrgreen: :mrgreen:

Re: SpellHeal LUA

Posted: Fri Dec 06, 2013 5:02 pm
by Jabantiz
John Adams wrote:So, after all is said and done, you're saying that SpellDamage(Target, Type, Amount) will do exactly "Amount", and is the way I've always known to trigger spell damage.

BUT! Optionally, we could do SpellDamage(Target, Type, SpellDataMin, SpellDataMax) WITHOUT doing math.random(SpellDataMin, SpellDataMax), and it is the exact same thing?
correct

Re: SpellHeal LUA

Posted: Sat Dec 07, 2013 5:56 am
by thefoof
Just committed some more code for this and SpellDamage(), two new params.


First new param is crit_mod, set this as 1 to force a crit, 2 to disable crits, leave it 0 to roll crit chance as normal.

Second new param is no_calcs, if set to 1 this will bypass damage/heal amount calcs in the server. (You still will get just the basic damage roll if supplying both low and top end heal amounts.)



Will update the wikis later today.

Re: SpellHeal LUA

Posted: Sun Jul 13, 2014 9:08 am
by Dello0000
Zcoretri wrote:I don't think there is server support for spells that are set to 'Enemy' or 'Any' and have a beneficial spell land on the caster.
We need that for the SK skills, and necro :) i was thinking about an effectscaster = 1 or 0 for yes and no that we could throw into the script.

Also, Unholy Hunger II - VIII are % based heals where as Unholy Hunger I isn't, no idea how to go about that, maybe two scripts, UnholyHunger.lua and UnholyHungerpercent.lua
ALSO the monk spell (mend) still doesn't work with the new % / ifspellname code in them, may need Mend.lua and Mendpercent.lua
ALSOOOOOOO the Bruiser spell (Ignore Pain) wont work with the new % / ifspellname code in them, may need Ignore Pain.lua and IgnorePainpercent.lua

Re: SpellHeal LUA

Posted: Sun Jul 13, 2014 12:56 pm
by Jabantiz
wiki wrote:Syntax

SpellHeal([String] HealType, [int] MinHeal, [int] MaxHeal, [Spawn*] target, ([int] crit_mod), ([int] no_calcs))
So For a simple heal spell it would be

Code: Select all

function cast(Caster, Target, Min, Max)
    SpellHeal("Heal", Min, Max)
end
For a life tap type spell that damages the target and heals the caster it would be

Code: Select all

function cast(Caster, Target, Type, Min, Max, MinHeal, MaxHeal)
    SpellDamage(Target, Type, Min, Max) -- Damage the target
    SpellHeal("Heal", MinHeal, MaxHeal, Caster) -- heals the caster
end

Re: SpellHeal LUA

Posted: Mon Jul 14, 2014 1:59 am
by Dello0000
Ill give the leach code a try just now :)

[EDIT] Added the (Caster) perimeter to the script, still no joy tho. Here's the script.

Also, my routers fucked, keeps dc'ing me all the time for no bloody reason! Bought another one but waiting on it being delivered, it seems to be working atm but i think its only a matter of hours before its totally dead, (so if im gone for a week don't be surprised.)

If you have a look at the script and see something obvious tell me what you changed with the normal code and the altered code in your post so i can get a better understanding for when i get stuck into the other damage/heal spells :)

[EDIT, Again] Ok fixed it /reload spells and its healing the target again as appose to the caster :S, But, and i think this is true for ALLLLL over time spells, It wont cast the final "tick" before it ends the spell, SO as an example, lets say you have a 3 second spell that ticks every 1 second meaning a total of 3 ticks, but it will either not do the first tick or it will miss the last tick, so a DoT will trigger on use, trigger one second later and then the spell will end before the third tick happens, is it server side? Could we make it so a 1 second tick would really just be a .99 second tick? Just so its got time to get that last one in before the spell cancels.

Now i know i could just add an extra second to the total duration meaning it will be a 4 second DoT but till only do 3 ticks (wont change the tooltip) but if its not much work to change the time code somewhere that might be better, changing each spell and each tier and each following spell will take a lot of time.

What are your thoughts?

Re: SpellHeal LUA

Posted: Mon Jul 14, 2014 1:05 pm
by Jabantiz
In your code you have this

Code: Select all

SpellHeal(Caster, "Heal", MinHeal)
Change it to

Code: Select all

SpellHeal("Heal", MinHeal, 0, Caster)
and it should work.

Re: SpellHeal LUA

Posted: Tue Jul 15, 2014 10:04 am
by Dello0000
What does the 0 stand for? is that crit chance or something?

Yeah, works like a charm, ill get the data in for the higher tiers and start on the first scripts for the other classes then hammer on with the rest of the SK :) thank you!

Re: SpellHeal LUA

Posted: Tue Jul 15, 2014 1:12 pm
by Jabantiz
0 is the max damage, as this spell has a set heal amount we just put that amount in the min heal amount and set max heal amount to 0 so we can add the target of the heal after it, in this case the caster

Re: SpellHeal LUA

Posted: Tue Jul 15, 2014 1:40 pm
by Dello0000
Jabantiz wrote:0 is the max damage, as this spell has a set heal amount we just put that amount in the min heal amount and set max heal amount to 0 so we can add the target of the heal after it, in this case the caster
I see! so it didn't know what the max damage was so it wasn't getting to the target parameter then. Gotchya!