1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Making a custom stat system

Discussion in 'Triggers & Scripts' started by enyeas, Feb 23, 2010.

  1. enyeas

    enyeas

    Joined:
    Jan 15, 2010
    Messages:
    47
    Resources:
    0
    Resources:
    0
    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
     
  2. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,127
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    Why do you need it initialized for each player? It's not like a filter that needs to be shown at one player at a time.
    Why did you set your stats into real variables and not integer ones?
     
  3. enyeas

    enyeas

    Joined:
    Jan 15, 2010
    Messages:
    47
    Resources:
    0
    Resources:
    0
    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: Feb 23, 2010
  4. Maximilianx

    Maximilianx

    Joined:
    Oct 14, 2008
    Messages:
    334
    Resources:
    0
    Resources:
    0
    I think I know the problem? you need to create the struct before you can set it's variables.

    so try
    Code (vJASS):
    local heroData h = heroData.create()
    set h.meleeDamageModifier = 1.0
    set hData[0] = h
     
     
  5. enyeas

    enyeas

    Joined:
    Jan 15, 2010
    Messages:
    47
    Resources:
    0
    Resources:
    0
    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
     
  6. Maximilianx

    Maximilianx

    Joined:
    Oct 14, 2008
    Messages:
    334
    Resources:
    0
    Resources:
    0
    well if you use
    Code (vJASS):

    globals
    endglobals
     


    it really shouldn't matter where you put it.
     
  7. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    just put globals/endglobals under the struct/endstruct
     
  8. 88WaRCraFT3

    88WaRCraFT3

    Joined:
    Jun 9, 2009
    Messages:
    1,139
    Resources:
    1
    Spells:
    1
    Resources:
    1
    One question, You will put your system on hive to public?
     
  9. enyeas

    enyeas

    Joined:
    Jan 15, 2010
    Messages:
    47
    Resources:
    0
    Resources:
    0
    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