RPG Parties

For questions about using Classic.

Post » Wed May 13, 2009 8:30 am

I'm really curious how Construct would handle parties.

For example.

variables: name, hp, maxhp, sp, maxsp, xp, slot; // note I'm just using programming for examples, not construct or actual python coding.

Now, when a game starts you see a few splash screens, then your title, you go through an introduction blah blah blah, etc. By the time it's all over, you should have 1 player to walk around with.

I'm just wondering how you would setup a database for players and able to remove them, then add them at any point in your game, with constructs default coding.
B
2
G
4
Posts: 30
Reputation: 1,110

Post » Wed May 13, 2009 8:55 am

you could always stuff the data on arrays
as for character sprites, you could either have one object per party member slot and load animations on runtime (can one add frames on runtime? set frames other than the first? never tried) or you could have a different object per character and spawn them accordingly.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed May 13, 2009 3:03 pm

Yeah, keep the info for the characters in the array, then use the array to also remember who's currently in the party. Like:

Character 1's hp
Character 1's mp
Party member slot 1: character 1

Then when starting a battle or such, if the value in party member slot 1 is character 1, create a character 1.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed May 13, 2009 8:43 pm

I didn't know arrays were possible to use without python scripting? What behavior/button is it?

In Game Maker I did it like this.

[code:otpwuf2s]
globalvar actor, name, lv, hp, maxhp, sp, maxsp, str, pow, def, spd, xp;
globalvar char1;

actor[char1,name] = "Character 1s Name";
[/code:otpwuf2s]

I always was never able to create a party add/remove system, but in python it could be like this.

[code:otpwuf2s]
class Party:
pass

Duran = Party() # Create a Party Member also can be done by arrays
Duran.name = "Duran";
Duran.hp = 75;
# More stat stuff here
Duran.slot = ''; // slots are only added when a party member is called.

define add_actor(actor)
i = actor.length # Don't know if python has a length thingy like javascript
if actor !=3
actor[i] = new object();
actor[i].Name = Actor[actor].name;
Actor[actor].slot +=actor.length;
[/code:otpwuf2s]
B
2
G
4
Posts: 30
Reputation: 1,110

Post » Wed May 13, 2009 8:50 pm

It's in the list of objects when you insert an object.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed May 13, 2009 8:59 pm

Coolies.

so I did it like this.

var Durran // player

array[Durran,name] = "Duran";
array[Durran,slot]' = ''; // only when added.

how would the adding/removing of the player work?

"I'm use to programming, kinda wish python was ready"
B
2
G
4
Posts: 30
Reputation: 1,110

Post » Wed May 13, 2009 9:11 pm

I have no understanding of python - here's how to do it via events.

Set the values at array's x, y to the character's stats. Like the stuff in column x1 is for character 1, column x2 is character 2, etc.

So set value at x:1 y:1 Charater 1's hp
Set value at x:1 y:2 Character 1's mp

Somewhere else, have a few slots on the array available to tell who's currently in the party.

Upon adding a character to the party, set the slot in the array to their name.

Set value at x, y to: "Character 1"

At the start of battle:

At start of layout
Array: value at x, y is equal to "Character 1"
- create Character 1

Removing a character:

Set value at x, y to: "None"

Important! There's currently a bug in the array that retrieving values from either x1 or y1 doesn't work correctly, I can't remember which. Start at x2/y2 and it should work. You also might need to increase the side of the array, done in its properties.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri May 15, 2009 5:55 am

[quote="MysticTrunks":2bllfdp8]"I'm use to programming, kinda wish python was ready"[/quote:2bllfdp8]
Me too :P
But then again using events has been really fast and easy. It's just event-oriented code. Kinda like javascript/actionscript, only loops are special events here (that still throws me off)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests