YEP.162 – Advanced Switches and Variables Tutorial – RPG Maker MV

NOTE: This is a tutorial made for the Advanced Switches & Variables plugin.

Many of you have asked what are some more ways we can use this plugin. That’s a very good question because there’s a lot of things you can do with this plugin. However, instead of giving the answers to every single example, it may be better for me to give you the actual Eval codes themselves and the description so you can figure out the things you can do with it, instead. There will be a “possible use” example listed just to give you an idea how things may be used. Hopefully, upon reading the descriptions for each one, you may come up with some ideas or answers to what you are looking for!


Switches


Switches

The following examples will be used for switches!

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameTemp.isPlaytest()

The switch will be ON if the game is in play test mode.
The switch will be OFF if the game isn’t in play test mode.
Possible Use: Debug events that only appear during play testing.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isJapanese()
Eval: $gameSystem.isChinese()
Eval: $gameSystem.isKorean()
Eval: $gameSystem.isRussian()

The switch will be ON if the game locale is in Japanese, Chinese, Korean, or Russian.
The switch will be OFF if the game isn’t in Japanese, Chinese, Korean, or Russian.
Possible Use: Events that behave differently for different language settings.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isSideView()

The switch will be ON if the game is running in sideview mode. Useful for those with the option to switch between sideview and frontview.
The switch will be OFF if the game is running in frontview mode.
Possible Use: Making a battle event that gives a different troop to fight depending on the view setting.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isSaveEnabled()

The switch will be ON if the player is capable of saving from the main menu.
The switch will be OFF if the player isn’t capable of saving from the main menu.
Possible Use: Make visible on-screen save points appear/disappear.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isMenuEnabled()

The switch will be ON if the player is capable of accessing the main menu through the X key.
The switch will be OFF if the player isn’t capable of accessing the main menu through the X key.
Possible Use: An event that may interact with the character’s main menu can be disabled if the character loses access to it.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isEncounterEnabled()

The switch will be ON if random encounters are enabled.
The switch will be OFF if random encounters are disabled.
Possible Use: An event that may or may not appear depending on how encounters are enabled.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.isFormationEnabled()

The switch will be ON if the player is capable of changing the party formation.
The switch will be OFF if the player isn’t able to change the party formation.
Possible Use: Can be used for an event that may or may not bar the player from a party changing prompt.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSelfSwitches.value([10,20,'A'])

The switch will be ON if map 10, event 20’s, A self switch is ON.
The switch will be OFF if map 10, event 20’s, A self switch is OFF.
Possible Use: It is used to reference another map/event’s self switch setting.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(1).isStateAffected(15)

The switch will be ON if Actor 1 is affected by state 15.
The switch will be OFF if Actor 1 is not affected by state 15.
Possible Use: May produce a different event branch. For example, if the actor was affected by state 15 (Poison), something different will happen in the storyline.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(2).isBuffAffected(0)
Eval: $gameActors.actor(2).isBuffAffected(1)
Eval: $gameActors.actor(2).isBuffAffected(2)
Eval: $gameActors.actor(2).isBuffAffected(3)
Eval: $gameActors.actor(2).isBuffAffected(4)
Eval: $gameActors.actor(2).isBuffAffected(5)
Eval: $gameActors.actor(2).isBuffAffected(6)
Eval: $gameActors.actor(2).isBuffAffected(7)

The switch will be ON if Actor 2 is affected by a certain buff. 0 = MaxHP, 1 = MaxMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK.
The switch will be OFF if Actor 2 is not affected by a certain buff. 0 = MaxHP, 1 = MaxMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK.
Possible Use: May produce a different event branch. For example, if the actor had its ATK buffed, it may be able to break through a locked door.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(3).isDebuffAffected(0)
Eval: $gameActors.actor(3).isDebuffAffected(1)
Eval: $gameActors.actor(3).isDebuffAffected(2)
Eval: $gameActors.actor(3).isDebuffAffected(3)
Eval: $gameActors.actor(3).isDebuffAffected(4)
Eval: $gameActors.actor(3).isDebuffAffected(5)
Eval: $gameActors.actor(3).isDebuffAffected(6)
Eval: $gameActors.actor(3).isDebuffAffected(7)

The switch will be ON if Actor 3 is affected by a certain debuff. 0 = MaxHP, 1 = MaxMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK.
The switch will be OFF if Actor 3 is not affected by a certain debuff. 0 = MaxHP, 1 = MaxMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK.
Possible Use: May produce a different event branch. For example, if the actor’s MaxHP has been debuffed, the actor may suffer from a death event.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(4).isStateResist(10)

The switch will be ON if Actor 4 is resistant against state 10.
The switch will be OFF if Actor 4 is not resistant against state 10.
Possible Use: May produce a different event branch. For example, if the actor is resistant against paralysis, the actor can overturn a binding spell during an event.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(5).isSkillTypeSealed(20)

