/** * Copyright (c) ©2000-2008 Sony Online Entertainment Inc. * All Rights Reserved * * Title: systems.beast.beast_display.script * Description: * @author teidson * @version $Revision: 0$ */ include library.beast_lib; include library.create; include library.hue; include library.incubator; include library.sui; include library.utils; trigger OnObjectMenuRequest(obj_id player, menu_info mi) { if(!hasObjVar(self, beast_lib.OBJVAR_OLD_PET_RENAMED) && getOwner(self) == player) { mi.addRootMenu(menu_info_types.SERVER_MENU3, new string_id("beast", "name_beast")); } return SCRIPT_CONTINUE; } trigger OnObjectMenuSelect(obj_id player, int item) { sendDirtyObjectMenuNotification(self); if(item == menu_info_types.SERVER_MENU3 && !hasObjVar(self, beast_lib.OBJVAR_OLD_PET_RENAMED) && getOwner(self) == player) { sui.inputbox(self, player, "@beast:name_d", sui.OK_CANCEL, "@beast:name_t", sui.INPUT_NORMAL, null, "handleSetBeastName", null); } return SCRIPT_CONTINUE; } trigger OnInitialize() { if(hasObjVar(self, "beast")) { messageTo(self, "beast_display", null, 1.0f, false); } return SCRIPT_CONTINUE; } void turnOff(obj_id source) { if(isIdValid(source) && hasObjVar(source, "displayed")) { obj_id displayedBeast = getObjIdObjVar(source, "displayed"); removeObjVar(source, "displayed"); if(isIdValid(displayedBeast)) { destroyObject(displayedBeast); } } } void displayBeast(obj_id source) { location loc = getLocation(source); obj_id container = getContainedBy(source); obj_id displayedBeast = null; if(!isIdValid(container) || !hasObjVar(source, "beast") || !isIdValid(loc.cell) || loc.cell != container) { if(hasObjVar(source, "displayed")) { displayedBeast = getObjIdObjVar(source, "displayed"); if(isIdValid(displayedBeast)) { destroyObject(displayedBeast); } } return; } if(hasObjVar(source, "displayed")) { displayedBeast = getObjIdObjVar(source, "displayed"); destroyObject(displayedBeast); } displayedBeast = beast_lib.createBasicBeastFromObject(source); if(!isIdValid(displayedBeast)) { LOG("beast", "Failed to display beast from decoration item: " + source); return; } setObjVar(source, "displayed", displayedBeast); setObjVar(displayedBeast, "beast_display", source); setInvulnerable(displayedBeast, true); setYaw(displayedBeast, getYaw(source)); setLevel(displayedBeast, beast_lib.getBCDBeastLevel(source)); setScale(displayedBeast, beast_lib.getBeastScaleByLevel(displayedBeast)); setObjVar(displayedBeast, "unmoveable", 1); setObjVar(displayedBeast, "noEject", 1); utils.setScriptVar(displayedBeast, "do_not_pack", 1); attachScript(displayedBeast, "item.special.block_open"); if(hasObjVar(source, "beast.beastName")) { setName(displayedBeast, getStringObjVar(source, "beast.beastName")); } attachScript(displayedBeast, "systems.beast.beast_stuffed"); } // The decoration_item is being simulated as a beast control device, if it has been made from a beast. messageHandler beast_display() { displayBeast(self); return SCRIPT_CONTINUE; } messageHandler furniture_rotated() { obj_id beastDisplayed = getObjIdObjVar(self, "displayed"); if(!isIdValid(beastDisplayed)) { return SCRIPT_CONTINUE; } float yaw = getYaw(self); setYaw(beastDisplayed, yaw); return SCRIPT_CONTINUE; } messageHandler furniture_moved() { obj_id beastDisplayed = getObjIdObjVar(self, "displayed"); if(!isIdValid(beastDisplayed)) { return SCRIPT_CONTINUE; } displayBeast(self); return SCRIPT_CONTINUE; } trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer) { messageTo(self, "beast_display", null, 1.0f, false); return SCRIPT_CONTINUE; } messageHandler handleSetBeastName() { // Store the vendor name. obj_id player = sui.getPlayerId(params); string beastName = sui.getInputBoxText(params); int btn = sui.getIntButtonPressed(params); if(btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } // No zero length or obscene names. if(beastName == "" || isNameReserved(beastName)) { // Ask them about the name. sendSystemMessage(player, new string_id("player_structure", "obscene")); sui.inputbox(self, player, "@beast:name_d", sui.OK_CANCEL, "@beast:name_t", sui.INPUT_NORMAL, null, "handleSetBeastName", null); return SCRIPT_CONTINUE; } if(beastName.length() < 3) { sendSystemMessage(player, new string_id("beast", "name_too_short")); sui.inputbox(self, player, "@beast:name_d", sui.OK_CANCEL, "@beast:name_t", sui.INPUT_NORMAL, null, "handleSetBeastName", null); return SCRIPT_CONTINUE; } if(beastName.length() > 40) { sendSystemMessage(player, new string_id("beast", "name_too_long")); sui.inputbox(self, player, "@beast:name_d", sui.OK_CANCEL, "@beast:name_t", sui.INPUT_NORMAL, null, "handleSetBeastName", null); return SCRIPT_CONTINUE; } sendDirtyObjectMenuNotification(self); setObjVar(self, "beast.beastName", beastName); setObjVar(self, beast_lib.OBJVAR_OLD_PET_RENAMED, 1); setObjVar(self, incubator.DNA_PARENT_NAME, beastName); return SCRIPT_CONTINUE; } messageHandler OnPack() { turnOff(self); return SCRIPT_CONTINUE; } messageHandler OnUnpack() { displayBeast(self); return SCRIPT_CONTINUE; }