Weapon Type Conditions

● ARCHIVED · READ-ONLY
Started by TheObermotz1 9 posts View original ↗
  1. Sorry for troubling you folks, but I've run into a problem, I can't solve on my own.
    The situation is the following:

    In my current project I want to include crates/chests that have to be pried open, before they can be lootet. The way it's supposed to work, is a condition checking if anyone in the party has any 'light weapons' or 'heavy weapons' (those are some of my weapon types) equipped and then either open the crate/chest or telling the player, that they need an appropriate weapon.
    It shouldn't matter, who is carrying the weapon (as long as it's somebody in the current party) or what exact weapon it is (as long as it's a 'light weapon' or 'heavy weapon').

    However, the vanilla conditions can only check if a certain character is carrying a certain weapon (instead of a weapon type).

    If anyone knows a way around this, i'd be much obliged. A script that activates a switch, if a weapon is being equiped could do the trick, but I'm open to every kind of suggestion.
  2. Most likely you have to use conditional branches instead of conditions.
    That means the event is always triggered and then checks for every actor in the party if one of those weapons is equipped.

    Most likely that will require a script line, but you can check what is possible in game data section of control variables as well - sometimes you can load the data you want into a variable there and then check the variable.
    I have no RM near to check unfortunately.
  3. You can use this script in the script box of a conditional to check if an actor has weapon type x equipped.

    $game_actors[id].equips[0].wtype_id == x

    If you want to check by party member's index instead of actor id this should work:

    $game_party.members[index].equips[0].wtype_id == x
  4. robhav said:
    $game_party.members[index].equips[0].wtype_id == x

    That certainly looks promising. However, I have trouble getting it to work; it makes the game crash.

    Script 'Game_Interpreter' line 450: NoMethodError occured.
    undefined method 'equips' for nil:NilClass


    Am I doing something wrong?
  5. Yeah, I should have mentioned that you need to check if they have anything equipped at all. If they don't have any weapon at all equipped that will happen. This should work. This is for the first party member. Index 0.

    $game_party.members[0].equips[0] && $game_party.members[0].equips[0].wtype_id == x
  6. robhav said:
    $game_party.members[0].equips[0] && $game_party.members[0].equips[0].wtype_id == x

    Ah, yes. Now we're getting somewhere. But two problems came up:

    1. A chain of conditions with your skript (with Index 0-3 for all 4 party members) still crashes the game, if there are less than 4 members in the party. The same goes for a chain that only counts for 3 party members, with a party without 3 members.

    2. The chain of conditions (just a long 'if-else' chain) still only checks the first party member and ignores the rest. Party members 2, 3 & 4 could be armed to the teeth, but the crate only cares if the leady carries a weapon.

    I'm not used to working with skripts in RPG Maker, so I'd be much obliged if you could help me out one more time.
  7. What you should do is set a variable to the number of party members. Like this:

    $game_party.members.count

    Then make a loop variable equal to 0. Then you have to use the loop variable in place of the party member index. It would be like this for game variable 19 as loop variable:

    $game_party.members[$game_variables[19]].equips[0] && $game_party.members[$game_variables[19]].equips[0].wtype_id == 2

    Add 1 to loop variable for each iteration and when the loop variable is equal to the members.count variable, break loop.

    Here's a link to an example, though some is cut off. Assuming the link works.

    https://photos.app.goo.gl/EWneDHBV7Vg1A8Bn9
  8. I would actually do this in a conditional branch:
    Code:
    !($game_party.members.select { |m| m.equips[0] && m.equips[0].wtype_id == 2 }).empty?

    If you just want to check the battle members, you can do:
    Code:
    !($game_party.battle_members.select { |m| m.equips[0] && m.equips[0].wtype_id == 2 }).empty?

    Basically, that iterates through each member of the party and checks whether they have a weapon equipped and if said weapon has a weapon type ID of 2. Much neater in my opinion.
  9. Why not like this? (If you want ANY of party members has wtype = 2)
    Code:
    $game_party.members.any? { |m| m.equips[0] && m.equips[0].wtype_id == 2 }
    or (If you want ALL of party members has wtype = 2)
    Code:
    $game_party.members.all? { |m| m.equips[0] && m.equips[0].wtype_id == 2 }
    *adding more confusion*