[RMVX ACE] CHECK IF AN ACTOR HAS EVADED AN ATTACK?
Posts
Pages:
1
I'm trying to using Yanfly's Lunatic States Found Here in order to create an effect where if a character evades an attack, they receive a buff to their stats.
However, I'm running into trouble forming the check to see if the User has properly evaded the attack.
I figure this is stored somewhere in the game_results or game action_results, as I was able to create a state that granted bonus on hitting a critical using similar methods.
So far, I have a passive state applied to said character. I'm using a "react effect" on that state that says the following:
I've also tried "if user.result.evaded" and "state_origin.result.evaded" but whenever the actor dodges, nothing happens. That state(44) is a bonus state that has the actual bonuses.
Am I just completely off? Thanks for taking the time to read this :).
However, I'm running into trouble forming the check to see if the User has properly evaded the attack.
I figure this is stored somewhere in the game_results or game action_results, as I was able to create a state that granted bonus on hitting a critical using similar methods.
So far, I have a passive state applied to said character. I'm using a "react effect" on that state that says the following:
when "EVADEBONUS"
if @result.evaded
user.add_state(44)
end
I've also tried "if user.result.evaded" and "state_origin.result.evaded" but whenever the actor dodges, nothing happens. That state(44) is a bonus state that has the actual bonuses.
Am I just completely off? Thanks for taking the time to read this :).
I don't know a thing about coding, but I have a script Craze made called Regrowth Options that does something like this. It has options for "when a character evades" but it seems to mainly do things like restoring HP, TP, or MP, but maybe it'd give you a clue, if nothing else?
I'd link you to it on his old blog, but it just 404s, so I can paste it here if you like!
I'd link you to it on his old blog, but it just 404s, so I can paste it here if you like!
author=unity
I don't know a thing about coding, but I have a script Craze made called Regrowth Options that does something like this. It has options for "when a character evades" but it seems to mainly do things like restoring HP, TP, or MP, but maybe it'd give you a clue, if nothing else?
I'd link you to it on his old blog, but it just 404s, so I can paste it here if you like!
That's actually a great idea!
I think I may have a copy of that script somewhere in my super old VX Ace failures...
Can you link it here, just in case :P
Not sure how much this helps, but, the default processing for the evasion check seems to be in Game_Battler?
*Edit: Maybe as a test-run, insert a new code-block with something like...
...this, and observe if the state is applied after a successful evasion? Might not hurt to set a character's (or enemy's) EVA to, like, 90% or 100% for the purposes of testing too.
class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Calculate Evasion Rate for Skill/Item #-------------------------------------------------------------------------- def item_eva(user, item) return eva if item.physical? # Return evasion if physical attack return mev if item.magical? # Return magic evasion if magic attack return 0 end #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end end end
*Edit: Maybe as a test-run, insert a new code-block with something like...
class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) elsif @result.evaded user.add_state(44) end end end
...this, and observe if the state is applied after a successful evasion? Might not hurt to set a character's (or enemy's) EVA to, like, 90% or 100% for the purposes of testing too.
author=Marrend
Not sure how much this helps, but, the default processing for the evasion check seems to be in Game_Battler?
class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Calculate Evasion Rate for Skill/Item #-------------------------------------------------------------------------- def item_eva(user, item) return eva if item.physical? # Return evasion if physical attack return mev if item.magical? # Return magic evasion if magic attack return 0 end #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end end end
*Edit: Maybe as a test-run, insert a new code-block with something like...
class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) elsif @result.evaded user.add_state(44) end end end
...this, and observe if the state is applied after a successful evasion? Might not hurt to set a character's (or enemy's) EVA to, like, 90% or 100% for the purposes of testing too.
Well, that snippet worked, but when the actor dodged it added the state to the enemy. So now, I guess the next step would be to change it so the "target" gets the state, and only when a specific actor is targeted.
I could make an equipment tag that says if the target's notebox contains this tag, add the state.
Oh no, the Code option and the Hide option don't work together and now I've flooded the topic with a big script!?
Whoops!
Well, thanks for sending! :D
I'm going to take a look at this and play with Marrend's snippet and see if I can come up with something.
Well, thanks for sending! :D
I'm going to take a look at this and play with Marrend's snippet and see if I can come up with something.
author=unity
When you've got it copied, I'll edit it out so people won't have to scroll forever.
You're good to go! Thank you!
Now to keep working at this. :P
Hide-tag is the absolute worst, sometimes. ;_;
Also, let me think this out a bit. I probably figured that the variable "user" in the context of Game_Battler was, technically, the target of a skill/item. In that case, the actual user of the skill/item would presumably be the object calling the function.
So, if my references were wrong, and "user" is exactly what it says on the tin, then, we might be looking at a function call attributed to "self"...
...or a function call...
...like so?
*Edit: Gotta love testingnot really!
Also, let me think this out a bit. I probably figured that the variable "user" in the context of Game_Battler was, technically, the target of a skill/item. In that case, the actual user of the skill/item would presumably be the object calling the function.
So, if my references were wrong, and "user" is exactly what it says on the tin, then, we might be looking at a function call attributed to "self"...
self.add_state(44)
...or a function call...
add_state(44)
...like so?
*Edit: Gotta love testing
Hey Marrend,
I think you may be on to something here...
but your original snippet had me looking at this from another angle. Instead of having the actor check if he dodged, I can check to see if the enemy skill simply missed the actor. I mean, from the player's end the result is the same right?
So instead, I used Yanfly's Lunatic Objects, and created a code on the enemy attacks where if the target was missed or evaded, they would get a state... I used pretty much the same code above, and that worked.
Not sure why it works this way, and not the other way, but I'll take it!
Thanks Unity and Marrend for helping me think this out!
I think you may be on to something here...
but your original snippet had me looking at this from another angle. Instead of having the actor check if he dodged, I can check to see if the enemy skill simply missed the actor. I mean, from the player's end the result is the same right?
So instead, I used Yanfly's Lunatic Objects, and created a code on the enemy attacks where if the target was missed or evaded, they would get a state... I used pretty much the same code above, and that worked.
Not sure why it works this way, and not the other way, but I'll take it!
Thanks Unity and Marrend for helping me think this out!
Pages:
1