After reading an article on TVTropes, I got an idea for a neat mechanic for a game I'm working on.
http://tvtropes.org/pmwiki/pmwiki.php/Main/BreakMeter
If anyone could design a script that allows the addition of a state when someone's TP are at maximum, I would be a very happy man.
Break Meter plz
● ARCHIVED · READ-ONLY
-
-
Maybe no custom scripts are needed. Usually battlers gain tp from trg or skills or items or taking damage, and damage are usually from negative hrg or enemies or self's attacks which are usually skills. So the below setup might work:
1. Change/add the custom damage formula of all skills that deal damage or give tp directly to targets and/or users to something like the below:
[a, b].each { |c| c.add_state(x) if c.tp == c.max_tp }; original_custom_damage_formulaNow if that skill hits the target, state with id x should be added to that target when his/her/its tp reaches the max. original_custom_damage_formula is the original custom damage formula of those skills before applying the above modification.
Just beware that using the above modification might cause some of the resulting custom damage formulae to exceed the default RMVXA limit.
2. Add an battle event page with trigger turn 0 + 1 * x in all battles. Add the below script code in all those battle event pages(the script box of v1.02a should be large enough for this):
battlers = $game_party.alive_members + $game_troop.alive_membersbattlers.each { |battler| battler.add_state(x) if battler.tp == battler.max_tp }As tp regen from trg are at the beginning of turns in the default RMVXA settings, if a battler's tp reaches max due to this, the above script code should be able to catch these battlers and add state with id x to them.
Of course even if the above whole setup does work it's still tedious to implement(especially if you have lots of skills and battle troops), and any decent custom script will be much, much simpler and more efficient and effective, but you may want to try this non-scripting method :) -
#===============================================================================# Written By DekitaRPG 17/o8/2o14# http://dekitarpg.wordpress.com/#===============================================================================module'>http://dekitarpg.wordpress.com/#===============================================================================module DekiSoPro#=============================================================================== #----------------------------------------------------------------------------- # State ID of state to apply when max tp is reached. #----------------------------------------------------------------------------- State_ID = 10 #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================class Game_BattlerBase#=============================================================================== #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- alias :refresh_add_status_effz :refresh #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh refresh_add_status_effz refresh_state_thing_for_max_tp end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh_state_thing_for_max_tp if reached_max_tp? add_state(DekiSoPro::State_ID) return end remove_state(DekiSoPro::State_ID) end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def reached_max_tp? @tp == max_tp end #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================# http://dekitarpg.wordpress.com/#=============================================================================== :)
Edit:
Damn Ninja's :/ -
Dekita, you were faster than I am (mine's half working, as I didn't think of the refresh command). Guess that comes with experience.
Edit: Here's the link to mine if you wish to see it or use it, now working now that I'm no longer using the on_damage command: http://pastebin.com/aeAAP1AK -
That's why the module name of his snippet is DekiSoPro :)Dekita, you were faster than I am (mine's half working, as I didn't think of the refresh command). Guess that comes with experience.
Actually, aliasing the refresh command is the easiest, fastest and most compatible and flexible way to do this. Being flexible here means it works with any tp mechanics, not just the default one. Dekita is a really pro scripter :D
Strictly speaking, it's not the most resource-friendly way as it checks @tp == max_tp all for battlers per frame, but only those obsessed with minimizing resources usage will care about this as that checking uses tiny resources. -
True that. Probably why we have the code off challenge too, so that those of us learning (like me) can try and compare with the pros.
-
Most of the time i spent writing the documentation :p
Yea, checking @tp == max_tp is not really ideal, but its a necessary evil imo. I mean, most all max tp controlling scripts modify the max_tp method to read from the newly written(usually) method of mtp. So having a check against whatever is considered the max value is best in this situation, rather than just assuming it will always be 100. :) -
Testing this code as we speak, as of the custom scripts posted on this thread, I think this one is the most well-written#===============================================================================# Written By DekitaRPG 17/o8/2o14# http://dekitarpg.wordpress.com/#===============================================================================module'>http://dekitarpg.wordpress.com/#===============================================================================module DekiSoPro#=============================================================================== #----------------------------------------------------------------------------- # State ID of state to apply when max tp is reached. #----------------------------------------------------------------------------- State_ID = 10 #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================class Game_BattlerBase#=============================================================================== #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- alias :refresh_add_status_effz :refresh #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh refresh_add_status_effz refresh_state_thing_for_max_tp end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh_state_thing_for_max_tp if reached_max_tp? add_state(DekiSoPro::State_ID) return end remove_state(DekiSoPro::State_ID) end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def reached_max_tp? @tp == max_tp end #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================# http://dekitarpg.wordpress.com/#=============================================================================== :)
Edit:
Damn Ninja's :/ -
Thanks. I try to keep my code as neat and tidy as possible :)
If you have any problems with it let me know. I'm sure I wrote a more advanced version of this for someone in the past. I've been trying to find the thread to no avail. If do though, I will send a link your way :) -
I don't think your snippet could create any non-trivial problem if it's placed below all other custom scripts if any.Thanks. I try to keep my code as neat and tidy as possible :)
If you have any problems with it let me know. I'm sure I wrote a more advanced version of this for someone in the past. I've been trying to find the thread to no avail. If do though, I will send a link your way :)
The only exception I can think of is that some 'creative geniuses' rewrite max_tp into a complete mess, but it's extremely unlikely.
If this does happen, it'll probably generate intolerable continuous resource waste, but then it's probably those guys' fault, not yours :)
P.S.: That's why I think the name of your snippet's module deserves to be DekiSoPro. Your snippet is just unable to cause non-trivial problems :D -
Well, another potential issue, again probably due to the 'creative geniuses'... If someone where to rewrite the refresh method (which i have seen unnecessarily done alot) within either Game_BattlerBase, Game_Battler, Game_Actor or Game_Enemy. Then, my script would be 'unread' by the interpreter (but this again would be solved by placing my script below theirs)... So I guess thats not really any kind of major threat :p
-
Speaking of rewriting the refresh method under class Game_Actor, if any scripter even do this and if they remove the super in their rewrites... Well I think rewriting refresh is mostly pointless to begin with already :)Well, another potential issue, again probably due to the 'creative geniuses'... If someone where to rewrite the refresh method (which i have seen unnecessarily done alot) within either Game_BattlerBase, Game_Battler, Game_Actor or Game_Enemy. Then, my script would be 'unread' by the interpreter (but this again would be solved by placing my script below theirs)... So I guess thats not really any kind of major threat :p
But yeah, if refresh in Game_Actor is rewritten and the super is removed in the rewrite, your snippet won't work no matter how its users place it. I'm talking about really extreme cases which should just never happen :D -
Oh yea, it would have to be an extreme case for such a thing to occur.
Personally I think a rewrite of the refresh method would be great (not only for battlerbase, but for everything)- but only to place each line of code into its own method... For example...
class Game_BattlerBase def refresh state_resist_set.each {|state_id| erase_state(state_id) } @hp = [[@hp, mhp].min, 0].max @mp = [[@mp, mmp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) endendBeing rewritten into something like
class Game_BattlerBase def refresh refresh_state_resist refresh_hp_set refresh_mp_set refresh_death_state end def refresh_state_resist state_resist_set.each {|state_id| erase_state(state_id) } end def refresh_hp_set @hp = [[@hp, mhp].min, 0].max end def refresh_mp_set @mp = [[@mp, mmp].min, 0].max end def refresh_death_state @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) endendObviously doing this is completely unnecessary, but its also alot cleaner and leaves alot more room for 3r party modification. Hopefully the next RPGMaker is structured as such. That will make for many easy to make scripts with high chance of compatibility :)
Also - have to remember as well, alof of new scripters - the ones like me, who started by modifying other scripts rather than learn the language first - dont fully understand the power of super or even aliasing. Obviously, once they are more familiarized with writing code in general it rarely happens, but the mistakes people make can 'haunt them' forever...
My first script was the 'Perfect Stat Point Distribution System' < Which has many flaws. I later rewrote that system into my 'Insane Stat Point Distribution System' < Which is much better in terms of efficient code and features. Yet still, my PSPDS has gained just as many views this year as my ISPDS.
Is a complete pain in the ass - when you know there is a better script available (and have stated that on the script download page) yet people continue to use the old inefficient model...
Anyway... I'm rambling now... -
And I've found the hard way being a good programmer at Java/C/C++ (which are my primary languages) does NOT make you good at scripting right away. Ruby syntax is mostly similar to Java, but the concepts are in some cases radically different. Not to mention I'm always going through the base scripts trying to find "What object affects this?"
It just takes a lot of practice. -
Well, it works. Thank you very much.Testing this code as we speak, as of the custom scripts posted on this thread, I think this one is the most well-written#===============================================================================# Written By DekitaRPG 17/o8/2o14# http://dekitarpg.wordpress.com/#===============================================================================module'>http://dekitarpg.wordpress.com/#===============================================================================module DekiSoPro#=============================================================================== #----------------------------------------------------------------------------- # State ID of state to apply when max tp is reached. #----------------------------------------------------------------------------- State_ID = 10 #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================class Game_BattlerBase#=============================================================================== #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- alias :refresh_add_status_effz :refresh #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh refresh_add_status_effz refresh_state_thing_for_max_tp end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def refresh_state_thing_for_max_tp if reached_max_tp? add_state(DekiSoPro::State_ID) return end remove_state(DekiSoPro::State_ID) end #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- def reached_max_tp? @tp == max_tp end #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------end#===============================================================================# http://dekitarpg.wordpress.com/#=============================================================================== :) Edit:
Damn Ninja's :/
EDIT: Wow, I have not been doing well with response time. Now there are more scripts to try out. -
No problem :)
Also: there is no need to use any of the scripts from above. They are just examples I gave in my ramblings about ho things should be structured (imo) :D