mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
59 lines
2.0 KiB
Java
Executable File
59 lines
2.0 KiB
Java
Executable File
package script.item.medicine;
|
|
|
|
import script.library.healing;
|
|
import script.library.utils;
|
|
import script.*;
|
|
|
|
public class enhancer extends script.base_script
|
|
{
|
|
public enhancer()
|
|
{
|
|
}
|
|
public static final string_id CANNOT_USE_ITEM = new string_id("base_player", "cannot_use_item");
|
|
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
|
|
{
|
|
if (canManipulate(player, self, true, true, 15, true))
|
|
{
|
|
menu_info_data mid = mi.getMenuItemByType(menu_info_types.ITEM_USE);
|
|
if (mid != null)
|
|
{
|
|
mid.setServerNotify(true);
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
|
{
|
|
if (utils.getContainingPlayer(self) != player || !hasObjVar(self, "commandName"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
String command = getStringObjVar(self, "commandName");
|
|
if (!hasCommand(player, command))
|
|
{
|
|
healing.sendMedicalSpam(player, CANNOT_USE_ITEM, COMBAT_RESULT_MEDICAL);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (item == menu_info_types.ITEM_USE)
|
|
{
|
|
int commandCrc = getStringCrc(toLower(command));
|
|
queueCommand(player, commandCrc, getLookAtTarget(player), "" + self, COMMAND_PRIORITY_NORMAL);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
|
|
{
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
if (idx == -1)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (hasObjVar(self, "healing.enhancement"))
|
|
{
|
|
names[idx] = "enhancer_power";
|
|
attribs[idx] = Double.toString(Math.floor(getFloatObjVar(self, "healing.enhancement")));
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|