//:://///////////////////////////////////////////// //:: Name: birdbath_hb //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* OnHeartbest event for the "Special Birdbath" placeable. This script will emulate birds flying in by the birdbath, walking around for a bit, and then flying off. */ //::////////////////////////////////////////////// //:: Created By: Adam Walenga //:: Created On: October 23rd, 2004 //::////////////////////////////////////////////// // modified by caesarbear 11/13/04 // not so Hitchcock-ian #include "nw_i0_spells" void Bird_Heartbeat (object oBird) { object oBirdBath = GetNearestObjectByTag ("Special_Birdbath", oBird); float fClearDelay = GetRandomDelay (1.1f, 1.9f); float fHBDelay = GetRandomDelay (2.0f, 2.8f); float fDistance = GetDistanceBetween (oBird, oBirdBath); //Check if the HB function has run atleast once for this bird. if (GetLocalInt (oBird, "Has_Run_Once")) //Determine if oBird should fly away (1/6 chance). if (d6() == 1) { //Determine if a sound should be played (1/2 chance). if (d2() == 1) { int iNumber = d2(); string sSound = "as_an_birdflap"; //Determine which sound to play. if (d2() == 1) sSound = "as_an_birdsflap"; //Now play the sound. sSound = sSound + IntToString (iNumber); AssignCommand (oBirdBath, PlaySound (sSound)); } //Have oBird fly away (using disappear effect). ApplyEffectToObject (DURATION_TYPE_INSTANT, EffectDisappear(), oBird); } SetLocalInt (oBird, "Has_Run_Once", TRUE); //Check if bird is too far away from the birdbath. if (fDistance <= 5.0f) { AssignCommand (oBird, ActionRandomWalk()); DelayCommand (fClearDelay, AssignCommand (oBird, ClearAllActions())); } else //Bird has wandered too far away - return to the birdbath. AssignCommand (oBird, ActionMoveToObject (oBirdBath)); DelayCommand (fHBDelay, Bird_Heartbeat (oBird)); } void main() { object oNewBird = OBJECT_INVALID, oBirdBath = OBJECT_SELF, oPCInArea = GetNearestCreature (CREATURE_TYPE_PLAYER_CHAR, TRUE); string sBirdResRef = "birdbath_raven"; float fDelay = GetRandomDelay(0.4f, 1.1f); //Between 0.4, and 1.1 seconds. object oArea = GetArea(OBJECT_SELF); int bRain; if (GetWeather(GetArea(OBJECT_SELF))==WEATHER_RAIN) //added cb { bRain = TRUE; } //If no PCs in area or is night, exit the script. if ((oPCInArea == OBJECT_INVALID) || (GetIsNight()) || (GetIsDusk()) || (bRain)) { return; } if (!GetLocalInt(OBJECT_SELF, "WAIT")) //added cb { //Choose a random bird to add. if (d2() == 1) sBirdResRef = "birdbath_falcon"; //Create the new bird, and run a heartbeat function on it. oNewBird = CreateObject (1, sBirdResRef, GetLocation (oBirdBath), TRUE); DelayCommand (fDelay, Bird_Heartbeat (oNewBird)); SetLocalInt(OBJECT_SELF, "WAIT", 1); //added cb } else //added cb { SetLocalInt(OBJECT_SELF, "WAIT", 0); //added cb } }