Jump to content


Photo

Checking Equipped Weapon's Type

equipped equip weapon type event script

  • Please log in to reply
1 reply to this topic

#1 pinkies

pinkies

    Newbie

  • Members
  • 3 posts
  • Primarily UsesN/A

Posted 23 May 2012 - 09:11 PM

(Sorry if this isn't the right place for this- I wasn't quite sure since it's using both events and scripts, but in this case since it's the script specifically that's causing me problems...)

So, I'm trying to have an event check to see what type of weapon the user has equipped- ie, whether it's a sword, an ax, or any other type- and proceed from there according to the type equipped. The problem is that the conditional branch menu only can check for *specific* weapons, not types, and I'm going to have way too many weapons to try to check them one by one.
I figured I'd just use the script option in event commands. In the class Game_Actor, I found the method wtype_equipped?(wtype_id). Copying it down real quick...:

#--------------------------------------------------------------------------
# * Determine if Specific Type of Weapon Is Equipped
#--------------------------------------------------------------------------
def wtype_equipped?(wtype_id)
weapons.any? {|weapon| weapon.wtype_id == wtype_id }
end

It sounds like it's just what I need. Problem is, I don't know what class to use with it. I've tried different things, and I'm currently at:

if $game_actors[0].wtype_equipped?(1)
$game_variables.[]=(2, 1)
else
$game_variables.[]=(2, 0)
end

In the script box for that event. So, right now I'm just trying to get it to check and see if you have any of the axes equipped, and if so, change variable2 to 1; if you don't have an ax equipped, change variable2 to 0. However, $game_actors[0] isn't working for the script, and I don't know what I should have in its place. Any ideas?

#2 Reyx

Reyx

    Cookie-Croc

  • Members
  • 9 posts
  • Primarily UsesRMVX Ace
  • First LanguageGerman

Posted 08 June 2012 - 03:57 PM

The if-statement itself seems to be correct so far except that you should not check for $game_actors[0] since this usually will be nil.
Maybe it's far better to use $game_party.members[n] instead of $game_actors[n].

But you use $game_variables a bit wrong.
This will set variable 2 to value 1:
$game_variables[2] = 1

If you want to check for any party member equipped with type 1 this may help
if $game_party.members.any?{|actor|
actor.wtype_equipped?(1)}
$game_variables[1] = 2
end

Hope I could help :)





Also tagged with one or more of these keywords: equipped, equip, weapon, type, event, script

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users