Help - Percentage.

Discussions on development of both the EQ2Emulator LUA Script Engine and Script specifications

Moderator: Team Members

Post Reply
Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 6:11 am

Hey
Looking at the script for Mend I and Mend III i see they use the same script. Will we need another script made up for percent based values?
As it stands now the tier 1 and 2 Mend spells heal for more than the tier 3 because the percent numbers come out as 9.5 health instead of 9.5% of total hp.

If i can get an idea of the code i should be able to fix a few other percent based ability's.
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Help - Percentage.

Post by Zcoretri » Fri Jun 13, 2014 7:55 am

Dello0000 wrote:Hey
Looking at the script for Mend I and Mend III i see they use the same script. Will we need another script made up for percent based values?
As it stands now the tier 1 and 2 Mend spells heal for more than the tier 3 because the percent numbers come out as 9.5 health instead of 9.5% of total hp.

If i can get an idea of the code i should be able to fix a few other percent based ability's.
Its just a matter of getting the Max Health of the target and multiplying it with the percent value.
Maybe something like this?

Code: Select all

CurrentHP = GetMaxHP(Target)
MinHeal = CurrentHP * (MinVal / 100)
MaxHeal = CurrentHP * (MaxVal / 100)
SpellHeal("Heal", MinHeal, MaxHeal)

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 9:45 am

Zcoretri wrote:Maybe something like this?

Code: Select all

CurrentHP = GetMaxHP(Target)
MinHeal = CurrentHP * (MinVal / 100)
MaxHeal = CurrentHP * (MaxVal / 100)
SpellHeal("Heal", MinHeal, MaxHeal)
Ill give that a try once the servers working again thanks.
And im guessing it would apply to to other things? Just need to change the functions.

Anyway thanks for that if i can get it working :D
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 2:17 pm

How do you make a new blank .lua? I need one called MendPercent.lua (Having one lua for the skill wont apply because after the first two they move to a different function.)

Can someone do that for me or tell me how to do it myself? thanks.
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Help - Percentage.

Post by thefoof » Fri Jun 13, 2014 2:22 pm

Dello0000 wrote:Having one lua for the skill wont apply because after the first two they move to a different function.
Can you explain what you're trying to do here? I can probably help just want to know why you need it first.

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 4:31 pm

thefoof wrote:
Dello0000 wrote:Having one lua for the skill wont apply because after the first two they move to a different function.
Can you explain what you're trying to do here? I can probably help just want to know why you need it first.
The monk heal ability is a simple X - X heal for the first two tiers. At Mend III however it changes into a percent based heal so the "one script for all tiers" method wont work in this case causing us to use two lua's

Unless we can marry the x to x heal with a percent heal but im sure that wouldn't work.
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Help - Percentage.

Post by thefoof » Fri Jun 13, 2014 4:42 pm

Dello0000 wrote:
thefoof wrote:
Dello0000 wrote:Having one lua for the skill wont apply because after the first two they move to a different function.
Can you explain what you're trying to do here? I can probably help just want to know why you need it first.
The monk heal ability is a simple X - X heal for the first two tiers. At Mend III however it changes into a percent based heal so the "one script for all tiers" method wont work in this case causing us to use two lua's

Unless we can marry the x to x heal with a percent heal but im sure that wouldn't work.
How about I just add a function so you can get the spell name and check it? :)

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Help - Percentage.

Post by thefoof » Fri Jun 13, 2014 5:08 pm

Code: Select all

function cast(Caster, Target, MinVal, MaxVal, CureLvls)
	local spell_name = GetSpellName()
	if spell_name ~= "Mend" and spell_name ~= "Mend II" then
		local max_hp = GetMaxHP(Target)
		MinVal = (max_hp * (MinVal / 100))
		MaxVal = (max_hp * (MaxVal / 100))
	end
    -- Heals target for 21 - 25
    --     This effect cannot be critically applied.
    -- The healing of this spell cannot be modified except by direct means
    SpellHeal("Heal", MinVal, MaxVal, 0, 2, 1)

    -- Dispels 7 levels of noxious hostile effects on target
    CureByType(CureLvls, 3);
end
This function isn't committed yet but will be tonight. I went ahead and put this script up, just posting here so you can see what I mean =p

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 5:09 pm

I don't think im following lol. In fact i know im not!
Adding an empty MendPercent.lua file for me to edit would be good. Let me explain abit more.

Mend I and Mend II are heals which (like a direct damage) have a minimum and maximum value to draw its ingame number from. However Mend III (If you look at the description) is also a minimum and maximum type heal but it is based on the casters total hp value, meaning the script that works for Mend I and Mend II will not work for Mend III because altho 50hp is less than 10% of 1000 the script treats the 9.0 - 10.0 as it would the "50"

So basically we need a new script to continue the Mend spell line.

I hope that clears it up lol :p

[EDIT]

Code: Select all

 local spell_name = GetSpellName()
   if spell_name ~= "Mend" and spell_name ~= "Mend II" then
Hmm, That could work, maybe. So have the usual script at the bottom and add that up the top and after "then" have your alternate heal spell.
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Help - Percentage.

Post by thefoof » Fri Jun 13, 2014 5:14 pm

Just to explain my script, if the spell that was cast not named either "Mend" or "Mend II", then the MinVal and MaxVal variables get changed into the correct values based on percentage. If not then the values are exactly as passed to the script.

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Fri Jun 13, 2014 5:20 pm

Yeah that kind of makes sense lol. Its probably a good idea that your doing it and not me tho :D

Wont you need the code in there to make it randomize the min / max values tho?
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Help - Percentage.

Post by thefoof » Fri Jun 13, 2014 5:22 pm

Dello0000 wrote:Yeah that kind of makes sense lol. Its probably a good idea that your doing it and not me tho :D

Wont you need the code in there to make it randomize the min / max values tho?
The server takes care of that, you have the option of leaving the max val as 0 which was just left in to keep backwards compatibility with old scripts. But if you give it the min and max values then the server will do the roll for you.

Dello0000
Posts: 175
Joined: Fri May 30, 2014 9:18 am
EQ2Emu Server: MHM Laneth
Characters: Dello - Dellos
Location: Scotland!
Contact:

Re: Help - Percentage.

Post by Dello0000 » Sat Jun 14, 2014 3:20 am

Oh ok, well that might be useful for later use lol.

So, for the spell its self, it occurs to that we would we need something like:
(heal) Min Max and cure, followed by your new call for spell name code and if its Mend III, IV or V follow that by the percent based heal and cure?

We will need both types of heal in the script for this to function under both conditions for both types of heals.
I cant see it killing the server but it may have an incorrect tooltip. Muhahaha :twisted:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests