random Array stat pull for subtract from global variable

Get help using Construct 2

Post » Sat Apr 30, 2016 12:33 am

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.

Image

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!
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Sat Apr 30, 2016 12:35 am

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

Image
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Sat Apr 30, 2016 6:12 am

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
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sat Apr 30, 2016 9:35 pm

Gearworkdragon wrote: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.
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Sat Apr 30, 2016 11:36 pm

Oh cool is it similar to the effect in the medic of Team fortress 2 ?
B
51
S
24
G
6
Posts: 391
Reputation: 7,820


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 2 guests