PDA

View Full Version : [Fixed] addXP multiplier does not use Float


mydas
09-24-2005, 21:06
taken from superheromod.sma
public addXP()
{
new szid[4]
new szvictim[4]
new szmult[10]

read_argv(1,szid,3)
read_argv(2,szvictim,3)
read_argv(3,szmult,9)

new id = str_to_num(szid)
new victim = str_to_num(szvictim)
new mult = str_to_num(szmult)

//stupid check - but checking prevents crashes
if ( id <= 0 || id > 32 || victim <= 0 || victim > 32 ) return
localAddXP(id, mult * gXPGiven[ gPlayerLevel[victim] ] )
displayPowers(id, false)

we have "new mult = str_to_num(szmult)" ... so the multiplier is an integer. i think it should be a float ... i've come to be disabled for the second time in hero scripting because it isn't. what if i let's say i wanna make a hero get 1.5 xp for kills ? is that doable as superheroes is now ?

jtp10181
09-24-2005, 22:42
New function

public addXP()
{
new szid[4]
new szvictim[4]
new szmult[10]

read_argv(1,szid,3)
read_argv(2,szvictim,3)
read_argv(3,szmult,9)

new id = str_to_num(szid)
new victim = str_to_num(szvictim)
new Float:mult = floatstr(szmult)

//stupid check - but checking prevents crashes
if ( id <= 0 || id > 32 || victim <= 0 || victim > 32 ) return
localAddXP(id, floatround(mult * gXPGiven[ gPlayerLevel[victim] ]) )
displayPowers(id, false)
}

This was an oversight. The original code was this way and I never thought to change it. I am not even aware of any hero that uses the multiplier. Be aware that if you code a hero to use a float here and someone uses it without this fix it will prob chop off the float. So 1.5 would become 1. I might merge this into CVS, but I am thinking of adding a little bonus feature for AMXX first.

-----

EDIT: This also requires a change to the include file, I just realized.

Replacement stock in include
stock shAddXP(id, victim, Float:multiplier )
{
// Use to add XP for a kill initiated by a hero other than standard kill..
server_cmd("sh_addxp %d %d ^"%f^"", id, victim, multiplier)
}

-----

More EDIT:

hmmm... I think doing this will cause a tag mismatch error from any hero using this function in its old state. Because it will be sending an int but the stock is expecting a Float. Guess I will test this out later but I am pretty sure I am correct. Although normally a hero would not even use this feature anymore since extraDamage does the XP stuff you. I am not sure if any updated heroes are even using this function. This may or may not make it into the CVS / next release.

mydas
09-24-2005, 23:59
like u'd said, u should rewrite it so it can be of real help. and don't forget about ways to find out one's experience, experience_to_next_level and adding a set amt of xp

jtp10181
10-04-2005, 18:02
commited to CVS. any hero previoiusly using this function will get a tag mismatch error when compiled. the last arg should be changed to a float, so 1 can be changed to 1.0