Well, I took a break of developing my KGuardian script and begun coding my new KCheckEventByCoords script. It will spare you the need for looping through all map events by searching that specific event by its coordinates.
After a while I updated it so that topic now includes a second version that allows RMXP game devs to assign a different trigger key for specific map events. The good thing about it is that it does NOT replace your old friend the OK button trigger functionality. Map events that are supposed to be triggered by pressing OK button will still work as normal without making any effort or any changes. Actually it does take advantage of my original idea.
Edit:
I updated the scripts once again to add a script call and fix some minor bugs.
I finished porting my KItemRefill script to VX, so there is one version for XP and another one for VX. I don't know if I'll port it to VX Ace some day. I also updated my script KElemRES XP, it reached version 0.8.16 and 0.8.17 when Melana showed up because she was quite interested in implementing it on her own game project. Later on I posted a more complete version (0.9.0) of my script that already includes a menu so game dev's and players can convert resistance gems to any other resistance gems.
For the past while I've been struggling with the weirdest bug that emerged while making my "pure RGSS enemy AI" thingy.
If an enemy is in a confused/berserk state and the skill they use (normally only Attack) costs MP they don't have, even after they
just paid the cost, the action is negated. Since it gets negated, there is no active skill (even though they already "passed go"), no targets, and the following error occurs:
Scene_Battle, line 584, NoMethodError
undefined method 'make_targets' for nil:NilClass
The line in question:
targets = @subject.current_action.make_targets.compact
This error happens because... somehow... the current_action has been erased the moment before it was used.
It took me a lot of messing around to be able to recreate this bug in a fresh project - it wasn't to do with my custom AI or anything, it was... to do with my "tiredness" script? It adds/removes a Tired state for "critical" MP. Like, literally all it is is this:
PHP Code:
<?php
class Game_BattlerBase
alias :tayruu_tiredness_gamebattlerbase_refresh :refresh
def refresh
tayruu_tiredness_gamebattlerbase_refresh
mp_rate <= 0.25 ? add_state(2) : remove_state(2)
end
end
I have no idea as of yet why this code would do this? It's also possible refresh isn't the best place for this code (even though this is where the dead state is refreshed too).
EDIT: ...
PHP Code:
<?php
class Game_Battler < Game_BattlerBase
def add_new_state(state_id)
die if state_id == death_state_id
@states.push(state_id)
on_restrict if restriction > 0
sort_states
refresh
end
def on_restrict
clear_actions
states.each do |state|
remove_state(state.id) if state.remove_by_restriction
end
end
Okay, when the tiredness state is added, the game ends up passing through add_state, add_new_state, on_restrict, and then
clear_actions. While "tired" is unrestricted, because the enemy has another restrictive state (confusion qualifies), it then clears the action. It does this at the moment of paying MP, but before the action itself, thus the crashing bug.
... so the answer to that is to probably move the add/removal to tiredness to somewhere like end-of-turn instead of refresh. Maybe?