Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED]Haki's Status Effect Armor Script Edit

Problem
I'm using a script made by Haki that is supposed to add a status effect to selected armor. It removes the status effect when you unequip the piece of equipment. I've modified it to be used for every peice of armor not just chest. Also for weapons. My problem is if say I have a piece of armor that causes the status effect Poison. And an accessory that causes Poison. When I unequip one of those items it drops the status effect even though i'm still wearing on of the items that causes poison. Is there a simple work around for this? If not i'll just use the script for accessories only but it was a thought.

The Code


So without further ado here is the code...
Code:
class Game_Actor < Game_Battler
  
  ASSIGNED_STATUS = {11 => 17, 5 => 17} #Chest Armor => Status
  ASSIGNED_STATUS2 = {23 => 3} #Weapon_ID => Status_ID
  ASSIGNED_STATUS3 = {8 => 3} #Shield_ID => Status_ID
  ASSIGNED_STATUS4 = {10 => 3} #Helmet_ID => Status_ID
  ASSIGNED_STATUS5 = {9 => 3} #Accesory_ID => Status_ID
    def equip(equip_type, id)
    case equip_type
    when 0 
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
      if ASSIGNED_STATUS2[id] != nil
        add_state(ASSIGNED_STATUS2[id])
      else
        remove_state(ASSIGNED_STATUS[@weapon_id])
      end
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1 
      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)
      if ASSIGNED_STATUS3[id] != nil
        add_state(ASSIGNED_STATUS3[id])
      else
        remove_state(ASSIGNED_STATUS3[@armor1_id])
      end
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2
      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)
      if ASSIGNED_STATUS4[id] != nil
        add_state(ASSIGNED_STATUS4[id])
      else
        remove_state(ASSIGNED_STATUS4[@armor2_id])
      end
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3 
      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)
      if ASSIGNED_STATUS[id] != nil
        add_state(ASSIGNED_STATUS[id])
      else
        remove_state(ASSIGNED_STATUS[@armor3_id])
      end
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4
      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)
      if ASSIGNED_STATUS5[id] != nil
        add_state(ASSIGNED_STATUS5[id])
      else
        remove_state(ASSIGNED_STATUS5[@armor4_id])
      end
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end

Originally the code only had ASSIGNED_STATUS i added the 2-5, which works except for my above problem. I don't know if this script looks different on XP and VX so I'm using RMXP if that helps anyone out.

Special Thanks for whoever helps me with this issue.
 

Haki

Member

You could try this, let's say for weapon status:
Code:
    when 0 
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
      if ASSIGNED_STATUS2[id] != nil
        add_state(ASSIGNED_STATUS2[id])
      elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS5[@armor4_id] #Checking is done here. You can also add checking if any other ASSIGNED_STATUS values are different
        remove_state(ASSIGNED_STATUS[@weapon_id])
      end
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end

You will also need do a check for weapon, helmet, armor etc.
 
Perfect you are a god, THANKS!!!

EDIT:
Okay I thought that would work for sure just got home to my computer to test it out and now the status' won't go away when the item is unequipped. Here is the code i've got now. I just know its something simple i'm overlooking but here it is i guess it isn't making it through the elsif statements or something.

Code:
class Game_Actor < Game_Battler
  
  ASSIGNED_STATUS = {11 => 3, 5 => 17} #Chest Armor => Status
  ASSIGNED_STATUS2 = {23 => 3} #Weapon_ID => Status_ID
  ASSIGNED_STATUS3 = {8 => 3} #Shield_ID => Status_ID
  ASSIGNED_STATUS4 = {10 => 3} #Helmet_ID => Status_ID
  ASSIGNED_STATUS5 = {9 => 3} #Accesory_ID => Status_ID
    def equip(equip_type, id)
    case equip_type
    when 0 
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
      if ASSIGNED_STATUS2[id] != nil
        add_state(ASSIGNED_STATUS2[id])
      elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS5[@armor4_id]
      elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS3[@armor1_id]
      elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS4[@armor2_id]
      elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS[@armor3_id]
        remove_state(ASSIGNED_STATUS[@weapon_id])
      end
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1 
      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)
      if ASSIGNED_STATUS3[id] != nil
        add_state(ASSIGNED_STATUS3[id])
      elsif ASSIGNED_STATUS3[id] != ASSIGNED_STATUS5[@armor4_id]
      elsif ASSIGNED_STATUS3[id] != ASSIGNED_STATUS2[@weapon_id]
      elsif ASSIGNED_STATUS3[id] != ASSIGNED_STATUS4[@armor2_id]
      elsif ASSIGNED_STATUS3[id] != ASSIGNED_STATUS[@armor3_id]      
        remove_state(ASSIGNED_STATUS3[@armor1_id])
      end
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2
      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)
      if ASSIGNED_STATUS4[id] != nil
        add_state(ASSIGNED_STATUS4[id])
      elsif ASSIGNED_STATUS4[id] != ASSIGNED_STATUS5[@armor4_id]
      elsif ASSIGNED_STATUS4[id] != ASSIGNED_STATUS3[@armor1_id]
      elsif ASSIGNED_STATUS4[id] != ASSIGNED_STATUS2[@weapon_id]
      elsif ASSIGNED_STATUS4[id] != ASSIGNED_STATUS[@armor3_id]        
        remove_state(ASSIGNED_STATUS4[@armor2_id])
      end
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3 
      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)
      if ASSIGNED_STATUS[id] != nil
        add_state(ASSIGNED_STATUS[id])
      elsif ASSIGNED_STATUS[id] != ASSIGNED_STATUS5[@armor4_id]
      elsif ASSIGNED_STATUS[id] != ASSIGNED_STATUS3[@armor1_id]
      elsif ASSIGNED_STATUS[id] != ASSIGNED_STATUS4[@armor2_id]
      elsif ASSIGNED_STATUS[id] != ASSIGNED_STATUS2[@weapon_id]
        remove_state(ASSIGNED_STATUS[@armor3_id])
      end
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4
      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)
      if ASSIGNED_STATUS5[id] != nil
        add_state(ASSIGNED_STATUS5[id])
      elsif ASSIGNED_STATUS5[id] != ASSIGNED_STATUS3[@armor1_id]
      elsif ASSIGNED_STATUS5[id] != ASSIGNED_STATUS2[@weapon_id]
      elsif ASSIGNED_STATUS5[id] != ASSIGNED_STATUS4[@armor2_id]
      elsif ASSIGNED_STATUS5[id] != ASSIGNED_STATUS[@armor3_id]      
        remove_state(ASSIGNED_STATUS5[@armor4_id])
      end
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end
 

