Raised This Month: $51 Target: $400
 12% 

[Fixed] addXP multiplier does not use Float


  
 
 
Thread Tools Display Modes
Author Message
mydas
Senior Member
Join Date: Mar 2005
Old 09-24-2005 , 21:06   [Fixed] addXP multiplier does not use Float
#1

taken from superheromod.sma
Code:
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 ?
mydas is offline
Send a message via Yahoo to mydas
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 09-24-2005 , 22:42  
#2

New function

Code:
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
Code:
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.
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
mydas
Senior Member
Join Date: Mar 2005
Old 09-24-2005 , 23:59  
#3

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
__________________
[2021] I would love to revive SHMOD.

My heroes: SLAYER, Akasha, Achilles, Robo-Ky,Justice, Potemkin, Juggernaut, Mirage, Leviathan, Tyrael, Marduk, Omega Red
mydas is offline
Send a message via Yahoo to mydas
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 10-04-2005 , 18:02  
#4

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
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode