• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help for a Conditional Turn-Based Battle system

Status
Not open for further replies.

Mog

Mog

Level 2
Joined
Feb 13, 2010
Messages
4
Hello everybody,
I'm now trying to make a RPG map using random battle & stuff right now, and the battle system seems to work fine (I mean, I can enter in battle, monsters generate, the turns skip correctly, and the battle ends when every unit from a team is dead then return to original location) but I can't think of a good formula for the turn skipping. I would like something that look like something like Final Fantasy X (CTB system) if possible.

Traditional time battle and active time battle aren't what I'm searching for even if they are easier to code

I could do a linear formula easily ; each time a unit does an action, it substract the speed cost of the ability to the speed of the playing unit, but the resulting effect would be that when there is a big difference of speed between 2 units, it would do that : P1, P1, P1, P1, P1, P1, P2, P1, P2, P1, P2, ... and it's not what I want either. If we take the example up ahead, I would prefer more something like P1, P1, P1, P2, P1, P1, P2, P1, P1, P1, P2, ...

If anybody could come with a way of doing this, I would be very happy :) Thanks
 
Level 4
Joined
Feb 22, 2012
Messages
74
I too have tried making some turn-based systems in a RTS engine and it is very difficult.

I am not sure what you are asking, sounds like you need help with an attack time system. I might tell you to reference the system in Tactics Ogre. I will try to describe it here.

Each unit on the field has a stat called "wait time" (WT). The WT of every character is WT = (550 - agility). Every battle starts with all units at their max WT. Before turn 1, all units lose enough WT so that the lowest-WT unit is at 0 WT. If the unit only moves, its WT is reset to 50% of max. If it only attacks, it is 75% of max, and if it does both, it gets 100% WT filled up. This process continues throughout the battle.

So a quick example:

Player 1
Knight (500 WT)
Archer (425 WT)


Player 2
Wizard (525 WT)
Griffin (300 WT)


At start of battle, before anything, it looks like:
Griffin (300/300)
Archer (425/425)
Knight (500/500)

Wizard (525/525)

Then, for turn 1:
Griffin (0/300)
Archer (125/425)
Knight (200/500)

Wizard (225/525)

The Griffin only moves, does not attack, so its WT goes up to 150/300
For turn 2:
Archer (0/425)
Griffin (25/300)
Knight (75/500)
Wizard (100/525)

The Archer moves and attacks, so goes back to 425/425
For turn 3:
Griffin (0/300)
Knight (50/500)
Wizard (75/525)
Archer (400/425)

So I think you could just set up a hashtable with the WT of each unit pretty easily.
 

Mog

Mog

Level 2
Joined
Feb 13, 2010
Messages
4
Thanks for the reply.

What I really wanted was something like that :
http://finalfantasy.wikia.com/wiki/Battle_Systems (scroll down to CTB)

I finally found a way of doing it while searching on the net :
http://www.spheredev.org/smforums/index.php?topic=2640.0
(so I guess the initial problem is solved...)

But I now have another problem. I tried to do it in the editor, it work more or so fine. Let me explain : It work fine when my units have a certain amount of agility, but below a certain value, the loop stop working before returning an unit, so I was wondering why and how could I fix it... Here is my code for getting the current unit turn :

JASS:
globals
    //I need to keep it global so I can remember the state of every unit's gauge atfer returning the current unit
    private integer array ReadyGauge
endglobals

private function GetCurrentUnit takes nothing returns unit
    local integer Max = 10000
    local unit Current = null
    local integer i = 0
    loop
        exitwhen Current != null
        set i = 0
        loop
            //the max number of unit in a team is 5 so 10 units at maximum
            exitwhen i==10
            set i=i+1
            //I could modify the Gauge increment with buff (haste/slow) or special ability that increase or lower the increment so the formula isn't complete yet but this is the basic
            set ReadyGauge[i-1] = ReadyGauge[i-1] + GetHeroStatBJ(bj_HEROSTAT_AGI, Party[i-1], true)
             if (ReadyGauge[i-1] >= Max) then
                set ReadyGauge[i-1] = 0
                set Current = Party[i-1]
            endif
        endloop
    endloop
    return Current
endfunction
 
Status
Not open for further replies.
Top