/** * Copyright (c)2000-2002 Sony Online Entertainment Inc. * All Rights Reserved * * Title: magic_eight_ball.script * DesCRiption: when examined displays a special message randomly picked * from 50 predefined messages * @author $AutHor: Matthew Kwid$ * @version $Revision:$ */ /***** INCLUDES ********************************************************/ include library.utils; include library.firework; /***** INCLUDES ********************************************************/ /***** CONSTANTS *******************************************************/ const string_id SID_NO_FIREWORKS_IN_SPACE = new string_id("space/space_interaction", "no_fireworks_in_space"); /***** TRIGGERS ********************************************************/ trigger OnAttach() { setCount(self, 5); return SCRIPT_CONTINUE; } trigger OnObjectMenuRequest(obj_id player, menu_info mi) { mi.addRootMenuOrServerNotify (menu_info_types.ITEM_USE, null); return SCRIPT_CONTINUE; } trigger OnObjectMenuSelect(obj_id player, int item) { // Make sure we aren't in space. if (isSpaceScene()) { sendSystemMessage(player, SID_NO_FIREWORKS_IN_SPACE); return SCRIPT_CONTINUE; } if ( item == menu_info_types.ITEM_USE ) //propose { obj_id inv = utils.getInventoryContainer(player); if ( isIdValid(inv) && utils.isNestedWithin(self, inv) ) { queueCommand(player, ##"launchFirework", self, "", COMMAND_PRIORITY_DEFAULT); return SCRIPT_CONTINUE; } } return SCRIPT_CONTINUE; } trigger OnGetAttributes(obj_id player, string[] names, string[] attribs) { string fx = ""; if ( !hasObjVar(self, firework.VAR_FIREWORK_BASE) ) { fx = firework.getRandomFireworkEffect(); if ( fx != null && !fx.equals("") ) setObjVar(self, firework.VAR_FIREWORK_FX, fx); } else { fx = getStringObjVar(self, firework.VAR_FIREWORK_FX); } if ( fx == null || fx.equals("") ) return SCRIPT_CONTINUE; int idx = utils.getValidAttributeIndex(names); if (idx == -1) return SCRIPT_CONTINUE; names[idx] = "pattern"; attribs[idx] = "@firework_n:" + fx; return SCRIPT_CONTINUE; }