/** * Copyright (c) ©2000-2002 Sony Online Entertainment Inc. * All Rights Reserved * * Title: outdoorsman.script * Description: scout command handlers * @author $Author:$ * @version $Revision: #1 $ */ //------------------------------------------------ // Includes //------------------------------------------------ include library.utils; include library.ai_lib; include library.camping; //------------------------------------------------ // Constants //------------------------------------------------ const string_id SID_DEPLOY = new string_id("camp","deploy"); const string_id SID_SYS_ALREADY_CAMPING = new string_id("camp","sys_already_camping"); const string_id SID_SYS_CANT_CAMP = new string_id("camp","sys_cant_camp"); const string_id SID_SYS_NOT_IN_INV = new string_id("camp","sys_not_in_inv"); const string_id SID_SYS_DEPLOY = new string_id("camp","sys_deploy"); const string_id SID_SYS_NOT_IN_COMBAT = new string_id("camp","sys_not_in_combat"); const string_id SID_SYS_NSF_SKILL = new string_id("camp","sys_nsf_skill"); //------------------------------------------------ // Methods //------------------------------------------------ //------------------------------------------------ // OnObjectMenuRequest //------------------------------------------------ trigger OnObjectMenuRequest( obj_id player, menu_info mi ) { // If we are encrypted add the option to decode. menu_info_data mid = mi.getMenuItemByType( menu_info_types.ITEM_USE ); if ( mid != null ) mid.setServerNotify( true ); return SCRIPT_CONTINUE; } //------------------------------------------------ // OnObjectMenuSelect //------------------------------------------------ trigger OnObjectMenuSelect( obj_id player, int item ) { // Item was used. if ( item == menu_info_types.ITEM_USE ) { // Deploy the camp. deployCamp( self, player ); } return SCRIPT_CONTINUE; } //------------------------------------------------ // deployCamp //------------------------------------------------ void deployCamp( obj_id self, obj_id player ) { // Make sure we aren't in space. if (isSpaceScene()) return; // Make sure we are in the player's inventory. obj_id inventory = getObjectInSlot( player, "inventory" ); if ( !utils.isNestedWithin( self, player ) ) { sendSystemMessage( player, SID_SYS_NOT_IN_INV ); return; } // Make sure we aren't in combat. if ( ai_lib.isInCombat( player ) ) { sendSystemMessage( player, SID_SYS_NOT_IN_COMBAT ); return; } // Make sure we aren't swimming. if ( 1 == getState( player, STATE_SWIMMING ) ) { sendSystemMessage( player, SID_SYS_CANT_CAMP ); return; } // Check to see if the player is already camping. if ( hasObjVar( player, camping.VAR_CAMP_BASE ) ) { obj_id myCamp = getObjIdObjVar( player, camping.VAR_PLAYER_CAMP ); if ( (myCamp == null) || (myCamp == obj_id.NULL_ID) ) { // Camp doesn't exist. } else { if ( exists(myCamp) && myCamp.isLoaded() ) { // We are already camping. sendSystemMessage( player, SID_SYS_ALREADY_CAMPING ); return; } else { removeObjVar( player, camping.VAR_CAMP_BASE ); } } } int campMod = getSkillStatMod( player, camping.MOD_CAMP ); int modReq = getIntObjVar( self, "skillReq" ); int campPower = getIntObjVar( self, "campPower" ); if ( campMod < modReq ) { // Not enough skill to use this. sendSystemMessage( player, SID_SYS_NSF_SKILL ); return; } // Player can build this camp. sendSystemMessage( player, SID_SYS_DEPLOY ); obj_id master = camping.createCamp( player, campPower ); if ( master == null ) { // Failed to create camp. } else { setObjVar( player, camping.VAR_PLAYER_CAMP, master ); if ( hasScript(player, "theme_park.new_player.new_player") ) { dictionary webster = new dictionary(); webster.put("deployedCamp", 1); messageTo(player, "handleNewPlayerScoutAction", webster, 1, false); } destroyObject( self ); } }