Haki

Member

Don't put elsif one below other. I belive you can use "and" like this:
Code:
if ASSIGNED_STATUS2[id] != nil
    add_state(ASSIGNED_STATUS2[id])
elsif ASSIGNED_STATUS2[id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS2[id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS2[id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS2[id] != ASSIGNED_STATUS[@armor3_id]
    remove_state(ASSIGNED_STATUS[@weapon_id])
end
 
/snaps fingers
That didn't work either, but I can still use your original script for accessories.

Explanation of why I wanted this.
I have an ore called Thorium, many may know this from WoW, but in my game its the Thorium from real world. Extremely durable yet slightly radioactive. So when you make items from this ore you have a 'Radiated' state. But i guess i'll just scrap that part. I can still do float, counterattack, and other items so still a great script Haki and thanks!
 

Haki

Member

I found out what's wrong.

It should look like this:
Code:
if ASSIGNED_STATUS2[id] != nil
    add_state(ASSIGNED_STATUS2[id])
elsif ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS[@armor3_id]
    remove_state(ASSIGNED_STATUS[@weapon_id])
end

All you needed to do was replace "id" with "@weapon_id" in the elsif line. I haven't tested it, however, so I'm not sure if it's gonna work.
 
Code:
class Game_Actor < Game_Battler
  
  ASSIGNED_STATUS = {11 => 3, 5 => 17} #Chest Armor => Status
  ASSIGNED_STATUS2 = {23 => 3} #Weapon_ID => Status_ID
  ASSIGNED_STATUS3 = {8 => 3} #Shield_ID => Status_ID
  ASSIGNED_STATUS4 = {10 => 3} #Helmet_ID => Status_ID
  ASSIGNED_STATUS5 = {9 => 3} #Accesory_ID => Status_ID
  
    def equip(equip_type, id)
    case equip_type
    when 0 
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
      if ASSIGNED_STATUS2[id] != nil
        add_state(ASSIGNED_STATUS2[id])
      elsif ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS2[@weapon_id] != ASSIGNED_STATUS[@armor3_id]
        remove_state(ASSIGNED_STATUS[@weapon_id])
      end
  @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1 
      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)
      if ASSIGNED_STATUS3[id] != nil
        add_state(ASSIGNED_STATUS3[id])
      elsif ASSIGNED_STATUS3[@armor1_id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS3[@armor1_id] != ASSIGNED_STATUS2[@weapon_id] and ASSIGNED_STATUS3[@armor1_id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS3[@armor1_id] != ASSIGNED_STATUS[@armor3_id] 
        remove_state(ASSIGNED_STATUS3[@armor1_id])
      end
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2
      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)
      if ASSIGNED_STATUS4[id] != nil
        add_state(ASSIGNED_STATUS4[id])
      elsif ASSIGNED_STATUS4[@armor2_id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS4[@armor2_id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS4[@armor2_id] != ASSIGNED_STATUS2[@weapon_id] and ASSIGNED_STATUS4[@armor2_id] != ASSIGNED_STATUS[@armor3_id]
        remove_state(ASSIGNED_STATUS4[@armor2_id])
      end
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3 
      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)
      if ASSIGNED_STATUS[id] != nil
        add_state(ASSIGNED_STATUS[id])
      elsif ASSIGNED_STATUS[@armor3_id] != ASSIGNED_STATUS5[@armor4_id] and ASSIGNED_STATUS[@armor3_id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS[@armor3_id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS[@armor3_id] != ASSIGNED_STATUS2[@weapon_id]
        remove_state(ASSIGNED_STATUS[@armor3_id])
      end
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4
      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)
      if ASSIGNED_STATUS5[id] != nil
        add_state(ASSIGNED_STATUS5[id])
      elsif ASSIGNED_STATUS5[@armor4_id] != ASSIGNED_STATUS3[@armor1_id] and ASSIGNED_STATUS5[@armor4_id] != ASSIGNED_STATUS2[@weapon_id] and ASSIGNED_STATUS5[@armor4_id] != ASSIGNED_STATUS4[@armor2_id] and ASSIGNED_STATUS5[@armor4_id] != ASSIGNED_STATUS[@armor3_id] 
        remove_state(ASSIGNED_STATUS5[@armor4_id])
      end
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end

EDIT: OMG! I had two of the same status in one line and that is what was causing my problem! Sorry for the inconvience Haki and thanks for all your help in this huge edit!

This topic is now complete.

For any who want this script this is the complete working version.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top