Inverting Order of Action (Trick Room)

Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Guys, I've been trying to create a field effect where the SLOWEST battler  (with the least Agi) moves first and the FASTEST battler (with most Agi) moves last.


So, basically the faster you are, the slower you'll be while a the state is still inflicted. Just like Trick Room in Pokemon.


I can also adapt this method using switch instead of state, so thats another option.


I tried to multiply AGi with -1 (Multiply with -100%) but the result is always *0% ... It looks like I can't multiply Agi parameter with negative number from the State "Features" tab. 


Is it possible for AGI parameter to be negative? Is there a way to do this?


Please help...


Thank You.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,370
Reaction score
7,678
First Language
German
Primarily Uses
RMMV
you'll need a script for this, because the values are capped to positive or zero.


The only way to handle this realistically is to change the code in the battlesequence.


I've moved this thread to Script Request. Please be sure to post your threads in the correct forum next time. Thank you.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Sorry, I'm new to this forum :)


And thanks a lot for your reply!!
 
Last edited by a moderator:

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
You could event this. You could have each character have, let's say, 1000 agi - their actual agi. Then, when the effect goes away, return them to their true agi (you must have stored them in a variable).


Ex:


A has 100 agi.


B has 200 agi.


B has more agi, B goes first.


Trick room.


A now has 1000 - 100 = 900 agi


B now has 1000 - 200 = 800 agi


Now A has more agi, now A goes first.


Here's an image. (Sorry that it's in spanish)


ertye45t.png
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
You could event this. You could have each character have, let's say, 1000 agi - their actual agi. Then, when the effect goes away, return them to their true agi (you must have stored them in a variable).


Ex:


A has 100 agi.


B has 200 agi.


B has more agi, B goes first.


Trick room.


A now has 1000 - 100 = 900 agi


B now has 1000 - 200 = 800 agi


Now A has more agi, now A goes first.


Here's an image. (Sorry that it's in spanish)


View attachment 46333
That's a good idea! Will this work for all enemies and actors? Because I have more than 4 playable characters (only 4 can be brought to battle though). Or do I have to apply this for all enemies and actors?
 
Last edited by a moderator:

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
frick, I just realized there's no way to change an enemy's agi. I have used my poor scripting skills to find another way to do it.


Choose one of two options:


Option A:


class Game_Action
def speed
if $game_switches[x]
speed = 9999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:


class Game_Action
def speed
if $game_switches[x]
speed = 9999
speed -= subject.agi
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




The difference between option A and option B is that option A is the default formula to speed: it adds a random component, meaning that sometimes a slower opponent may attack first. Option B erases that.


Now, where it says "if $game_switches[x]", change x to the id of a switch you like. When that switch is on, trick room will be activated.
 
Last edited by a moderator:

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
If you need help on anything, like attaching it to a skill or making the effect dissapear after x turns, just ask.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,370
Reaction score
7,678
First Language
German
Primarily Uses
RMMV
xdan, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


If you have to add something and your own post is the last one, please edit it.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
frick, I just realized there's no way to change an enemy's agi. I have used my poor scripting skills to find another way to do it.


Choose one of two options:


Option A:



class Game_Action
def speed
if $game_switches[x]
speed = 9999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:



class Game_Action
def speed
if $game_switches[x]
speed = 9999
speed -= subject.agi
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




The difference between option A and option B is that option A is the default formula to speed: it adds a random component, meaning that sometimes a slower opponent may attack first. Option B erases that.


Now, where it says "if $game_switches[x]", change x to the id of a switch you like. When that switch is on, trick room will be activated.
Thank you! I'll try it soon! And sorry if I asked too much... But how if I wanna activate it from a state? Because I would like to make the effect disappear after certain turns..
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
If you need help on anything, like attaching it to a skill or making the effect dissapear after x turns, just ask.
Yes please :)


Sorry, I'm still a noob at this..
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
Edit: Ok nevermind I found a way to do it with states.


Option A:


class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 9999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:


class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 9999
speed -= subject.agi
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end


Where it says "if $game_troop.members.any? {|mem| mem.state?(x)}" replace x with the id of the state you like. If any enemy has the state, trick room is active, so make sure the skill targets the whole enemy team.


Ignore this spoiler if you want, I explained how to do it with the switch.

Make a common event that activates the switch and attach it to a skill and sets a certain variable to 0. Then make a battle event that activates at the end of each turn only if the trick room switch is active.


thtrh.png


rgtferg.png


You want to store in the variable we set before to 0 how long the effect has been active. In the event, add 1 to the variable. Each turn, it will increase 1.


frgre.png


Now make a conditional branch that activates when the variable reaches the amount of turns you want the effect to last. Inside it, turn off the switch and set the variable to 0 again. You could also show a message, something like "The effect of Trick Room has dissapeared". It should look like this:


rgrgreg.png


