Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,549 guests, and 14 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to arrange Variables in an order ~ #220509
08/07/08 13:20
08/07/08 13:20
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Well I've got the following problem.

I need to know how I can bring variables into a certain order.
I've got 9 variables with values. now I want to draw the biggest one of them and put them into another variable.

Example:

//These are the variables that i need to be filled with values.
var ctb_place1 = 0;
var ctb_place2 = 0;
var ctb_place3 = 0;
var ctb_place4 = 0;
var ctb_place5 = 0;
var ctb_place6 = 0;
var ctb_place7 = 0;
var ctb_place8 = 0;
var ctb_place9 = 0;

// And these r the Variables which i need to bring up in order.

h1_agi = 15;
h2_agi = 17;
h3_agi = 13;
h4_agi = 12;
e1_agi = 10;
e2_agi = 10;
e3_agi = 10;


First I want to find out the biggest value of these and put them in to the "ctb_place1" variable.
after this I need to know which one was filled in so that this won't be took again.
after this I want to put in the next biggest variable into ctb_place2. BUT If ! the first variable was a hx_agi then next a ex_agi value should be taken. and so on,until all variables are filled.

Is there an easy way to do such a thing?

greets Roxas

Re: How to arrange Variables in an order ~ [Re: Roxas] #220512
08/07/08 13:36
08/07/08 13:36
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hello,

first, read your values into an array. Then you can just perform a sorting algorithm on it, quicksort (german) for example.

Re: How to arrange Variables in an order ~ [Re: Fenriswolf] #220569
08/07/08 14:06
08/07/08 14:06
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
German:
hmm naja ich will sie ja nicht auf- oder absteigend sortieren.
Um genau zu sein versuche ich eine Art Conditional Turn Based Battle System zu erstellen wie in Final Fantasy X.
Dazu brauch ich erstmal eine Kampfreihenfolge die ich in abhängigkeit der Agilitäts Werte der Charaktere erstellen wollte,
aber da die Heldentruppe mehr agi hat als die Gegner truppe, wollte ich es so haben, dass als erstes das Maximum aller Agilitätswerte
an erster Stelle kommt. und dann soll anhand der ersten stelle nachgesehen werden, ob es der Agi-wert von einem Held, oder der Agi-wert von
einem gegner war. Je nachdem soll dann abwechselnd ein enemy, ein held, ein enemy, ein held, in die reihenfolge reingebracht werden, aber nach
agilitätswerten. in meinem beispiel sollte das dann so aussehen:

h1_agi = 15;
h2_agi = 17;
h3_agi = 13;
h4_agi = 12;
e1_agi = 10;
e2_agi = 10;
e3_agi = 10;


ctb_place1 = h2_agi;
ctb_place2 = e1_agi;
ctb_place3 = h1_agi;
ctb_place4 = e2_agi;
ctb_place5 = h3_agi;
ctb_place6 = e3_agi;
ctb_place7 = h4_agi;
ctb_place8 = e1_agi; //hier soll er wieder von vorne beginnen mit den Gegnern
ctb_place9 = x; //der letzte der eine aktion ausgeführt hat kommt in den 9. platz

so hab ich mir das vorgestellt..

Wenn einer schon mal sowas in der Art programmiert hat, oder ne idee hat wie man das hinkriegt wär ich dankbar für antwort.
oder wenn mir jemand sagt wie ein CTB sonst funktioniert.. ich hab da nicht wirklich so den genauen plan.

Danke im vorraus

greets Roxas


English:
hmm well, I don't want to sort them up. I try to make an Conditional turn based battle system like in
Final Fantasy X. I need a battle order first. this order should be controlled by the Agility values of the charakters.
But the hero party got higher agility values than the enemy troupe, so I wanted to get the maximum of all agility values first and put it
in the first place of the battle order. after this I need to find out wether it was the agility value of a hero or an enemy.
if it was an enemy the next place should be filled by the next highest hero agility value etc. it should be in turns.
It should look kinda this:

h1_agi = 15;
h2_agi = 17;
h3_agi = 13;
h4_agi = 12;
e1_agi = 10;
e2_agi = 10;
e3_agi = 10;


ctb_place1 = h2_agi;
ctb_place2 = e1_agi;
ctb_place3 = h1_agi;
ctb_place4 = e2_agi;
ctb_place5 = h3_agi;
ctb_place6 = e3_agi;
ctb_place7 = h4_agi;
ctb_place8 = e1_agi; // hear he should repeat the action
ctb_place9 = x; // the last one who made an action should be placed in the 9th place.

that's the way i wanted it to be =/.

if someone did a CTB before, or got a great idea how to solve that problem i would be grateful for an answer.
or if someone knows how a ctb works.. because i don't know how it works at all.

thanks in advance

greets Roxas

Re: How to arrange Variables in an order ~ [Re: Roxas] #220625
08/07/08 20:43
08/07/08 20:43
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Ok, I see.
Well, I am not much into conditional turn based games, but here is an basic approach (pseudocode). : )
It uses lists and queues. Both data structures can be found in my signature.
You can also solve this problem with arrays, though.
Code:
/* we start with two lists in which each element stores a pointer to an entity */
new List ListOfHeros
new List ListOfEnemies

/* now we sort those lists descendingly according to the entities agility skills */
list_sort(ListOfHeros, agility)
list_sort(ListOfEnemies, agility)

/* this is our battle queue */
new Queue BattleQueue

/* heros and enemies will be pushed into the battle queue alternately */
while(list_not_empty(ListOfHeros) && list_not_empty(ListOfEnemies))
    Cut first element of ListOfHeros
    Push it into BattleQueue

    Cut first element of ListOfEnemies
    Push it into BattleQueue


if (list_not_empty(ListOfHeros))
    Push rest of ListOfHeros into BattleQueue

if (list_not_empty(ListOfEnemies))
    Push rest of ListOfEnemies into BattleQueue

/* We are done. Now we can pop out the entities one by one. */
entity = queue_pop(BattleQueue) // returns entity with highest agility

...

Hope this helps somehow.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1