Files
dsrc/sku.0/sys.server/compiled/game/script/item/medicine/stimpack_crafted.java
T
2020-05-08 11:35:47 +01:00

93 lines
3.1 KiB
Java
Executable File

package script.item.medicine;
import script.library.buff;
import script.library.healing;
import script.library.utils;
import script.*;
public class stimpack_crafted extends script.base_script
{
public stimpack_crafted()
{
}
public static final string_id SID_ITEM_LEVEL_TOO_LOW = new string_id("healing", "item_level_too_low");
public static final string_id SID_STIMPACK_TOO_SOON = new string_id("healing", "channel_heal_stimpack_too_soon");
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.power"))
{
names[idx] = "healing_power";
int value = getIntObjVar(self, "healing.power");
attribs[idx] = Integer.toString(value);
idx++;
if (idx >= names.length)
{
return SCRIPT_CONTINUE;
}
}
if (hasObjVar(self, "healing.combat_level_required"))
{
names[idx] = "healing_combat_level_required";
int value = getIntObjVar(self, "healing.combat_level_required");
attribs[idx] = Integer.toString(value);
idx++;
if (idx >= names.length)
{
return SCRIPT_CONTINUE;
}
}
names[idx] = "count";
int value = getCount(self);
attribs[idx] = Integer.toString(value);
return SCRIPT_CONTINUE;
}
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 (isDead(player) || isIncapacitated(player))
{
return SCRIPT_CONTINUE;
}
if (buff.hasBuff(player, "feign_death"))
{
return SCRIPT_CONTINUE;
}
if (buff.hasBuff(player, "recent_heal"))
{
sendSystemMessage(player, SID_STIMPACK_TOO_SOON);
return SCRIPT_CONTINUE;
}
if (item == menu_info_types.ITEM_USE)
{
int level = getLevel(player);
int requiredLevel = getIntObjVar(self, "healing.combat_level_required");
if (level < requiredLevel)
{
sendSystemMessage(player, SID_ITEM_LEVEL_TOO_LOW);
return SCRIPT_OVERRIDE;
}
else
{
boolean worked = healing.useChannelHealItem(player, self);
}
}
return SCRIPT_CONTINUE;
}
}