Status
Not open for further replies.

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
63
Reaction score
4
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
37,039
Reaction score
10,033
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
4
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
4
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,869
Reaction score
1,926
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
4
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
512
Reaction score
219
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,385
Reaction score
1,214
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,945
Reaction score
6,305
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 Profile Posts

By far, the weirdest flex I've ever seen on the internet is "I don't have the attention span to read what you wrote, but I REALLY want the world to know I don't have that attention span!".
Why... the FACK... do I work in customer service?!?!
Excuse me while I go question allllll my life choices.
DamageEvil_6.png added!
index.php

Sometimes I wonder why I still try and recruit others to help with my games. It never works.

Forum statistics

Threads
125,777
Messages
1,173,412
Members
164,930
Latest member
alantangyl
Top