Array action to Textbox [SOLVED!]

Get help using Construct 2

Post » Mon May 09, 2016 11:46 pm

Hi all,

I've been trying to solve an little stumbling block i've had with my combat log and i'm hoping someone can provide some advice on how to overcome this.

To give you an idea of what i'm trying to achieve, here's some wonderfully pre-alpha shots and the events.

Firstly upon loading, the textbox asks you to hit Spawn to spawn a random mob. Once you click this it then tells you what mob you've spawned:

Image

For this particular part you then press basicAttack(testAttack). This takes the mob health i've pushed from a static mob array to a temporary mob array tempMob.At(0), and then I subtract a random number from your characters min and max attack stat array "- round(random(aCharH.At(4),aCharH.At(5)))"

Image

This is fine and dandy and does what it's supposed to. However I would like it display the value of - round(random(aCharH.At(4),aCharH.At(5))) and not the health remaining at tempMob.At(0). So instead of "mob is at x health":

Image

I'd like it to say "You attack mob for x damage" or something similar. My main objective here is to get that X damage done. I've played around with a global variable to try and get the x damage done so I can easily display it, then have it subtracted from the mobs health, but I don't seem to be able to get the math nailed down.

Has anyone done something similar before? If so how did you overcome it? I feel like it's staring at me in the face and i'm too blind to see it!

Thanks for looking :)
Last edited by Grymligast on Tue May 10, 2016 9:59 pm, edited 1 time in total.
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Tue May 10, 2016 12:21 am

How about:

Make a holding variable to store player attack damage for the round, let's call it roundAttack.
On click "test attack": set roundAttack to round(random(aCharH.At(4),aCharH.At(5))), set array value to itself minus roundAttack, call function (paramater is: "You attack mob for " & roundAttack & " damage!" & newline & "Mob health is now " & tempMob.At(0) )

Function call works the same as it did before.

That's off the top of my head so might not work :p
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 204
Reputation: 3,466

Post » Tue May 10, 2016 7:51 am

Hi Mike,

Thanks for that, I think might just work! I was running on empty last night and couldn't wrap my head around it!

I'll let you know how I get on tonight.

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

Post » Tue May 10, 2016 9:07 am

I think mikehive is correct, and as mentioned "holding variable" should likely be a local variable.
Event 23, create a blank subevent that will contain the action setting the variable's value, modifying the array and displaying the value, so this way your local variable can sit between the top event 23 and the newly created blank sub-event.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Tue May 10, 2016 2:59 pm

Kyatric wrote:I think mikehive is correct, and as mentioned "holding variable" should likely be a local variable.
Event 23, create a blank subevent that will contain the action setting the variable's value, modifying the array and displaying the value, so this way your local variable can sit between the top event 23 and the newly created blank sub-event.


Cheers Kyatric, makes so much more sense when it's not 1am and struggling to keep an eye open!
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Tue May 10, 2016 9:59 pm

Image

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

Post » Wed May 11, 2016 12:20 am

Our pleasure ;)
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 204
Reputation: 3,466


Return to How do I....?

Who is online

Users browsing this forum: NN81 and 24 guests