The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: CDA on January 31, 2012, 07:20:35 PM

Title: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: CDA on January 31, 2012, 07:20:35 PM
This seems like something that has probably been answered before.
But searching here and on google comes up with a whole bunch of shop related things that I already know.  ::)

Anyway, in my game I've got characters using the two sword style and their second weapon is actually important and cannot be un-equipped.

But when I go to buy a weapon from a shop, it displays how much better the weapon is than my weapon in the weapon 2 slot, that doesn't work for my game.

I was told that the engine does not differentiate between Weapon 1 or 2 and that the only way I could get it to show Weapon 1 and only Weapon 1 was through a script.

Thanks for reading and I hope you can help.
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: modern algebra on January 31, 2012, 11:57:50 PM
What maker is this for? VX or VXA?
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: CDA on February 01, 2012, 07:46:18 AM
VX, so RGSS2.

Thanks.
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: modern algebra on February 01, 2012, 09:02:56 PM
Try pasting the following code into its own slot, below Materials but above Main.


class Window_ShopStatus
  def weaker_weapon(actor)
    return actor.weapons[0]
  end
end


Mind you, that would always return weapon 1 for all actors, even if you had another dual wielding actor where you want the shop to actually show the weaker weapon. If you wanted it so that the restriction only applied to a particular actor, you could do something like this:


class Window_ShopStatus
  alias cdarulez_weakwep_3ed7 weaker_weapon
  def weaker_weapon(actor, *args, &block)
    if actor.id == 1
      return actor.weapons[0]
    else
      cdarulez_weakwep_3ed7(actor, *args, &block)
    end
  end
end


And you would change the

if actor.id == 1

line to the ID of the actor with the unreplacable second weapon, so if that was actor 1, the above would be fine, but if it was actor 5, then the line would need to be:

if actor.id == 5
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: CDA on February 01, 2012, 11:14:52 PM
Beautiful, works perfectly.

Thanks MA.  :lol:
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: LoganF on February 01, 2012, 11:37:56 PM
Since there's a hint that there might be more than 1 character with this particular requirement, and to save having to make if/elsifs for each actor, i figured it might be worth having a quicker way of handling that:


class Window_ShopStatus
  alias cdarulez_weakwep_3ed7 weaker_weapon
  def weaker_weapon(actor, *args, &block)
    if [1, 5].include?(actor.id)
      return actor.weapons[0]
    else
      cdarulez_weakwep_3ed7(actor, *args, &block)
    end
  end
end


Then it's just a matter of putting in the desired actor id's in the array (between the square brackets) in this line:


if [1, 5].include?(actor.id)


So here we have actors 1 and 5 set to have their 2nd weapon not being used as wanted. If you wanted actors 2 and 4 instead, you would change [1, 5] to [2, 4]. If you wanted to have actors 2, 4 and 7 it would be [2, 4, 7], and so on.

Of course, if there is only 1 actor using this unchangeable 2nd weapon, then you'd only need modern's version. This just lets you use as many actors as you want without having to do the extra repeating leg work.
Title: Re: Weapon Shop Display (Weapon 1 instead of Weapon 2)
Post by: CDA on February 24, 2012, 03:04:44 PM
Thanks Logan :) But MA script on it's own covers my needs.

But thanks anyway ;)