• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Making a custom stat system

Status
Not open for further replies.
Level 3
Joined
Jan 15, 2010
Messages
47
Hey all,

I am working on a custom stat system to use with some jass spells that I wrote. All it really has to be is a couple of real variables stored in a struct and I want to make a struct for each player.

I have the structure compiling successfully and its just a bunch of different real variables. How would I go about initializing a struct for each player? So far I have:

scope CSSInit intializer Init

globals
[Part A]
endglobals

private function Init takes nothign returns nothing
[Part B]
endfunction

endscope

My initial thought was to put it in globals at [Part A], but im not quite sure how. At [Part A] I wrote "heroData array hData", heroData being the name of the struct. then in [Part B] i wrote "set hData[0].meleeDamageModifier = 1.0" and it doesnt compile.

I guess what I am asking is whether I am making a simple syntax error, if I am making things more complicated than they need to be, or if someone knows a better solution :)

Thanks in advance!
-enyeas
 
Level 3
Joined
Jan 15, 2010
Messages
47
I want each players hero to have certain stats associated with them that I can implement into spells. Such as a real variable storing spell critical chance. I could have a trigger that increases that real by 15.5 and then make a spell that gets a random number between 0-10000 and check if the number is less than 150 (crit chance x 100). Then apply extra dmg if it is.

I guess, to answer your question, I could use integers instead of reals. It wouldnt make all that much difference.

And your first question, are you suggesting that i could just put it in the map header? I didn't think about that, I'll try that now :)

Edit:
Okay so I put

globals
heroData array hData
endglobals

in my map header and it compiles.

I can modify it and can show it to myself in game and it works perfectly :)

Thanks!
-enyeas
 
Last edited:
Level 7
Joined
Oct 14, 2008
Messages
340
I think I know the problem? you need to create the struct before you can set it's variables.

so try
JASS:
local heroData h = heroData.create()
set h.meleeDamageModifier = 1.0
set hData[0] = h
 
Level 3
Joined
Jan 15, 2010
Messages
47
Yeah, I wasn't sure where to create the struct array in order to use it globally. Makes sense now to use the map header :p
 
Level 3
Joined
Jan 15, 2010
Messages
47
well the "system" (if you could call it that) is just an array of variables that i would only be implementing in my jass spells. i have it working now, so if you need help figuring one out for yourself i would be glad to help
 
Status
Not open for further replies.
Top