Status
Not open for further replies.

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
63
Reaction score
3
First Language
English
Primarily Uses
RMVXA
The way my game works is that there is no standard equipment, instead each piece of equipment serves a special purpose and can be equipped in a specific slot. The result of this is that I want players to try and figure out the best equipment for each character on their own, which also means I want each piece of equipment to only work on one actor at a time.

For example, using example terms, Tim cannot equip a Red Hat if Jerry is already wearing a Red Hat, but if Jerry takes off the Red Hat, anyone, including Tim, can now wear it. The only piece of equipment that isn't like this, is a really cheap 10% defense increase body armor.

What I need is a script that allows me to limit equipment to only be worn by one actor at a time, with probably an array of excluded equipment ids that work as normal.

Thanks in advance.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,236
Reaction score
9,681
First Language
German
Primarily Uses
RMMV
no need for a script if you simply give out only one of each equipment in total.
then the player has to unequip it from an actor before he can equip it on another one.

you only have to make manual shops instead of default shops and no longer offer something to purchase if it is already owned by the party.

no need for any script at all.
 

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
63
Reaction score
3
First Language
English
Primarily Uses
RMVXA
no need for a script if you simply give out only one of each equipment in total.
then the player has to unequip it from an actor before he can equip it on another one.

you only have to make manual shops instead of default shops and no longer offer something to purchase if it is already owned by the party.

no need for any script at all.
Much easier suggested said than done. Some enemies can drop equipment, which allows for it to be acquired repeatedly. The game is essentially done, save for stuff like needing this script, so re-adjusting every single shop (which already use another script to function) wouldn't be viable. This also includes the pre-existing save files that are hours into the game already in possession of multiple of each equipment type that my playtesters have. If I could get a simple script that just stops the same equipment from being equipable on multiple actors, this wouldn't be an issue anymore.
 

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
63
Reaction score
3
First Language
English
Primarily Uses
RMVXA
also still easier than making a script to control this.
I managed to, after looking around, figure out how to make the script myself. It works. I have no idea why it was being treated like an impossibility. Retooling my entire game vs writing like, only like, 17 lines of code doesn't seem like a fair fight. Sure it's not optimally coded, as I only know slightly understand how it all works, but it functions as intended.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,767
Reaction score
1,826
First Language
Spanish
Primarily Uses
RMVXA
window_equipitem object.
look at .include?(item) and .enabled?(item)
those are the two methods you have to override, and nothing else.
 

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
63
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Ruby:
#  credit goes to Trihan for providing me with an idea as to how this works.
#
#  i recognize this is not optimal code, nor the optimal solution, but it's
#  better than nothing. i barely know how coding optimally would look or work,
#  but i'm sharing this so anyone with my problem won't be burdoned by finding
#  a thread about their issue with no solution in it.

Game_Actor.class_eval do
  alias_method(:grig_change_equip, :change_equip)
  def change_equip(slot_id, item)
    a = 1
    4.times do
      if item != nil && slot_id != 0 && item.id != 1
        if $game_actors[a].equips.include?($data_armors[item.id])
          return
        end
      end
        a += 1
    end 
    grig_change_equip(slot_id, item)
  end
end
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
463
Reaction score
196
First Language
English
Primarily Uses
RMXP
At first glance this is how the code should look like...

Ruby:
class Game_Actor
  alias_method(:grig_change_equip, :change_equip)
  def change_equip(slot_id, item)
    4.times do |n|
      if item != nil && slot_id != 0 && item.id != 0
        if $game_actors[n+1].equips.include?($data_armors[item.id])
          return
        end
      end
    end 
    grig_change_equip(slot_id, item)
  end
end

But there is a problem with it. Why should it check every single Actor ID starting at 1? I mean, if Actor #1 has equipment n and Actor #2 is about to equip the same piece of equipment, why shouldn't it let him do so at will?

There is also a problem with slot_id 0. Why can't any actor equip anything in his very first slot?

Since I am not looking at the original code, I would just suggest the following snippet might be a better solution to your issue.

Ruby:
class Game_Actor
  alias_method(:grig_change_equip, :change_equip)
  def change_equip(slot_id, item)
    if item != nil && item.id != 0
      return if $game_actors[n+1].equips.include?($data_armors[item.id])
    end 
    grig_change_equip(slot_id, item)
  end
end
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
this is how the code should look like
I like how you are able to optimize code so well.
I will continue to try and learn from your examples.
Thank you.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,694
Reaction score
6,161
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_6_24_2022_9_20_7.png
Here's Mike when you get a preemptive strike in battle. There's another one for when an enemy sneaks up on you too.
Suddenly, games mean nothing. The money spent was worth it to bring souls towards the light of life. May God bless my path forever. I pray that all are shaken for truth and poured out flat on the table of true understanding, knowledge, and wisdom. Bless you.
Finally I bought OMORI...cant wait to get traumatised!!!
Finished making this pretty ambitious forest map. Was wondering what y'all think of it! :kaopride:
1656136876015.png
All this anger everywhere,Who's happy but me?
Seems to be all the people that don't follow Jesus wholeheartedly. My smile might burn you ahhhhhhhhhhh!

Forum statistics

Threads
123,021
Messages
1,153,446
Members
161,363
Latest member
jereDev
Top