Issue w/ Turn-Based RPG

Get help using Construct 2

Post » Tue Jan 14, 2014 8:06 pm

I am new to programming in general and, by definition, to Construct as well. I am attempting to use Construct to build a prototype of a turn-based, 2D RPG. Made some progress but am running into a wall that I hope this forum can help with.

The combat is essentially a row of static monsters faced off against a row of static player characters. Each character (player or enemy) takes a turn in 'rounds'. At the completion of each round, the process starts over (quite original, I know...).

I am using an array to store data for each PC and enemy. For example: arrayPC1. I am now attempting to figure out how to construct an attack function that can be reused everywhere (seems pretty important for an RPG). The problem I am having is that I can't predict which 'slot' a character will choose to attack. So PC1 might decide to attack Enemy1, 2, or 3 and the correct array would need to referenced in the function in any of those cases. Here is a visual example to try and help explain:



So, how do I tell the function which of these slots to pull data from when it is calculating an attack?

Thanks in advance for helping out a noob...
B
3
Posts: 2
Reputation: 204

Post » Tue Jan 14, 2014 8:52 pm

Sounds like you are making things more complicated than they need to be.

You would be better using instance variables to achieve this...

Someone may post an example capx using an array, but you would be better knowing what the events are doing rather than just bolting someone else's work into your project...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Wed Jan 15, 2014 6:38 am

Wouldn't using instanced variables still have the same issue? How will the function know which character to pull the data from?
B
3
Posts: 2
Reputation: 204

Post » Sat Dec 13, 2014 6:09 pm

I'm trying to discover how to do this too. If someone knows the answer, please, share with us!
B
7
S
2
G
1
Posts: 13
Reputation: 1,101

Post » Sat Dec 13, 2014 6:38 pm

Just like an rpg, you can't go attack a level 10 boss if you're at level 1.
As Pixel perfick said instance variables would be a start, but you need to understand picking first.
Keyword instance.
Also why do you need a function?
Image ImageImage
B
168
S
50
G
164
Posts: 8,232
Reputation: 105,583

Post » Sat Dec 13, 2014 8:39 pm

Thanks for the tip!

I searched about picking and turn-based mechanics and realized I was understanding UID wrong. I thought each object had its own UID "series", like enemy0, enemy1, enemy2 and protagonist0, protagonist1, protagonist2... :D

Now everything works properly!
B
7
S
2
G
1
Posts: 13
Reputation: 1,101



Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, RobertMKD, Syazanie Amirin and 12 guests