Imploded Tomato

Veteran
Veteran
Joined
Sep 16, 2012
Messages
161
Reaction score
56
First Language
English
Primarily Uses
Is it possible for the Player character or enemy battler to have a 100 Percent chance for first strike during battle? I'm using the default battle system and want to incorporate first strikes in my project depending on how the Player and enemy event meet on the map (direction of the Player character and enemy when initiating battle). A good example of this feature is in "EarthBound : Mother 2". 

I can't figure how to do this as of now, is there a RGSS3 script I can reference during a script call to automatically initiate a first strike for the Player or enemy? Or maybe there is a script out there I cannot find because of other irrelevant scripts that are listed when searching on Bing? Any suggestions would be extremely helpful, thanks for your time.

EarthBound Mother 2 Snapshot.png

EarthBound Mother 2 Snapshot 2.png

EarthBound Mother 2 Snapshot 3.png

EarthBound Mother 2 Snapshot 4.png

EarthBound Mother 2 Snapshot 5.png
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,842
First Language
English
Primarily Uses
RMVXA
Bing?  BING?  You're using Bing and you're surprised to get irrelevant results?  Well duh!!  Why are you using Bing?  You've been deceived by their mediocre marketeers!  Go hang your head in shame!!  SHAAAAAAME!! :guffaw:

No, I'm not being paid by Google to rag on their would-be competitor, and Yes, there is a way to ensure the party gets the first strike when certain conditions are met.

The method you would use to do it is rate_preemptive in Game_Party.

#-------------------------------------------------------------------------- # * Calculate Probability of Preemptive Attack #-------------------------------------------------------------------------- def rate_preemptive(troop_agi) (agi >= troop_agi ? 0.05 : 0.03) * (raise_preemptive? ? 4 : 1) endLet's say you want the rate to be 100% when Switch 12 is ON.  Here's how you would rewrite (or alias) that method:

#-------------------------------------------------------------------------- # * Calculate Probability of Preemptive Attack #-------------------------------------------------------------------------- def rate_preemptive(troop_agi) if $game_switches[12] == true chance = 1.00 else chance = ((agi >= troop_agi ? 0.05 : 0.03) * (raise_preemptive? ? 4 : 1)) end return chance endThere are more concise ways to write that, but what I rewrote it as above is what I feel is the cleanest, clearest way.  This will give your party a 100% chance to First-Strike when Switch 12 is set to ON, and use the standard "compare party's AGI to troop's AGI and use the RNG to determine whether it's a First-Strike" logic if it's set to OFF.

EDIT: I forgot to include one more change that will be necessary to make this work for Event-based encounters, since the preemptive/surprise logic is only visited for Random Encounters by default.  It seems like rewriting the Battle Processing method in Game_Interpreter will fix this issue and allow Preemptives/Surprises logic (including that which I gave you above) to activate in Event Encounters.  Simply add the line BattleManager.on_encounter, as I did here.  Thanks for reporting this bug!

#-------------------------------------------------------------------------- # * Battle Processing #-------------------------------------------------------------------------- def command_301 return if $game_party.in_battle if @params[0] == 0 # Direct designation troop_id = @params[1] elsif @params[0] == 1 # Designation with variables troop_id = $game_variables[@params[1]] else # Map-designated troop troop_id = $game_player.make_encounter_troop_id end if $data_troops[troop_id] BattleManager.setup(troop_id, @params[2], @params[3]) BattleManager.on_encounter BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n } $game_player.make_encounter_count SceneManager.call(Scene_Battle) end Fiber.yield endNow, from the rest of your description, I take it you want to set the switch ON (or OFF) based on whether you're able to sneak up behind the enemy to initiate combat?  You can do that with just eventing.  There are several different ways to do it, but here's how I would go about it: you can set variables to equal player's current Map X and Map Y, as well as the "wandering enemy" event's Map X and Map Y (use "this event" to make it easy to copy the same wandering enemy event all over the map).  Then, create conditional branches based on which way the characters are facing.  So, for example, if the player is facing LEFT and the enemy is NOT facing RIGHT, and the player's Map X is greater than the enemy's Map X, you know that the player approached the enemy from its right side and snuck up on it.  You should set Switch 12 (or whatever switch you're using to track whether there should be a 100% First-Strike Rate) ON.  Once you've gone through all the ways that a player could have possibly gotten initiative, run the Battle processing as normal, and then remember to set Switch 12 back OFF after the battle is over, before the event processing ends.

One more edit: Right below rate_preemptive in Game_Party is rate_surprise and you can use similar logic to give the enemy a 100% chance to First-Strike you, if you'd like.  Note that preemptive takes precendence over surprise, so if you've somehow set it so that both parties would get a first strike, the player's party (preemptive) wins out and the surprise by the enemies is ignored.
 
Last edited by a moderator:

Imploded Tomato

Veteran
Veteran
Joined
Sep 16, 2012
Messages
161
Reaction score
56
First Language
English
Primarily Uses
Well this is impressive Wavelength, and makes perfect sense to me; thanks a bunch! I've already set up the detection by using a script called "Proximity Detection Script v1.5a" by V.M of D.T. and it is working flawlessly!

Edit : I use Bing to get free xbox live gold membership codes, that's why I use Bing. I dislike google, they sell your personal information, gibiru is my preferred search engine.
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,842
First Language
English
Primarily Uses
RMVXA
Sure thing!  Let me know if there's any other logic you'd like to work in those methods.  I'll check out the Proximity Detection script, too - Vlue's scripts tend to be really nice.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,970
Reaction score
8,618
First Language
German
Primarily Uses
RMMV
that's why I use Bing. I dislike google, they sell your personal information, gibiru is my preferred search engine.
For something as small and specific a community as RM, all of the general search engines are a bad choice (even more so if you're looking for terms that have a different specific use in RM compared to general use, for example "Parallax".
You'll usually getting a lot better search results if you're using the forum search engines of the specific forums, as you won't get the hundred thousands non-RM results you'll get from Google, Bing and other general search engines.
 

Latest Threads

Latest Posts

Latest Profile Posts

Doing RPG Maker News for 24th October 2021

I'm not sure how to do this so I'll just ask here, Wheres a good place to post your game (for free) once its done?
I don't know what I'm doing :D
So got my hearing tested to see if it was the cause of my mishearing what people say. Test showed no problems but talked with the doctor about anxiety and ADHD causing hearing issues and she agreed and also added that some people hear things differently. With my anxiety cause I am in fight or flight I pay attention to all the sounds in the area so body knows when react. Can't pay attention to one source.

Forum statistics

Threads
116,057
Messages
1,095,397
Members
151,418
Latest member
MythologixGD
Top