//:://////////////////////////////////////////////////////////////////////////// //:: //:: Script Name: area_enter //:: //:: Use: This script will respawn NPCs in your area onEnter, explore an area //:: if toggled on, and add visual effects if toggled on. //:: //:: Created By: Birdman076 //:: //:: Created On: July 27, 2009 //:: //:: Update: Aug 30, 2009 - Added script executions to check for maps and added //:: Taer City check as well in variable on area format //:: //:: Variables used in the properties of the area you use this script: //:: //:: NPC_TOTAL - How many NPCs should spawn in the area total //:: NPC_WP - The waypoint of the NPC you want to spawn in (use NPC_WP0,1,2,3,etc for as many NPC's as you have) //:: NPC_TAG - The Tag of the NPC you wish to spawn in (use NPC_TAG0,1,2,3,etc for as many NPCs as you have) //:: NPC_RES - The Resref of the NPC you wish to spawn in (use NPC_RES0,1,2,3,etc for as many NPCs as you have) //:: //:: iExplore - Set to "1" to explore the area for the player //:: iTaerCity - Set to "1" to check for Taer City key on player //:: //:: This next portion is for adding a visual effect that fills the area //:: it has been broken up into 2 variations for each effect. The first is //:: a low fill effect that fills pits, and low places within the area. //:: The second variation is a ground level effect that fills slightly above //:: ground level for a full area fill and also it kind of looks like you are //:: traversing through the effect. To change the effect higher or lower just //:: change the value of the float number to higher or lower. If you go to high //:: the player will be able to see under the effect by moving the camera angle. //:: //:: AREA VISUAL EFFECTS VARIABLES //:: Add the variables to the area properties to make the effects happen in that area //:: //:: iLava_Low - Set to "1" to fill an area with lava, this one fills low areas //:: iLava_Med - Set to "1" to fill an area with lava, this one fills ground level //:: iIce_Low - Set to "1" to fill an area with Ice, this one fills low areas //:: iIce_Med - Set to "1" to fill an area with Ice, this one fills ground level //:: iWater_Low - Set to "1" to fill an area with water, this one fills low areas //:: iWater_Med - Set to "1" to fill an area with water, this one fills ground level //:: iSWater_Low - Set to "1" to fill an area with sewer water, this one fills low areas //:: iSWater_Med - Set to "1" to fill an area with sewer water, this one fills ground level //:://////////////////////////////////////////////////////////////////////////// #include "persist_loc" #include "NW_I0_GENERIC" #include "x2_inc_toollib" void doNPCSpawn( object oArea, int iCount ); void main() { object oPC = GetEnteringObject(); object oArea = GetArea( oPC ); // Added for persistent location script SavPlayer(oPC); ExecuteScript("show_map_if", OBJECT_SELF); int iNPCs = GetLocalInt( oArea, "NPC_TOTAL" ); // NPC_TOTAL = how many NPCs should spawn in area int iNPCCurrent = GetLocalInt( oArea, "NPC_AMT" ); // Current number of NPCs spawned in, used in while loop next int iCount = 0; // counter to add up in while loop number already spawned by loop AssignCommand( oPC, ClearAllActions( TRUE ) ); if( GetIsPC( oPC ) ) { if( iNPCs > 0 && iNPCCurrent == 0 ) { //only if its a pc and we have more then zero npcs and we haven't started spawning them yet while( iCount < iNPCs ) { DelayCommand( IntToFloat( iCount ) * 0.2, doNPCSpawn( oArea, iCount ) ); SetLocalInt( oArea, "NPC_AMT", iCount ); // set the local int now so that if another player iCount++; // comes into the area at the time they're spawning we don't start spawning again } } // Start of area visual effects if( GetLocalInt( oArea, "iLava_Low" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_LAVA, -0.3f); if( GetLocalInt( oArea, "iLava_Med" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_LAVA, 1.0f); if( GetLocalInt( oArea, "iIce_Low" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_ICE, -0.3f); if( GetLocalInt( oArea, "iIce_Med" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_ICE, 1.0f); if( GetLocalInt( oArea, "iWater_Low" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_WATER, -0.3f); if( GetLocalInt( oArea, "iWater_Med" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_WATER, 1.0f); if( GetLocalInt( oArea, "iWater_MedB" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_WATER, 2.7f); if( GetLocalInt( oArea, "iSWater_Low" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_SEWER_WATER, -0.3f); if( GetLocalInt( oArea, "iSWater_Med" ) == 1 ) TLChangeAreaGroundTilesEx(oArea, X2_TL_GROUNDTILE_SEWER_WATER, 1.0f); // end of visual effects if( GetLocalInt( oArea, "iTaerKey" ) == 1 ) ExecuteScript("taer_city_chk", OBJECT_SELF); if( GetLocalInt( oArea, "iExplore" ) == 1 ) // if you want the area to be explored ExploreAreaForPlayer( oArea, oPC ); } } void doNPCSpawn( object oArea, int iCount ) { object oNPC_WP = GetWaypointByTag( GetLocalString( oArea, "NPC_WP" + IntToString( iCount ) ) ); object oNPC; if( !GetIsObjectValid( GetNearestObjectByTag( GetLocalString( oArea, "NPC_TAG" + IntToString( iCount ) ), oNPC_WP ) ) ) oNPC = CreateObject( OBJECT_TYPE_CREATURE, GetLocalString( oArea, "NPC_RES" + IntToString( iCount ) ), GetLocation( oNPC_WP ), FALSE ); if( GetIsPostOrWalking( oNPC ) ) DelayCommand( ( IntToFloat( iCount ) * 0.2 ) + 0.1, AssignCommand( oNPC, WalkWayPoints( FALSE ) ) ); }