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

>20 lvls?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlueRaja
Senior Member
Join Date: Nov 2004
Old 07-29-2004 , 09:29   >20 lvls?
Reply With Quote #1

Okay, I've never scripted in SmallC before (and hence have no experience scripting for AMX or Superhero mod), but I do have a background in C++.
I wanted to get more than 20 levels, so I tried editing the superheromod.sma code:

Code:
SUPERHEROMOD.SMA
public readINI()
{
...
new XP[41][10]
new XPG[41][10]
...
if ( ( containi( data, "XPLEVELS" )==0 && !gLongTermXP) || ( containi( data, "LTXPLEVELS" )==0 && gLongTermXP ) )
    {
      parse(data, tag, 19, XP[0], 9, XP[1], 9, XP[2], 9, XP[3], 9, XP[4], 9, XP[5], 9, XP[6], 9, XP[7], 9, XP[8], 9, XP[9], 9, XP[10], 9, XP[11], 9, XP[12], 9, XP[13], 9, XP[14], 9, XP[15], 9, XP[16], 9, XP[17], 9, XP[18], 9, XP[19], 9, XP[20], 9, XP[21], 9, XP[22], 9, XP[23], 9, XP[24], 9, XP[25], 9, XP[26], 9, XP[27], 9, XP[28], 9, XP[29], 9, XP[30], 9, XP[31], 9, XP[32], 9, XP[33], 9, XP[34], 9, XP[35], 9, XP[36], 9, XP[37], 9, XP[38], 9, XP[39], 9, XP[40], 9)
    }
    
    if ( ( containi(data, "XPGIVEN")==0 && !gLongTermXP ) || ( containi(data, "LTXPGIVEN")==0 && gLongTermXP ) )
    {
      parse(data, tag, 19, XPG[0], 9, XPG[1], 9, XPG[2], 9, XPG[3], 9, XPG[4], 9, XPG[5], 9, XPG[6], 9, XPG[7], 9, XPG[8], 9, XPG[9], 9, XPG[10], 9, XPG[11], 9, XPG[12], 9, XPG[13], 9, XPG[14], 9, XPG[15], 9, XPG[16], 9, XPG[17], 9, XPG[18], 9, XPG[19], 9, XPG[20], 9, XPG[21], 9, XPG[22], 9, XPG[23], 9, XPG[24], 9, XPG[25], 9, XPG[26], 9, XPG[27], 9, XPG[28], 9, XPG[29], 9, XPG[30], 9, XPG[31], 9, XPG[32], 9, XPG[33], 9, XPG[34], 9, XPG[35], 9, XPG[36], 9, XPG[37], 9, XPG[38], 9, XPG[39], 9, XPG[40], 9)
     }
I assumed that the parse function read from a string until hitting a space character, at which point it stored word it just read into the variable given, up to a maximum of the proceeding number.

I also noticed (in that same function) two arrays named gXPLevel[] and gXPGiven. These are declared earlier in superheromod.sma to be the size of a constant #defined in superheromod.inc - I changed this constant to 40 as well.
Code:
#define SH_MAXLEVELS 40

Finally, I noticed the data written to vault.ini (in superherovault.inc) is stored in an array defined as size 20. I changed this to SH_MAXLEVELS (as I assumed it should be):
Code:
SUPERHEROVAULT.INC
public parseXP(id, xpinfo[] )
{
...
  new skills[SH_MAXLEVELS][21]
...
rc=parse(xpinfo, name, 31, epoch, 15, mm, 2, dd, 2, yy, 4, hh, 2, mi, 2, xp, 19, skills[0], 20, skills[1], 20, skills[2], 20, skills[3], 20, skills[4],20, skills[5], 20, skills[6], 20, skills[7], 20, skills[8], 20, skills[9], 20, skills[10], 20, skills[11], 20, skills[12], 20, skills[13], 20, skills[14], 20, skills[15], 20, skills[16], 20, skills[17], 20, skills[18], 20, skills[19], 20, skills[20], 20, skills[21], 20, skills[22], 20, skills[23], 20, skills[24], 20, skills[25], 20, skills[26], 20, skills[27], 20, skills[28], 20, skills[29], 20, skills[30], 20, skills[31], 20, skills[32], 20, skills[33], 20, skills[34], 20, skills[35], 20, skills[36], 20, skills[37], 20, skills[38], 20, skills[39], 20)
And that completes the list of everything I changed...

However, after recompiling everything, superheromod.amx has a "bad load".
Could any of you SH-AMX veterans help me out here?
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 07-29-2004 , 16:07  
Reply With Quote #2

uhhhh

*SMACK*

edit the superhero.ini

leave the SMA alone
__________________
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
BlueRaja
Senior Member
Join Date: Nov 2004
Old 07-29-2004 , 16:10  
Reply With Quote #3

That was the first thing I did...

But Superhero plugin has an inherent limitation on how many levels you can have (that limit happens to be 20), which is why I was editing the .sma to increate that limit...

Any..erm..real help?
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 07-29-2004 , 16:16  
Reply With Quote #4

cvar to change maxpowers...

sh_maxpowers

default is 20

again.... don't edit the sma, there is NO need to unless your fixing bugs or something....

Also... you will want to edit the superhero.inc file and change the define at the top to allow over 20 levels. Then resompile the original SMA
__________________
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
Chivas2973
Veteran Member
Join Date: Mar 2004
Location: Wisconsin
Old 07-29-2004 , 18:51  
Reply With Quote #5

the thing is, he wants greater than 20 levels and as far as we knew, 20 was max if you go over 20 it won't let you have or give it
atleast that has been my experience
__________________
Chivas2973 is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 07-29-2004 , 18:54  
Reply With Quote #6

yeah sorry about that..... now looking at the code I see this, I assumes it was coded better than this.

I am going to make it possible ot have more than 20 in the next amx rls.
__________________
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
Chivas2973
Veteran Member
Join Date: Mar 2004
Location: Wisconsin
Old 07-29-2004 , 20:10  
Reply With Quote #7

I think we should make a hero
Hero: jtp10181

AKA: Mentor II
Real Name: Unrevealed
Occupation: Member, Royal Elite, Imperial Guard
Identity: Publicly known in Shi'ar Empire
Legal Status: Citizen of Shi'ar Empire
Place of Birth: Unrevealed
Marital Status: Unrevealed
Known Relatives: None
Base of Operations: Shi'ar Throneworld
First Appearance: X-MEN #107

History: Unrevealed.

Height: 5 ft. 9 in.
Weight: 150 lbs.
Eye: Apparently no visible pupils or irises
Hair: Unrevealed
Skin: Green

Strength Level: Unrevealed, probably the same as that of an Earthman of the same physical age, height, and build who engages in moderate regular exercise.

Known Superhuman Powers: Unrevealed. It has been suggested that Mentor has superhuman level of intelligence.

In Game Powers:
-Conquers problems of all other heros


lol, Thanx for the effort
__________________
Chivas2973 is offline
BlueRaja
Senior Member
Join Date: Nov 2004
Old 07-29-2004 , 21:17  
Reply With Quote #8

ok, thanks for the effort..

I spent the first half of the day taking tutorials for AMX, and the second half sleeping upside-down on the living-room couch.
Now that I know a little more, I'm going to continue editing the code. If I figure anything out, I'll post it here.

The code could have been written a little more cleanly..I mean, I know (now) that arrays cannot be dynamically allocated is SmallC, but a simple comment (//TO ADD MORE THAN 20 HEROS...) would have sufficed.
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 07-29-2004 , 21:27  
Reply With Quote #9

screw a comment....

I have trashed using the "parse" and wrote my own little function to parse the data out of the superhero.ini

error checking and everything, it can handle multiple spaces and tabs.

I just about have the kinks worked out, I'll post the code for it in a short while so you can test it out for me in the real world.

------

OK First add this to your superhero.inc file

Code:
stock replace_all(string[],len,what[],with[]) {
	new withlen,charnum = 0
	withlen = strlen(with)
	while ( replace( string[charnum],len,what,with) != 0) {
		charnum += contain(string[charnum],with) + withlen
	}
}
then replace the readINI block in the superheromod.sma with the following block.

Code:
//----------------------------------------------------------------------------------------------
public readINI()
{
  if ( !file_exists(gSHFile ) ) createINIFile()

  new readLine = 0
  new data[512], tag[20], lengthRead
  new charNumXP, charNumXPG, charNumXPn, charNumXPGn, x
  new numLevels[4]
  new XP[512], XPG[512], tempXP[16]

  do {
    readLine = read_file(gSHFile,readLine,data,511,lengthRead)

    if ( equal(data[0],"##",2) ) continue

    if ( equali( data[0], "NUMLEVELS",9 ) )
      parse(data, tag, 19, numLevels, 3)

    else if ( ( equali( data[0],"XPLEVELS",8 ) && !gLongTermXP) || ( equali(data[0], "LTXPLEVELS",10 ) && gLongTermXP ) )
      copy(XP,512,data)

    else if ( ( equali( data[0],"XPGIVEN",7 ) && !gLongTermXP ) || ( equali( data[0],"LTXPGIVEN",9 ) && gLongTermXP ) )
      copy(XPG,512,data)

  } while ( readLine )

  gNumLevels = str_to_num(numLevels)

  //This prevents variables from getting overflown
  if (gNumLevels > SH_MAXLEVELS) {
  	server_print("[AMX] NUMLEVELS in superhero.ini is defined higher than SH_MAXLEVELS in the include file. Adjusting NUMLEVELS to %d", SH_MAXLEVELS)
  	gNumLevels = SH_MAXLEVELS
  }
  
  replace_all(XP,511,"^t"," ")
  replace_all(XPG,511,"^t"," ")

  charNumXP = contain(XP," ")
  charNumXPG = contain(XPG," ")

  for (x = 0; x <= gNumLevels; x++ ) {

	do {
		if (equal(XP[charNumXP + 1]," ",1)) charNumXP++
		if (equal(XPG[charNumXPG + 1]," ",1)) charNumXPG++
	} while (equal(XP[charNumXP + 1]," ",1) || equal(XPG[charNumXPG + 1]," ",1))

	if (charNumXPn == charNumXP ||	charNumXPGn == charNumXPG) {
		server_print("[AMX] Ran out of levels to load, check your superhero.ini for errors. Adjusting NUMLEVELS to %d", x - 1)
  		gNumLevels = x - 1
  		break
  	}

	charNumXPn = charNumXP
	charNumXPGn = charNumXPG
	charNumXP = contain(XP[charNumXPn + 1]," ")
	charNumXPG = contain(XPG[charNumXPGn + 1]," ")

	copyc(tempXP,15,XP[charNumXPn + 1],charNumXP)
	gXPLevel[x] = str_to_num(tempXP)

	copyc(tempXP,15,XPG[charNumXPGn + 1],charNumXPG)
	gXPGiven[x] = str_to_num(tempXP)
	
	charNumXP += charNumXPn
	charNumXPG += charNumXPGn

	if (x == 0 && gXPLevel[x] != 0) {
		server_print("[AMX] Level 0 must have an XP setting of 0, adjusting automatically")
		gXPLevel[x] = 0
	}
  }

  // Set the CVAR to let heros know how many levels there are...
  register_cvar("sh_numlevels", numLevels )
  set_cvar_string("sh_numlevels", numLevels)

}
you may get loose indent errors because the code blocks on the forums will prob mess up the indentations.

This is in my current WIP version, hopefully it can be slapped in the current public version without errors.
__________________
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
BlueRaja
Senior Member
Join Date: Nov 2004
Old 07-29-2004 , 22:43  
Reply With Quote #10

That did the trick; thanks
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
Reply



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 13:37.


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