Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Heretic86

Equip Weapons and Armors with a Script - XP

Question

XP - how do I equip with a Script? Isn't it something like Player.weapon(1).equip or something similar to that?

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

It's more like actor.equip(someparameter, anotherparamter) or something like that.

 

But you can just use the event command Change Equipment.

Share this post


Link to post
Share on other sites
  • 0

What are you doing exactly, creating a Scene or calling a script.

 

and I thought it was:

@actor.equip(@right_window.index, item == nil ? 0 : item.id)

 

which what I got from Scene_Equip on line: 227

Share this post


Link to post
Share on other sites
  • 0

kiri and Bigace are right,

 

This is the method you are looking for, in Game_Actor:

class Game_Actor
 #--------------------------------------------------------------------------
 # * Change Equipment
 #     equip_type : type of equipment
 #     id    : weapon or armor ID (If 0, remove equipment)
 #--------------------------------------------------------------------------
 def equip(equip_type, id)
   case equip_type
   when 0  # Weapon
     if id == 0 or $game_party.weapon_number(id) > 0
       $game_party.gain_weapon(@weapon_id, 1)
       @weapon_id = id
       $game_party.lose_weapon(id, 1)
     end
   when 1  # Shield
     if id == 0 or $game_party.armor_number(id) > 0
       update_auto_state($data_armors[@armor1_id], $data_armors[id])
       $game_party.gain_armor(@armor1_id, 1)
       @armor1_id = id
       $game_party.lose_armor(id, 1)
     end
   when 2  # Head
     if id == 0 or $game_party.armor_number(id) > 0
       update_auto_state($data_armors[@armor2_id], $data_armors[id])
       $game_party.gain_armor(@armor2_id, 1)
       @armor2_id = id
       $game_party.lose_armor(id, 1)
     end
   when 3  # Body
     if id == 0 or $game_party.armor_number(id) > 0
       update_auto_state($data_armors[@armor3_id], $data_armors[id])
       $game_party.gain_armor(@armor3_id, 1)
       @armor3_id = id
       $game_party.lose_armor(id, 1)
     end
   when 4  # Accessory
     if id == 0 or $game_party.armor_number(id) > 0
       update_auto_state($data_armors[@armor4_id], $data_armors[id])
       $game_party.gain_armor(@armor4_id, 1)
       @armor4_id = id
       $game_party.lose_armor(id, 1)
     end
   end
 end
end

 

All current actors in the party are stored in the Game_Party class, to access these actor objects:

$game_party.actors[index]

the global variable $game_party is the current party object and .actors is the array storing each actor in the party. So, let's say you want to equip the party member in the first position:

$game_party.actors[0].equip( equip_type, id )

equip_type being a number from 0-4

0: Weapon slot

1: Armor 1 slot

2: Armor 2 slot

3: Armor 3 slot

4: Armor 4 slot

 

id being the id no. of the weapon/armor in the database

Share this post


Link to post
Share on other sites
  • 0

Thanks guys! That helps immensely! Mostly just playing around right now, waiting impatiently for the contest, so focusing on understanding the scripting langauge better.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...