ANY numbers you key in should NOT have leading zeros -
e.g. map numbers, event numbers, variable/switch numbers.
(E.g. Don't type EV002, just type in 2)
Special Thanks and Credits!
Shaz for handling all my questions and missing functions!
Galv for taking time to figure out script call commands with me!
Yami for helping me find some missing functions and teaching about damage formulas which got referenced here!
Everyone in the Script Call Thread for the amazing script calls! (http://forums.rpgmakerweb.com/index.php?/topic/6248-script-call-equivalent-of-events/)
RMRK.Net for alternative Script Calls! (http://rmrk.net/index.php/topic,48189.0.html)
GrandmaDeb and everyone for reminding me that this should be done.
Check this thread as well! (http://forums.rpgmakerweb.com/index.php?/topic/25040-ace-useful-script-call-reference/)
Title: Re: Script Call Collection
Post by: Nessiah on April 05, 2014, 12:09:49 PM
params = [] choices = [] choices.push("choice 1") choices.push("choice 2") params.push(choices) params.push(0/1/2 this part is where you press cancel and which choice to default) setup_choices(params)
# For Single Actor # ---------------------------------------------- actor = $game_actors[id] if !actor.dead? actor.change_hp(value, enable_death) actor.perform_collapse_effect if actor.dead? end
# For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| next if actor.dead? actor.change_hp(value, enable_death) actor.perform_collapse_effect if actor_dead? }
# Where id (in the first one) is the id of the single actor # value is the change to make (a positive or negative amount to be added to the current hp) # 5 will make someone with HP 10 go to 15 # -5 will make someone with HP 10 go to 5 # so it's not SETTING the value, but adjusting it. # enable_death is true or false
# For Single Actor # ---------------------------------------------- $game_actors[id].mp += value
# For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| actor.mp += value }
# where id (in the first one) is the id of the single actor # value is the amount to change # You can also do -= or *= or /= instead of += ... that way you can keep value positive
# Add State For Single Actor # ---------------------------------------------- actor = $game_actors[id] already_dead = actor.dead? actor.add_state(state_id) actor.perform_collapse_effect if actor.dead? and !already_dead actor.result.clear
# Remove State For Single Actor # ---------------------------------------------- actor = $game_actors[id] actor.remove_state(state_id) actor.result.clear
# Add State For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| already_dead = actor.dead? actor.add_state(state_id) actor.perform_collapse_effect if actor.dead? and !already_dead } $game_party.clear_results
# Remove State For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| actor.remove_state(state_id) } $game_party.clear_results
where id (in the first two) is the id of the individual actor state_id is the id of the state you want to add or remove
# I'm working on the assumption that removing a state will NOT cause actor death. The interpreter script DOES do the # perform_collapse_effect if actor.dead? && !already_dead test even when removing a state. # LMK if you think that needs to be added in, and I'll adjust the state remove scriptlets.
# For Single Actor # ---------------------------------------------- $game_actors[id].change_exp(new_exp, show)
# For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| actor.change_exp(new_exp, show)
# where id (in the first one) is the id of the individual actor # show is true or false - if true, it will display a level up message and list new skills if the exp puts them past the current level # new_exp is what you want to SET the exp to (this is not an adjustment - if they have 50 and you want to add 10, you need to pass 60) # If you WANT to pass an adjustment, change this: new_exp # to this: actor.exp + value # where value is a positive or negative amount
# For Single Actor # ---------------------------------------------- $game_actors[id].change_level(new_level, show)
# For Entire Party # ---------------------------------------------- $game_party.members.each { |actor| actor.change_level(new_level, show)
# where id (in the first one) is the id of the individual actor # show is true or false (as above, for level up and skills messages) # new_level is the level you want to change them to (not an adjustment) # If you WANT to make an adjustment (give them all an extra level, not necessarily make them all the SAME new level), change this: new_level # to this: actor.level + value # where value is a positive or negative amount
$game_actors[id].change_equip_by_id(slot, equip) if $game_actors[id] # id is actor id # slot is the slot number (0=weapon, 1=shield, 2=head, 3=body, 4=accessory) # equip is the weapon or armor id
# Remove Actor by ID $game_party.remove_actor(actor_id)
# Remove Actor by Party Position partyMem = $game_party.members $game_party.remove_actor(partyMem[memPos].id)
# actor_id - Numerical identifier of actor within database. # memPos - Numerical identifier of actor within current party. 0 = 1st member, 1 = 2nd member, etc
# ---------------------------------------------- # Set a Value # ---------------------------------------------- $game_variables[n] = n
# ---------------------------------------------- # Set a Value to a batch of variables # ---------------------------------------------- (n..n).each { |i| $game_variables = value } # Example: (1..5).each { |i| $game_variables = 20 }
# Alternatively, you can use do (n..n).each do |i| $game_variables = value end # Example: (1..5).each do |i| $game_variables = 20 end
# ---------------------------------------------- # For operator references: # ---------------------------------------------- # Addition $game_variables[n] += n # Subtraction $game_variables[n] -= n # Multiply $game_variables[n] *= n # Division $game_variables[n] /= n # Modulus $game_variables[n] %= n # String (aka text) $game_variables[n] = "Insert string here!" # Another Variable $game_variables[n] = $game_variables[n]
# Variable References $game_variables[$game_variables[n]] = value
# Randomize $game_variables[n] = rand(value)
# Example for Randomize: # If you use rand(10) you get a number between 0-9 $game_variables[1] = rand(10) # To have negative values, put something like "*-5 + rand(11)" to get a number between -5 to 5 $game_variables[1] = (-5 + rand(11))
# ---------------------------------------------- # For Game Data References: # ----------------------------------------------
# Amount of Items in Inventory $game_variables[n] = $game_party.item_number($data_items[n]) # Example Usage: Amount of Potions in Inventory is going to be displayed Variable 1 $game_variables[1] = $game_party.item_number($data_items[1])
# Amount of Weapons in Inventory $game_variables[n] = $game_party.item_number($data_weapons[n])
# Amount of Armors in Inventory $game_variables[n] = $game_party.item_number($data_armors[n])
# Party Members Related # To reference who's in a particular position in the lineup, it's $game_variables[n] = $game_party.members[index].id # where index is the position (starting at 0 for the leader)
# To reference where someone is in the lineup, it's $game_variables[n] = $game_actors[id].index # where id is the actor id
# Actor Level $game_variables[n] = $game_actors[n].level # Actor HP $game_variables[n] = $game_actors[n].hp # Actor Max HP $game_variables[n] = $game_actors[n].mhp # Actor MP $game_variables[n] = $game_actors[n].mp # Actor Max MP $game_variables[n] = $game_actors[n].mmp # Actor Attack $game_variables[n] = $game_actors[n].atk # Actor Defense $game_variables[n] = $game_actors[n].def # Actor MagAtk $game_variables[n] = $game_actors[n].mat # Actor MagDef $game_variables[n] = $game_actors[n].mdf # Actor Agility $game_variables[n] = $game_actors[n].agi # Actor Luck $game_variables[n] = $game_actors[n].luk # Actor Pharmacology $game_variables[n] = $game_actors[n].pha
# Enemy Troop Stats (use this only in battle!) $game_variables[n] = $game_troop.members[index].stat # where stat = hp or mp or param(id) # where id = 0:MHP, 1:MMP, 2:ATK, 3:DEF, 4:MAT, 5:MDF, 6:AGI, 7:LUK [/code]
$game_self_switches[[map, event, 'self_switch']] = value
Map is either @map_id (for the current map) or a number without leading zeros for a map other than the current one event is either @event_id (for the current event) or a number for an event other than the current one (EV001 would be 1) self_switch is 'A', 'B', 'C' or 'D' (must have the single or double quotes) value is either true or false
For a better explanation of Conditional Branches, search the Help File for Control Structures. It will give you a better idea of how to use them and what kind of Control Structure to use.
# Basic Conditional Branch if put condition here # do stuff else # do stuff end
# Forked Conditions -- basically when you have a lot of conditions going on. if stuff here happens # do stuff elsif stuff happens here too! # do stuff elsif stuff happens again! # do stuff elsif stuff happens... # do stuff end
# ---------------------------------------------- # To set Vehicle Location # ---------------------------------------------- $game_map.vehicles[n].set_location(map_id, x, y) # n = [0] boat, [1] ship, [2] airship
# ---------------------------------------------- # To Refer Game Vehicles # ---------------------------------------------- $game_map.vehicles[n] $game_map.vehicles[n].x $game_map.vehicles[n].y # n = [0] boat, [1] ship, [2] airship
# To find a Vehicle's Map ID, you would need to add a accessor reader. # Add the following code in Script Editor: class Game_Vehicle < Game_Character attr_reader :map_id end
# or Edit Game_Vehicle and add attr_reader :map_id
Fiber.yield while $game_map.scrolling? # Add this if just the script call below doesn't work. $game_map.start_scroll(direction, distance, speed) # Direction = [2]Down [4]Left [6]Right [8]Up # Distance = How many tiles you want it to scroll # Speed = [1]8x Slower [2]4x Slower [3]2x Slower [4]Normal [5]2x Faster [6]4x Faster
move_route = RPG::MoveRoute.new move_route.repeat = false # This means the event will repeat the action move_route.skippable = true # This means the event will skip the move route if it's not possible m = RPG::MoveCommand.new m.code = 45 # The List of M Code can be found over Game_Character Default Script, this current m.code is call script m.parameters = ["script call here"] # This is if you use #45 in M.code # To show animation in move route just type animation_id = n, for balloons it's balloon_id = n move_route.list.insert(0,m.clone)
$game_player.force_move_route(move_route) # For Player $game_map.events[ID].force_move_route(move_route) # For Events
# ---------------------------------------------- # Other Move Route Options # ----------------------------------------------
# Single Action newCommand.code = moveCode # See List in Game_Character Default Script newCommand.parameters = [""] # This refers to Jump, Wait, Switch On, Switch Off, Change Speed, # Change Frequency, Change Graphic, Change Opacity, Play SE and Script. newRoute.list.insert(0,newCommand.clone)
# For Turning $game_map.events[eventid].set_direction(n) # For Events $game_player.set_direction(n) # For Players #Direction n = [2]Down [4]Left [6]Right [8]Up
# Changing Event Graphic $game_map.events[id].set_graphic("character_name", character_index) # id is the id of the event you want to change. # "character_name" is the name of the graphic file you want to change to (make sure to keep the quotation marks). # character_index is the index on the character sheet (it starts counting at 0).
screen.pictures[index].show(file_name, position, x, y, x zoom, y zoom, opacity, blend type) # position = [0] Top Left, [1] = Center # blend type = [0] Normal, [1] Add, [2] Sub
screen.pictures[n].move(position, x, y, x zoom, y zoom, opacity, blend type, wait) # position = [0] Top Left, [1] = Center # blend type = [0] Normal, [1] Add, [2] Sub
screen = $game_party.in_battle ? $game_troop.screen : $game_map.screen # The first line is not required screen.pictures[n].erase # if you're using this in an event on the map.
# type = :none, :rain, :storm, or :snow # power = Intensity of weather. If weather type is none (:none), set power (target value of intensity) # to 0 to represent gradual stopping of rain, but only in this case. # time = Specified time to fade weather in or out.
tone = Tone.new(R,G,B,Opacity) $game_map.screen.start_tone_change(tone, duration) wait(n) # Add these too to allow 'wait till the screen changes tint. n.to_i.times { Fiber.yield } # Number of frames to wait (1000 is equal to 1 second)
color = Color.new(R,G,B,Opacity) screen.start_flash(color, t) wait(t) # t = time # Example below: color = Color.new(255,255,25,100) screen.start_flash(color, 6) wait(6)
SceneManager.call(Scene_Name) SceneManager.scene.prepare(actor_id, chars) Fiber.yield # Actor ID = Actor ID, Chars = How many characters long the name can be.
# X and Y's # ---------------------------------------------- $game_player.x $game_player.y
$game_map.events[n].x $game_map.events[n].y # n = Event ID
# Check Terrain Tag # ---------------------------------------------- $game_map.terrain_tag(x, y) $game_player.terrain_tag $game_map.events[event_id].terrain_tag
# Check Region ID # ---------------------------------------------- $game_map.region_id(x, y) $game_player.region_id == n $game_map.events[event_id].region_id == n
# Check Map Name and Map ID # ---------------------------------------------- $game_map.name $game_map.map_id
# Check if Event is Near Player # ---------------------------------------------- $game_map.events[n].near_the_player?
# True/False. Distance for detection is 20 squares. # n = Event ID
# Event Change Graphic # ---------------------------------------------- $game_map.events[id].set_graphic("character_name", character_index) # id is the id of the event you want to change. # "character_name" is the name of the graphic file you want to change to (make sure to keep the quotation marks). # character_index is the index on the character sheet (it starts counting at 0).
# Actor Change Graphic # ---------------------------------------------- hero = $game_actors[ID] hero.set_graphic("characterset_filename", character_index, "Faceset_filename", faceset_index) $game_player.refresh # ID = Actor Index # character_index = Starts from 0 (Top Left), 1, 2, ... # faceset_index = Starts from 0 (Top Left), 1, 2, ...
# Add every Item/Skill/Weapon/Etc. without blank fields. # ---------------------------------------------- $data_items.each { |i| next if i.nil? or i.name == "" $game_party.gain_item(i, 99) } # Change $data_items to $data_weapons or something else and the amount you want.
# Use Items immediately # ---------------------------------------------- $game_actors[id].use_item($data_items[x]) $game_party.leader.use_item($data_items[x]) $game_party.members[index].use_item($data_items[x])
# Check Party Member Size # ---------------------------------------------- $game_party.members.size $game_party.all_members.size # If In Battle, use this instead. This checks the total size of your party (not just battlers).
# Checking Availability # ---------------------------------------------- $game_actors[X].equips.include?($data_weapons[Y]) # Checks if the actor X has weapon Y equipped $game_actors[X].equips.include?($data_armors[Y]) # Checks if the actor X has equipment (shield, armor, helmet or accessory) # Y equipped $game_actors[X].skills.include?($data_skills[Y]) # Checks if the actor X has learned skill Y $game_actors[X].states.include?($data_states[Y]) # Checks if the actor X is afflicted by status effect Y
$game_actors[actorid].skill_learn?($data_skills[skillid]) # If Player learned Skill. actorid and skillid are the ids from the database of # the actor and skill you're interested in. # It will return true if they have that skill, and false if they don't.
# Example Usage: # if xxx weapon type is the same as unless xxx == nil $game_actors[x].equips[y].wtype_id if $game_actors[x].equips[y]
# Check for Name/ID of Player Equipment # ---------------------------------------------- $game_actors[X].equips[Y].id unless $game_actors[X].equips[Y] == nil # Returns the ID of the equipment on actor X, equipped in slot Y $game_actors[X].equips[Y].name unless $game_actors[X].equips[Y] == nil # Returns the name of the equipment on actor X equipped in slot Y
# NOTE: If using any scripts that give or take equipment slots, the #Y is the number of the character's slot, # not the slot's number in the script. I.E. using Yanfly Equip Menu script - if your character has equipment # slots 6,7,8,15,15,32,75 available then $game_actors[1].equips[0].id would return the ID of the item equipped # in the slot defined as slot 6 in Yanfly script because it's the 1st equipment slot for the specific character.
# Checking Actors # ---------------------------------------------- $game_actors[X].name # Returns the name of the actor X $game_actors[X].nickname # Returns the nickname of the actor X $game_actors[X].class.id # Returns the ID of the actor X class $game_actors[X].class.name # Returns the name of the actor X class
$game_map.passable?(X, Y, D) $game_player.passable?(x, y, d) $game_map.events[event_id].passable?(x, y, d)
# $game_map.passable? only tells you whether you can leave one tile in the direction of the other. # The player and event versions take it further and tell you if you can leave that tile in the direction of the other # AND if you can enter the other tile from the tile you're on now (for example, if you are facing right and the tile # in front of you is the edge of a cliff that is higher than you - $game_map.passable? would tell you that you CAN # step right from the current tile. But $game_player.passable? would tell you that you could not move onto the next # tile from the left). It also looks to see if there is an event on your target tile which would stop you going there, # but $game_map.passable? would not tell you that.
# Q: I want to check the position of Player and compare with the position at side of Events. # ---------------------------------------------- # Variable [6] = Position X Player # Variable [7] = Position Y Player # Variable [8] = Position X Event # Variable [9] = Position Y Event
# If you only want them to be beside the event (positions 1 or 3), use this: $game_variables[7] == $game_variables[9] and ($game_variables[6] - $game_variables[8]).abs == 1 # which says if the y value is the same and there is a difference of 1 between the x values. # Note: abs = absolute value
# If you want them to be on any of the 4 numbered tiles, use this: ($game_variables[6] - $game_variables[8]).abs + ($game_variables[7] - $game_variables[9]).abs == 1 # which says there is a difference of 1 between the x values OR a difference of 1 between the y values # It is comparing the difference between the x position of the player and the tile of interest. # Using abs lets me take one away from the other in any order and still end up with a positive number - # it doesn't matter which has the # higher or lower x value. Then it does the same with the y position of # the player and the tile of interest. Then it adds them together (+ means plus, not and). # So if the sum of the x distance and the y distance between the two tiles is 1, it means the player is on # a tile that is directly touching the tile of interest (and not corner-ways, as then the sum of the numbers would be 2)
# Change an actor's equipment. # ---------------------------------------------- $game_actors[1].change_equip(n,$data_weapons[1]) # Change n with one of the following: # 0 = weapon, 1 = shield, 2 = headgear, 3 = body-gear (armor), 4 = accessory
# Check Conditional Branch: if [Actor] has [Weapon] Equipped # ---------------------------------------------- $game_actors[actor id].weapons.include?($data_weapons[weapon id]) right_hand = $game_actors[actor_id].equips[0] left_hand = $game_actors[actor_id].equips[1]
# To get the items. Replace the index in equips for the item you're looking for: # 0 = right hand, 1 = left hand, 2 = head, 3 = body, 4 = accessory # provided you're not using any scripts that change that. You can check their types with:
if right_hand.is_a?(RPG::Weapon) # do something elsif right_hand.is_a?(RPG::Armor) # do something else end
# Or get their properties with with: right_hand.id right_hand.name right_hand.icon_index right_hand.description # etc..
# Example: if you want to check if you have a Prinny Gun equipped on your first weapon slot: right_hand = $game_actors[actor_id].equips[0] if !right_hand.nil? && right_hand.name.eql?("Prinny Gun") # Do something end
# You don't even need to keep track of the IDs, really (unless you want to, for some reason). # If there's no way to not have a weapon equipped in your game, you can also take out the ".nil?" check.
# Currency unit set from the system tab: # ---------------------------------------------- $data_system.currency_unit
# Move Events and players by fractional squares # ---------------------------------------------- $game_map.events[ID].moveto(x, y) $game_player.moveto(x, y)
# Example of fractional squares $game_map.events[1].moveto(0, 5.5) $game_player.moveto(7.5, 3) end # The Collission box is still seen as 32x32
# Script Call Battle Logs! # ---------------------------------------------- # First add this scriptlet: class Scene_Battle < Scene_Base attr_accessor:log_window end
# To load your own battle logs SceneManager.scene.log_window.add_text("Insert custom text here") # It doesn't clear out and just stays there until something else replaces it. SceneManager.scene.log_window.wait # If you want it to clear make sure to use this. SceneManager.scene.log_window.wait_and_clear
# You can also do something like this! x = "Hi." x += " Hello." x += " This is getting long eh?" x += " Surely so long. wahahahahahaha" SceneManager.scene.log_window.add_text(x)
# or: y = SceneManager.scene.log_window y.add_text(text)
Title: Re: Script Call Collection
Post by: Nessiah on April 05, 2014, 12:12:20 PM
- Reserved -
Feel free to change stuff EXHydra or any admin that find some stuff wrong. (Please tell me when you do so I can update my copy too.)
Title: Re: Script Call Collection
Post by: yuyu! on July 27, 2014, 08:34:49 AM
I apologize if I skipped over the answer somewhere. ;9
Does anyone know if there's a specific way to call a variable (via conditional branch) and check if it is one of multiple values? Basically calling "$game_variables[2] == 1 or 10" (I don't think the "or" quite works, unless my testing skills fail that badly haha). Although, when I tried it with "or" it did run the event...for literally everyone no matter what, haha.
Spoiler for What I wants to do (because sometimes I suck at explaining):
I'm working on a game where you can play as many different characters of differing personalities, but writing all that dialogue is a pain in the buttocks. So, I've made it where (for the unimportant stuff) certain characters will say the same thing, usually grouped together by general personality traits.
Let's say I want Arthemes (#1), Diora (#6), and Elsie (#10) to say the same thing because they're all fairly calm and serious people.
Instead of having to call a ton of conditional branches like so:
[If] 2: Character # = 1 [If] 2: Character # = 6 [If] 2: Character # = 10 [Obligatory dialogue]
I could just do a conditional branch script call:
[If] $game_variables[2] == 1 or 6 or 10 [Obligatory dialogue]
If this is actually a thing, it'd be pretty awesome and really save on space and confusion, haha. If anyone knows if that's a proper call, please let me know. :)
Thanks again, everyone!
Title: Re: Script Call Collection
Post by: D&P3 on July 27, 2014, 01:07:50 PM
When using a conditional branch, with a script call:
Where '[1, 6, 10]' would be the numbers you are looking for, and are each separated by a comma. For Example: '[1, 4, 7, 12, 18]' would check the variable against those numbers to see if 'any?' of them matched up.
Title: Re: Script Call Collection
Post by: yuyu! on July 28, 2014, 12:49:07 AM
Oh wow, it worked perfectly!! Thank you so, so much! ^_^
This is going to save on a ton of space and make everything look a lot cleaner! ;_;