Now, you'd have to put this in every single battle. If you don't want to do that (and I bet you don't), you can use this awesome script right here: https://yanflychannel.wordpress.com/rmvxa/utility-scripts/base-troop-events/


That script allows you to set a battle as a "base troop". All the events you put in it will be copied to every battle.







Hope I helped!
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Edit: Ok nevermind I found a way to do it with states.


Option A:



class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 9999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:



class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 9999
speed -= subject.agi
speed -= item.speed if item
speed -= subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end


Where it says "if $game_troop.members.any? {|mem| mem.state?(x)}" replace x with the id of the state you like. If any enemy has the state, trick room is active, so make sure the skill targets the whole enemy team.


Ignore this spoiler if you want, I explained how to do it with the switch.

Make a common event that activates the switch and attach it to a skill and sets a certain variable to 0. Then make a battle event that activates at the end of each turn only if the trick room switch is active.


View attachment 46527


View attachment 46528


You want to store in the variable we set before to 0 how long the effect has been active. In the event, add 1 to the variable. Each turn, it will increase 1.


View attachment 46529


Now make a conditional branch that activates when the variable reaches the amount of turns you want the effect to last. Inside it, turn off the switch and set the variable to 0 again. You could also show a message, something like "The effect of Trick Room has dissapeared". It should look like this:


View attachment 46534


Now, you'd have to put this in every single battle. If you don't want to do that (and I bet you don't), you can use this awesome script right here: https://yanflychannel.wordpress.com/rmvxa/utility-scripts/base-troop-events/


That script allows you to set a battle as a "base troop". All the events you put in it will be copied to every battle.







Hope I helped!
You're awesome!! It worked! But the thing is.. it appears to ignore priorities.. so skills like Quick Attack will move last... I hope I'm not asking too much, but is there any way to fix this? Make the Agi addition from skill goes after the trick room script is executed :D
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
You're awesome!! It worked! But the thing is.. it appears to ignore priorities.. so skills like Quick Attack will move last... I hope I'm not asking too much, but is there any way to fix this? Make the Agi addition from skill goes after the trick room script is executed :D


Well, it does exactly what was asked: inverts attack order. If you want agi addition from skill and items, you'd have to use this one:



Option A:

class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 7999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end



Option B:

class Game_Action
def speed
if $game_troop.members.any? {|mem| mem.state?(x)}
speed = 7999
speed -= subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end





But before using the code, there's something important you've missunderstood: what you set in the skill isn't a priority, it's just agi that adds to your total agi while you're using the skill. That means that if you have 10 agi and use an skill with 20 agi, you'll have a total of 30 agi for that turn. I'll put an example:


A has 20 agi and uses skill with 10 agi.


B has 30 agi and uses skill with 5 agi.


A: 20 + 10 = 30


B: 30 + 5 = 35


B is higher so he goes first even thought A's skill has higher agi.


If you want something like pokemon priority you'll probably need a script. Or set very high agi to your skills (I do that myself in fact):


ergergr.png
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
I gave the Skill 'Protect' 2000 Agi but it still goes last...


I think they calculate it as 9999 - (2000+ agi) instead of (9999-agi) + 2000.


It'll be great to have Pkmn like priority..


Also, I got an issue after an actor or enemy revives from fainting... Because it does not give the state automatically after reviving


You think using switch might be a better idea?.
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I gave the Skill 'Protect' 2000 Agi but it still goes last...


Are you sure? I just tested it and it worked fine.

Also, I got an issue after an actor or enemy revives from fainting... Because it does not give the state automatically after reviving


You think using switch might be a better idea?.


Yes, it certainly would.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Are you sure? I just tested it and it worked fine.


Yes, it certainly would.
Yes I've tested it.. witht he 7999 speed at the script and it still goes last


I'm using variable to count the TR turns and it's working fine now :)


But still the 'priorities' tho...
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
Yes I've tested it.. witht he 7999 speed at the script and it still goes last


I'm using variable to count the TR turns and it's working fine now :)


But still the 'priorities' tho...


Lend me your project, I have to see what's going on.


Option A:


class Game_Action
def speed
if $game_switches[x]
speed = 7999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:


class Game_Action
def speed
if $game_switches[x]
speed = 7999
speed -= subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end


These are the ones with the priority and the switch.


Edit: ok ok nevermind anything I just found the perfect script for us: http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/field-state-effects/


It makes everyone have a certain state, even when they are revived. Important: set the state duration to 1 turn more than it should last.
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Lend me your project, I have to see what's going on.


Option A:



class Game_Action
def speed
if $game_switches[x]
speed = 7999
speed -= subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi + rand(5 + subject.agi / 4)
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end




Option B:



class Game_Action
def speed
if $game_switches[x]
speed = 7999
speed -= subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
else
speed = subject.agi
speed += item.speed if item
speed += subject.atk_speed if attack?
speed
end
end
end


These are the ones with the priority and the switch.


Edit: ok ok nevermind anything I just found the perfect script for us: http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/field-state-effects/


It makes everyone have a certain state, even when they are revived. Important: set the state duration to 1 turn more than it should last.
No need to worry about the revive thing... I got everything covered using Tsukihime's Permastate script :)
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
So... Everything's solved now?
Yeah I think... I guess the priority issue can be ignored. I'm gonna add more rules to the game then..


Thanks for your help! Everything is now can be considered solved.


This thread can now be closed.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

"You can thank my later", "But you haven't done anything", "Well, that's why ..."
Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

Forum statistics

Threads
105,884
Messages
1,017,243
Members
137,609
Latest member
shododdydoddy
Top