Author Topic: Auto-States for Weapons  (Read 1415 times)

Offline AresWarrior

  • Awakened Visionist
  • **
  • Posts: 51
  • LV: 3
    • View Profile
Auto-States for Weapons
« on: April 28, 2010, 04:27:59 AM »
In RPG Maker XP, there is no option to add an Auto-State to weapons. Well with this little script, you can.
(An Auto-State is a state that affects the user of the weapon.)

In the Scene_Battle 2 script, under @phase = 1, add this:

Code: [Select]
    # Weapon Auto-State
    if $game_party.actors.size >= 1
    if $game_party.actors[0].weapon_id == WEAPON_ID
      $game_party.actors[0].add_state(STATE_ID)
    end
    end
    if $game_party.actors.size >= 2
    if $game_party.actors[1].weapon_id == WEAPON_ID
      $game_party.actors[1].add_state(STATE_ID)
    end
    end
    if $game_party.actors.size >= 3
    if $game_party.actors[2].weapon_id == WEAPON_ID
      $game_party.actors[2].add_state(STATE_ID)
    end
    end
    if $game_party.actors.size == 4
    if $game_party.actors[3].weapon_id == WEAPON_ID
      $game_party.actors[3].add_state(STATE_ID)
    end
    end
^^Change WEAPON_ID to the weapon that gives the state. Change STATE_ID to the state that the weapon gives. For each of the $game_party.actors, the IDs have to be the same if you want it to work. So if I wanted to make weapon #44 inflict state #55 then it would look like:
Code: [Select]
    # Weapon Auto-State
    if $game_party.actors.size >= 1
    if $game_party.actors[0].weapon_id == 44
      $game_party.actors[0].add_state(55)
    end
    end
    if $game_party.actors.size >= 2
    if $game_party.actors[1].weapon_id == 44
      $game_party.actors[1].add_state(55)
    end
    end
    if $game_party.actors.size >= 3
    if $game_party.actors[2].weapon_id == 44
      $game_party.actors[2].add_state(55)
    end
    end
    if $game_party.actors.size == 4
    if $game_party.actors[3].weapon_id == 44
      $game_party.actors[3].add_state(55)
    end
    end

I know this script isn't much, but it can help a lot if you want weapons with special effects. (ie. Sharp Claw: Gives the user Sharpness.)
or if you simply want an animation to appear while wearing a certain weapon. (ie. a Gold Sword would show glowing animation)

Side Note: I know the script looks messy. I don't know how to make it look nice like "case blahblahblah when 1 then 2" etc.
« Last Edit: April 28, 2010, 05:03:09 AM by AresWarrior »

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: Auto-States for Weapons
« Reply #1 on: April 29, 2010, 12:32:36 AM »
There is a much easier way of doing this. And it'll be easier to configure. In fact if you don't mind I'm gonna make a small script real quick.

Offline AresWarrior

  • Awakened Visionist
  • **
  • Posts: 51
  • LV: 3
    • View Profile
Re: Auto-States for Weapons
« Reply #2 on: May 02, 2010, 05:44:23 AM »
i dont mind. i'd want to see a better looking script than mine cuz its too much work to insert the same id numbers for each battler.