The switch will be ON if Actor 5’s skill type 20 is sealed.
The switch will be OFF if Actor 5’s skill type 20 isn’t sealed.
Possible Use: May produce a different event branch. For example, if the actor’s skill type is sealed during an event, it will not be able to cast a certain spell to change the outcome.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(6).isSkillSealed(50)

The switch will be ON if Actor 6’s skill 50 is sealed.
The switch will be OFF if Actor 6’s skill 50 isn’t sealed.
Possible Use: May produce a different event branch. For example, if the actor’s skill type is sealed during an event, it will not be able to cast a certain spell to change the outcome.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActor.actor(7).isDead()

The switch will be ON if Actor 7 is currently dead.
The switch will be OFF if Actor 7 is currently alive.
Possible Use: Different event outcome if the actor in question is dead or alive.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActor.actor(8).isAlive()

The switch will be ON if Actor 8 is currently alive.
The switch will be OFF if Actor 8 is currently dead.
Possible Use: Different event outcome if the actor in question is dead or alive.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(9).hasWeapon($dataWeapons[100])
Eval: $gameActors.actor(9).isEquipped($dataWeapons[100])

The switch will be ON if Actor 9 has weapon 100 equipped.
The switch will be OFF if Actor 9 doesn’t have weapon 100 equipped.
Possible Use: Different event outcome if the actor in question has weapon 100 equipped. This can be used to check if the actor is carrying a legendary weapon on hand to maybe influence an NPC to do something for them.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(10).hasArmor($dataArmors[200])
Eval: $gameActors.actor(10).isEquipped($dataArmors[200])

The switch will be ON if Actor 10 has armor 200 equipped.
The switch will be OFF if Actor 10 doesn’t have armor 200 equipped.
Possible Use: Different event outcome if the actor in question has weapon 100 equipped. This can be used to check if the actor is wearing a cloak that may conceal his/her presence from a guard.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(11).isLearnedSkill(50)

The switch will be ON if Actor 11 has skill 50 learned.
The switch will be OFF if Actor 11 hasn’t learned skill 50 yet.
Possible Use: Different event condition. If say, skill 50 is “True Sight”, then the actor may be able to see through the enemy’s disguise.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(12).hasSkill(60)

The switch will be ON if Actor 12 has skill 60. Different from learned. This can be added through a weapon/armor/state’s traits.
The switch will be OFF if Actor 12 doesn’t have skill 60.
Possible Use: Different event condition. If say, skill 60 is “Treasure Hunter”, then the actor can find secret paths to treasure locations.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –


Variables


Variables

The following examples will be used for variables!

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.battleCount()

The variable will return a value of how many battles the player has fought in this game save.
Possible Use: A trophy that may appear in the player’s HQ after fighting a certain number of battles.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.winCount()

The variable will return a value of how many battles the player has won in this game save.
Possible Use: A trophy that may appear in the player’s HQ after winning a certain number of battles.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.escapeCount()

The variable will return a value of how many battles the player has escaped in this game save.
Possible Use: A trophy that may appear in the player’s HQ after escaping a certain number of battles.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameSystem.saveCount()

The variable will return a value of how many times the player has saved in this game.
Possible Use: Can be used to reference an achievement if the player has saved less than a certain number of times.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameScreen.weatherType()

The variable will return a value of the current weather being played. 0 = none, 1 = rain, 2 = storm, 3 = snow
Possible Use: Different dialogue options from NPC’s depending on the current weather.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameScreen.weatherPower()

The variable will return a value of the current weather’s power (from 1 to 9).
Possible Use: Different dialogue options from NPC’s depending on the weather’s power.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameActors.actor(1).level
Eval: $gameActors.actor(1).mhp
Eval: $gameActors.actor(1).hp
Eval: $gameActors.actor(1).mmp
Eval: $gameActors.actor(1).mp
Eval: $gameActors.actor(1).atk
Eval: $gameActors.actor(1).def
Eval: $gameActors.actor(1).mat
Eval: $gameActors.actor(1).mdf
Eval: $gameActors.actor(1).agi
Eval: $gameActors.actor(1).luk

The variable will return a value of Actor 1’s base parameters: Level, MaxHP, HP, MaxMP, MP, ATK, DEF, MAT, MDF, AGI, LUK
Possible Use: A different event that can occur once the specific actor’s parameter has reached a certain point, such has having enough ATK to move a boulder.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: Math.floor(100 * $gameActors.actor(2).hit)
Eval: Math.floor(100 * $gameActors.actor(2).eva)
Eval: Math.floor(100 * $gameActors.actor(2).cri)
Eval: Math.floor(100 * $gameActors.actor(2).cev)
Eval: Math.floor(100 * $gameActors.actor(2).mev)
Eval: Math.floor(100 * $gameActors.actor(2).mrf)
Eval: Math.floor(100 * $gameActors.actor(2).cnt)
Eval: Math.floor(100 * $gameActors.actor(2).hrg)
Eval: Math.floor(100 * $gameActors.actor(2).mrg)
Eval: Math.floor(100 * $gameActors.actor(2).trg)

