Main Menu
  • Welcome to The RPG Maker Resource Kit.

Weapon Shop Display (Weapon 1 instead of Weapon 2)

Started by CDA, January 31, 2012, 07:20:35 PM

0 Members and 1 Guest are viewing this topic.

CDA

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.

modern algebra


CDA


modern algebra

#3
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

CDA


LoganF

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.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

CDA

Thanks Logan :) But MA script on it's own covers my needs.

But thanks anyway ;)