Turn based combat structure

For questions about using Classic.

Post » Sun Sep 04, 2011 6:00 am

Hi!

I've been able to figure out a prototype method for a simple turn based RPG combat system that works in one versus one. But I'm having a hell of a hard time figuring out how I would manage battles with one versus multiple enemies, any enemy type in any order, following turns, etc...

Like there are a couple orders I'd like to give, how in construct would you say things like:

"select the enemy at this position, whatever type of enemy it is, and attack him/make him attack, use these values to figure out the result"

"take the speed value of all player and non player character in play and apply this formula to then write a list of order of attacks"

"the enemy at this spot is this particular type of enemy which has these statistic parameters"

Not expecting a complete logic course 101 but just wondering if you guys could give me a trail or a hint or two that could unblock me. Just a general method idea on how to structure all this and where should I focus my attention. I've been on this one for the past week, so any help is really appreciated!



http://dl.dropbox.com/u/38319441/RPGtest1.exe

Need the INI:

http://dl.dropbox.com/u/38319441/StringTable.ini

Bless you!

edit: more clarityGropwel2011-09-04 08:23:11
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Sun Sep 04, 2011 6:27 am

[QUOTE=Gropwel] Hi!

I've been able to figure out a prototype method for a simple turn based RPG combat system that works in one versus one. But I'm having a hell of a hard time figuring out how I would manage battles with one versus multiple enemies, any enemy type in any order, following turns, etc...

Like there are a couple orders I'd like to give, how in construct would you say things like:

"select the enemy at this position and attack him, use these values to figure out the result"

"take the speed value of all player and non player character in play and apply this formula to then write a list of order of attacks"

"the enemy at this spot is this particular type of enemy which has these statistic parameters"

Not expecting a complete logic course 101 but just wondering if you guys could give me a trail or a hint or two that could unblock me. Just a general method idea on how to structure all this and where should I focus my attention. I've been on this one for the past week, so any help is really appreciated!



http://dl.dropbox.com/u/38319441/RPGtest1.exe

Need the INI:

http://dl.dropbox.com/u/38319441/StringTable.ini

Bless you!

edit: more clarity[/QUOTE]


I think what you need is picking.
Sprite condition : section Pick

Pick random returns a random instance of the object type.
Pick closest test the distance between sprites and returns the closest
Pick farthest same but returns the farther from the given position
Pick by comparison allow you to apply the formula of your chosing returning the instance that corresponds best.

Check also in section "Private variable" Pick object with highest variable & lowest variable.
Allow you to test directly which instance of your object type has the higher/lower value.

The characteristics of your monsters should be stocked in private variables, easying picking.

Then once you picked one instance, use sub events. Any reference to the object type will apply actions/conditions to the instance picked.

Ex:
Pick random SpriteMonster
+ SpriteMonster.health > 0
=> Add 1 to SpriteMonster.x

(For example. Only the picked SpriteMonster health PV will be tested. And only this instance will be moved if the condition is true.)

Now for groups, or testing each monsters :
System: For each object / for each object (ordered).
Such a loop will go through every instances of the object type. You can then test conditions and apply actions. For each iteration of the loop, only the current instance (picked by the loop) will be influenced.
Then again, you nest your tests/conditions in sub events of the "for each" loop.Kyatric2011-09-04 06:28:39
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun Sep 04, 2011 7:14 am

hmm yes, yes, yes... applying the condition directly on the object. I could point to the enemy family so it'd pick any enemy class object that is selected. I was thinking too abstract.

Then I could check all players, give the action function to the fastest one, switch his turn off, start the loop again, etc...

Now to see if I can make it happen! Thanks a lot Kyatric, once again. :)

B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Sep 05, 2011 6:20 am

no, definitly I won't escape it, I gotta become a master of the lists and array and selection cycle and functions... could barely get the list object to work...

Damn it's hard, is it common around here to pay a fellow comrad to build an event sheet for a buyer?
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Tue Sep 06, 2011 4:54 am

Families are useful in this situation. Use three families "enemy", "friendly" and a third family like "Blue" that includes both the "enemy" and "friendly" families.

If you pick a single "Blue" instance you can find if the instance is in "enemy" or "friendly" with:
+ Enemy: Unique ID is Blue.UID
or
+ Friendly: Unique ID is Blue.UID

In the same way, you can find if the instance is a particular object type with:
+ Sprite: Unique ID is Blue.UID

For turns based on a character's speed, a way to do it is for each object to have a variable that increases with the character's speed stat. When the variable reaches a certain value the character is given a number to queue it, the first will get 1, the second 2 and so on. Then each character is picked by that number for the corresponding turn, and at the end of the turn they will start the process over.

Hope that makes some sense, I tend to be not very good with explanations sometimes.

Here is an example that shows some of these ideas:
http://dl.dropbox.com/u/5426011/examples6/turnBased.cap
Feel free to use it however you like.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests