random Array stat pull for subtract from global variable

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Morning all,

    I'm doing some testing at the moment trying to get the combat working on me game. I believe what I'm trying to do is possible but I'm having a problem getting the syntax right.

    I have 2 arrays:

    1D "aCharH" for my character stats

    2D "TRmob" for my NPC stats

    I have a function that calls a random NPC from the TRmob array to the screen, and the NPC HP from that is shoved in to a global variable and shown on screen.

    I then have a button to "attack" the NPC. When I click this it SHOULD pull X=2 and X=3 from the aCharH array which is my minAtk and maxAtk values (2 and 4), which then subtracts this from the NPC HP global variable.

    However nothing happens. I took out the syntax and just put in "15" to make sure nothing else is wrong and it works fine, so I know my syntax is crap trying to pull the min/max values from aCharH. I know it must be possible, and by god i've looked around the Googleweb for an answer but I can't seem to see anything. Has anyone done something similar?

    Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • crap I worked it out! random(aCharH.at(2),aCharH.At(3)). when i saw it I thought, "of course". meh, it's 130am.

    will leave it up if anyone else has something similar.

    [Edit]

    Actually if someone does use something similar, it's best to use "round(random.." first, otherwise you get crazy decimal places and not whole numbers

  • something id like to add here you might want to change the hp to also have a current hp and a max hp if you plan on adding in healing. to least cap the health pool

  • something id like to add here you might want to change the hp to also have a current hp and a max hp if you plan on adding in healing. to least cap the health pool

    That's a really good idea, thanks for that. i'm just about to start adding in spells now as the base combat is now complete.

    Though thinking about it, I might have overhealing as a mechanic, with a timed decay back down to your max hp.

    Thanks again.

  • Oh cool is it similar to the effect in the medic of Team fortress 2 ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)