Lock equipment
Moderators: marionline, SDHawk
Lock equipment
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.
- marionline
- Metal Slime
- Posts: 673
- Joined: Sat Feb 26, 2011 9:23 pm
- Pepsi Ranger
- Liquid Metal Slime
- Posts: 1457
- Joined: Thu Nov 22, 2007 6:25 am
- Location: South Florida
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.
Pretty basic, kinda ugly, but it should work.
Place Obligatory Signature Here
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):
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.
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 (who < 0) then (exit script) #cancelled
if (hero by slot(who) == hero:defense robot) then (
# disallow changing equip
play sound (sfx:cancel)
exit script
)
equip menu (who, false)
end
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.
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.
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.