The variable will return a value of Actor 2’s extra parameters: Hit Rate, Evasion, Critical Rate, Critical Evasion, Magic Evasion, Magic Reflect, Counter Rate, HP Regeneration, MP Regeneration, and TP Regeneration values. These values are originally decimals, but this will return them as whole numbers multiplied by 100 and then rounded down.
Possible Use: Can be used for an event that occurs once the actor’s specific extra parameter reached a certain point. For example, shooting an arrow at a very difficult target while checking the actor’s HIT rate.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: Math.floor(100 * $gameActors.actor(3).tgr)
Eval: Math.floor(100 * $gameActors.actor(3).grd)
Eval: Math.floor(100 * $gameActors.actor(3).rec)
Eval: Math.floor(100 * $gameActors.actor(3).pha)
Eval: Math.floor(100 * $gameActors.actor(3).mcr)
Eval: Math.floor(100 * $gameActors.actor(3).tcr)
Eval: Math.floor(100 * $gameActors.actor(3).pdr)
Eval: Math.floor(100 * $gameActors.actor(3).mdr)
Eval: Math.floor(100 * $gameActors.actor(3).fdr)
Eval: Math.floor(100 * $gameActors.actor(3).exr)

The variable will return a value of Actor 3’s special parameters: Target rate, Guard rate, Recovery rate, Pharmacology, MP Cost, TP Charge, Physical Damage rate, Magical Damage rate, Floor Damage rate, Experience rate values. These values are originally decimals, but this will return them as whole numbers multiplied by 100 and then rounded down.
Possible Use: Can be used for an event that occurs once the actor’s specific special parameter reached a certain point. For example, having a high enough Guard Rate to tank an incoming evented hit.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: Math.floor(100 * $gameActors.actor(4).elementRate(10))

The variable will return a value of Actor 4’s affinity towards element 10. This value is originally a decimal, but this will return the value as a whole number multiplied by 100 and then rounded down. If a number is under 100, the actor is resistant towards the element. If the number is above 100, the actor is vulnerable towards the element.
Possible Use: Can be used for an event to determine a different outcome. If an actor had fire resistance, he/she may be able to survive a burning house collapsing on him/her.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: Math.floor(100 * $gameActors.actor(5).stateRate(20))

The variable will return a value of Actor’s vulnerability towards state 20. This value is originally a decimal, but this will return the value as a whole number multiplied by 100 and then rounded down. If a number is under 100, the actor is resistant towards the state. If the number is above 100, the actor is vulnerable towards the state.
Possible Use: Can be used for an event to determine a different outcome. If an actor has a vulnerability towards a certain state, that actor may become food poisoned.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: Math.round($gameParty.agility())

The variable will return a value of the party’s average AGI value rounded.
Possible Use: An event branch possibility where the party may be able to outrun the enemies pursuing them depending on their agility values.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.leader().actorId()

The variable will return a value of the party leader’s actor ID.
Possible Use: This can be useful for certain events that may have different reactions depending on who your party leader is at the time.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.aliveMembers().length
Eval: $gameParty.deadMembers().length

The variable will return a value of the number of alive or dead members in the current party.
Possible Use: This can be used in events to get a headcount of the number of casualties done after a certain battle.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.highestLevel()

The variable will return a value of the party’s current highest level member’s level. In battle, this will refer to the active party in action. Outside of battle, it pertains to any of the members in the active party or reserve party.
Possible Use: This can be used to gauge the difficulty of a battle that may be coming up for the player to face.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.gold()

The variable will return a value of party’s exact amount of gold.
Possible Use: This can be used in some event’s pages to make bags of gold appear in the player’s HQ to show just how rich the player is.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.steps()

The variable will return a value of the amount of steps the player has walked.
Possible Use: This can be used in ways where a trophy may appear in the player’s HQ depending on how many steps the player has walked.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Eval: $gameParty.numItems($dataItems[1])
Eval: $gameParty.numItems($dataWeapons[2])
Eval: $gameParty.numItems($dataArmors[3])

The variable will return a value of the actual number of items as the condition instead of whether or not the party has that item. For weapons and armors, this will not include those that are equipped.
Possible Use: This can be used to determine the sprite used when detecting the quantity of a certain item the player has.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –


Happy RPG Making!


 

Happy RPG Making!


These plugins and Tips & Tricks ideas are made possible thanks to our creative patrons on Patreon! The majority of our Tips & Tricks, Plugins, and Lunatic Pack ideas are placed within the Patreon-exclusive Sample Project for quick and easy access! If you'd like to make a Plugin Suggestion, Yanfly's Patreon-based Suggestion Box a visit here:


If you have any bugs to report, visit the following link:


If you have any questions about Action Sequences, visit the following link:



Thank you!