Jump to content
Wren

Custom Script to determine if a weapon type is equipped in the second weapon slot?

Recommended Posts

I'm looking for a script call to check if weapon type 20 is equipped in the weapon 2 slot of a character during battle.

 

Any help on this would be super appreciated and will get a credit in my game.

 

 

**Edit**

 

RPG::Weapon.wtype_id==20 or something like that?  Maybe?

Edited by Wren

Share this post


Link to post
Share on other sites

$game_actors[x].equips[1].wtype_id == 20

$game_actors[x].weapons[1].wtype_id == 20

both will give the weapon type but will return an error if the 2nd equip slot is empty or not a weapon so you will need to add a check before calling it.

eg if $game_actors[x].dual_wield? && !$game_actors[x].equips[1].nil?

Share this post


Link to post
Share on other sites

Okay, I set up a test to see if I could use this:

 

shieldcheck1_zpsc8f775c4.png

 

The following happened:

Game_Interpreterline4502_zps83433b28.png

 

Okay, I just remembered that !$game.actors[1].equips[1].nil? will be true if the second slot is not empty, thus the whole argument is that if the character is dual wield and the second is not empty, thus it would be true if anything is equipped in slot 2, I moved the other conditional branch up to above the else.

 

Same thing happened.

 

So then I was like, what if game.actor[0] was really #1 in the database, so changed the game.actor[1] to 0 and tried again:

 

It has an error at the same line but this time says 'undefined method 'dual_wield?' for nil:NilClass

Game_Interpreterline450_zps13031f83.png

 

So, basically stuck again.

 

I'll wait patiently as possible for any other suggestions or help if I have done something completely stupid and wrong.

Edited by Wren

Share this post


Link to post
Share on other sites

Yes, it works as long as they are dual wield and have that weapon equipped, if not, it returns the error above about wtype_id

 

Hmmm... must be a way to do this...

Edited by Wren

Share this post


Link to post
Share on other sites

Aha!

 

Okay, I have all my actors as dual wield.  I did it this way:

 

Conditional branch: Script: $game_actors[1].equips[1].nil?

@>

: Else

@> Conditional Branch: Script: $game_actors[1].weapons[1].wtype_id == 20

 

This works for if they have no weapon equipped in slot 2, because it exits before checking wtype

if they have a weapon there, it checks if it is type 20

 

booyah!

 

Thanks again both of you, you guys rock

 

Good to go on closing this thread.

 

Xypher, Mr, Trivel, you both get a credit on my game (not like Xypher hasn't already gotten credit, he's helped me like 100 million times)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×