/** * Copyright (c)2000-2002 Sony Online Entertainment Inc. * All Rights Reserved * * Title: terminal_food.script * Description: BETA SCRIPT: food dispenser * @author $Author:$ * @version $Revision:$ */ /***** INCLUDES ********************************************************/ /***** INHERITS ********************************************************/ //inherits terminal.base.base_terminal; /***** CONSTANTS *******************************************************/ const string_id SID_ORDER_DAMAGE_MEDICINE = new string_id ("sui", "order_damage_medicine"); const string_id SID_ORDER_WOUND_MEDICINE = new string_id ("sui", "order_wound_medicine"); const string VAR_CAN_USE_TERMINAL = "terminal.can_use_terminal"; const int VAR_TERMINAL_TIME = 1; const string[] TEMPLATES = { "object/tangible/medicine/medpack_wound_health.iff", "object/tangible/medicine/medpack_wound_constitution.iff", "object/tangible/medicine/medpack_wound_action.iff", "object/tangible/medicine/medpack_wound_stamina.iff" }; /***** TRIGGERS ********************************************************/ trigger OnAttach() { setCanUseTerminal(self, true); return SCRIPT_CONTINUE; } trigger OnObjectMenuRequest(obj_id player, menu_info mi) { if (canUseTerminal(self)) { mi.addRootMenu(menu_info_types.SERVER_HEAL_DAMAGE, SID_ORDER_DAMAGE_MEDICINE); mi.addRootMenu(menu_info_types.SERVER_HEAL_WOUND, SID_ORDER_WOUND_MEDICINE); } return SCRIPT_CONTINUE; } trigger OnObjectMenuSelect(obj_id player, int item) { if (isGod(player) || hasObjVar(player, "beta.terminal_ok")) { if ( item == menu_info_types.SERVER_HEAL_DAMAGE) { if (!canUseTerminal(self)) { sendSystemMessageTestingOnly(player, "You must wait for the terminal to recharge."); LOG("LOG_CHANNEL", "You must wait for the terminal to recharge."); return SCRIPT_CONTINUE; } //grant damage medicine here obj_id inv = getObjectInSlot(player, "inventory"); createObject("object/tangible/medicine/medpack_damage.iff", inv, ""); //debugSpeakMsg(self, "player inventory = " + inv); // The terminal can only be used every so often. setCanUseTerminal(self, false); dictionary dctMsg = new dictionary(); messageTo(self, "msgMedicineTerminal", dctMsg, VAR_TERMINAL_TIME, false); } if (item == menu_info_types.SERVER_HEAL_WOUND) { if (!canUseTerminal(self)) { sendSystemMessageTestingOnly(player, "You must wait for the terminal to recharge."); LOG("LOG_CHANNEL", "You must wait for the terminal to recharge."); return SCRIPT_CONTINUE; } obj_id inv = getObjectInSlot(player, "inventory"); int idx = rand(0, TEMPLATES.length - 1); obj_id medicine = createObject(TEMPLATES[idx], inv, ""); // The terminal can only be used every so often. setCanUseTerminal(self, false); dictionary dctMsg = new dictionary(); messageTo(self, "msgMedicineTerminal", dctMsg, VAR_TERMINAL_TIME, false); } return SCRIPT_CONTINUE; } else { sendSystemMessageTestingOnly(player, "Only authorized users may access this terminal."); return SCRIPT_CONTINUE; } } /***** FUNCTIONS *******************************************************/ boolean setCanUseTerminal(obj_id terminal, boolean toggle) { if (terminal == null) return false; if (!hasObjVar(terminal, VAR_CAN_USE_TERMINAL)) { setObjVar(terminal, VAR_CAN_USE_TERMINAL, 1); } if (toggle == true) { setObjVar(terminal, VAR_CAN_USE_TERMINAL, 1); } else { setObjVar(terminal, VAR_CAN_USE_TERMINAL, 0); } return true; } boolean canUseTerminal(obj_id terminal) { LOG("LOG_CHANNEL", "canUseTerminal called."); if (terminal == null) return false; if (!hasObjVar(terminal, VAR_CAN_USE_TERMINAL)) { setObjVar(terminal, VAR_CAN_USE_TERMINAL, 1); } if (getIntObjVar(terminal, VAR_CAN_USE_TERMINAL) == 0) return false; else return true; } /***** MESSAGEHANDLERS *************************************************/ messageHandler msgMedicineTerminal() { setCanUseTerminal(self, true); return SCRIPT_CONTINUE; }