Help with a Battle time reversal skill

● ARCHIVED · READ-ONLY
Started by Latimius 8 posts View original ↗
  1. Hello,

    I want to make an oracle class who has the power to reverse time during a combat, which means he can select one or multiple actors (depending of the skill) and put them in the way they were 3 turns before, including hp, mp and states.
    I have no idea how to do it in practice ;'(
    So I was wondering if you guys knew a way to do this ^^

    PS : I use yanfly's plugins if that makes a difference.
  2. That is actually very tough to do, as you will have to save their HP, MP and states for every turn in battle in preparation for that skill, then when it is used you will need to have it recall the appropriate values. In other words,it is a very advanced javascript coding problem, and I've yet to see anyone here solve it to date.

    I've moved this thread to JavaScript Support. Thank you.

  3. It's not that hard to do, but it's better done with a plugin.
    You can do it with events though and a bit of js.
    Have an event run at each turn start with the following code:

    Edit: removed due to typo, use the version below.

    This code stores the hp mp tp state state duration buff and buff duration properties for every actor and enemy at the start of every turn in an array.
    Specifically a $gameTroop._log array is created on turn 0 and is filled each turn with the actors and enemies array containing those properties.
    So for turn 1 (before any action is taken) to get actor 1 hp you'd call:
    $gameTroop._log[1].actors[1].hp
    $gameTroop._log[1].enemies[1].hp for foes

    When casting the spell of your oracle you just have to recall the proper turn then.

    To recall for three turn earlier you'd do assuming using yanfly scripts were target is defined and a single target spell:
    This defaults to turn 1 before any actions are taken if the cast happens before turn 4
    Code:
    var turn = $gameTroop._turnCount
    var turnDes = turn - 3; if (turnDes < 1) {turnDes = 1;}
    if (target.isActor()) {
    target._hp = $gameTroop._log[turnDes].actors[target._actorId].hp
    target._mp = $gameTroop._log[turnDes].actors[target._actorId].mp
    target._tp = $gameTroop._log[turnDes].actors[target._actorId].tp
    target._states = $gameTroop._log[turnDes].actors[target._actorId].states
    target._stateTurns = $gameTroop._log[turnDes].actors[target._actorId].stateTurns
    target._buffs = $gameTroop._log[turnDes].actors[target._actorId].buffs
    target._buffTurns = $gameTroop._log[turnDes].actors[target._actorId].buffTurns
    } else {
    var index = $gameTroop.members().indexOf(target)
    target._hp = $gameTroop._log[turnDes].enemies[index].hp
    target._mp = $gameTroop._log[turnDes].enemies[index].mp
    target._tp = $gameTroop._log[turnDes].enemies[index].tp
    target._states = $gameTroop._log[turnDes].enemies[index].states
    target._stateTurns = $gameTroop._log[turnDes].enemies[index].stateTurns
    target._buffs = $gameTroop._log[turnDes].enemies[index].buffs
    target._buffTurns = $gameTroop._log[turnDes].enemies[index].buffTurns
    }

    I haven't really tested it much, only gave it 1 try, but it worked for me, so it should work.
  4. Hey, thx for the reply !

    But I've got a problem, for the second script you gave me, I tried to put it in a common event that was called by the oracle skill, but the script is too long for the common event. How did you make it work ?

    BTW, I forgot to mention it but my battle system is the Olivia's Octopack one (a variant of the yanfly's STB system)
  5. It won't work in a common event, because target won't be defined.
    Use it in an after eval notetag from skill core or in an action sequence using the eval line.
  6. Astfgl66 said:
    It won't work in a common event, because target won't be defined.
    Use it in an after eval notetag from skill core or in an action sequence using the eval line.
    Alright, thanks !
    So, now, it works, until I cast the spell on someone who is affected by a state, that makes the game crash :'(
    https://snag.gy/Cf1QA6.jpg
  7. Ah I made a typo in the troop event: it should be like this:
    Code:
    var turn = $gameTroop._turnCount
    if (turn === 1) {
    $gameTroop._log = [0,{actors:[],enemies:[]}];
    } else {
    $gameTroop._log.push({actors:[],enemies:[]});
    }
    $gameParty.battleMembers().forEach(function(member){
    $gameTroop._log[turn].actors[member._actorId] = {hp:member._hp,mp:member._mp,tp:member._tp,states:member._states,stateTurns: member._stateTurns, buffs: member._buffs, buffTurns: member._buffTurns}
    })
    $gameTroop.members().forEach(function(member,index){
    $gameTroop._log[turn].enemies[index] = {hp:member._hp,mp:member._mp,tp:member._tp,states:member._states,stateTurns: member._stateTurns, buffs: member._buffs, buffTurns: member._buffTurns}
    })

    I named the property statesTurns instead of stateTurns.
    I tested it and it works fine now even with states.
  8. Well, it doesn't crash anymore that's true ! (amazing job btw) but it doesn't put the same states as 3 turns before, it doesn't affect them at all (at least in my game ^^)
    Exemple : Turn 1 : actor is unharmed
    Turn 2 : Actor got blinded
    Turn 3 : Oracle's skill used, Actor is full life (because he was full life turn 1) but still blinded