Lock equipment

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
Master324
Slime
Posts: 3
Joined: Mon Jul 10, 2017 4:15 pm

Lock equipment

Post by Master324 »

I would like to know if there is a way to prevent the player from changing/removing a certain hero's equipment. I checked the FAQ on the wiki and the plotscripting dictionary but I couldn't find anything useful, so I thought I would ask here.
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

Post by marionline »

In the Item menu there is the "consumed by use" bitset, press arrow key right and you can change it to "Cannot be Sold/Dropped".
Master324
Slime
Posts: 3
Joined: Mon Jul 10, 2017 4:15 pm

Post by Master324 »

well, yes I'm aware of that option, does it also stop the player from equipping that piece of equipment?
Last edited by Master324 on Tue Jul 11, 2017 5:30 am, edited 1 time in total.
User avatar
Pepsi Ranger
Liquid Metal Slime
Posts: 1457
Joined: Thu Nov 22, 2007 6:25 am
Location: South Florida

Post by Pepsi Ranger »

It's a little hacky, but you could set a tag called "equip locked on hero" or something like that, then "force equip" (plotscripting dictionary will tell you all about that command) the hero with that item with every step the tag is set. You can "unlock" the equipment by turning the tag off.

Pretty basic, kinda ugly, but it should work.
Place Obligatory Signature Here
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Hello!

There's no way to lock equipment, as you can with heroes. (But come to think of it, people actually ask about it a lot, so it would be a good idea to add it to the engine. It shouldn't be much work.)

There are a couple (not very good) workarounds for locking equipment:

-remove the Equip menu altogether when you want to lock any equipment
-replace the Equip option in the menu with a script which calls "equip menu" and then afterwards check if the player changed some equip you didn't want to. If so, revert the change and tell off the player. This is similar to what Pepsi Ranger suggested
-script your own equip menu instead of using the built-in one

However, you asked about locking all the equip for a specific hero, and that could be handled differently. Because it was really easy to do so, I've just added a new "allow switch" argument to the "equip menu" command which you can use to only allow the the player to access the equip menu for certain heroes, like so (this script would replace the Equip option in the menu):

Code: Select all

plotscript, equip menu replacement, begin
  variable(who)
  who := pick hero
  if &#40;who < 0&#41; then &#40;exit script&#41;  #cancelled
  if &#40;hero by slot&#40;who&#41; == hero&#58;defense robot&#41; then &#40;
    # disallow changing equip
    play sound &#40;sfx&#58;cancel&#41;
    exit script
  &#41;
  equip menu &#40;who, false&#41;
end
You can get that in nightly builds (from tomorrow), or wait for the next release (soon!)

However, this still isn't ideal, because it doesn't let you view the equipment of that hero.
Last edited by TMC on Tue Jul 11, 2017 7:33 am, edited 1 time in total.
Master324
Slime
Posts: 3
Joined: Mon Jul 10, 2017 4:15 pm

Post by Master324 »

Alright, thank you all for the ideas, I think i'll try Pepsi's workaround since it is important for my purposes that the player can still view the hero's equipment.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

It would be better to force the equipment immediately after leaving the equip menu, rather than on each step. Otherwise there are various things that can go wrong, for example the player can unequip something and then drop it or sell it. You also have to worry about them unequipping it and then equipping it to a different hero. Note that the forceequip command will equip an item regardless of whether it's in the inventory: if you don't have that item then it creates a new copy! So if the equipment in question can be equipped to anyone else, it seems that disallowing switching will save you some work scanning the equipment of the other heroes.

Note that to replace the Equip option with a script you have to either allow scripts to run on the main menu, or close the menu when selected.
Also, you can't replace Equip in shop menus with a script.
Last edited by TMC on Wed Jul 12, 2017 1:19 am, edited 1 time in total.
Post Reply