Zorkaz Posted June 8, 2021 Share Posted June 8, 2021 I created a custom crow and want it to be dead when the cell loads. But how can I script it when there's no gamebryo animation? Link to comment Share on other sites More sharing options...
RoNin1971 Posted June 8, 2021 Share Posted June 8, 2021 (edited) Hmmm... interesting question... I'll see if I can find an answer. edit:By the looks of it there have to be several Havok animations inside the behavior graph .hkx data (Critters\Crow\CrowProject.hkx) corresponding to the properties available for the BirdCritterScript (NPCCrowCall, NPCCrowCallDistressed, NPCCrowWingFlap, NPCCrowWingFlapLand & NPCCrowWingFlapTakeoff. (also noticed the absence of NPCCrowDead or similar)) even though non is mentioned under Havok Anim. or could they possibly be fully scripted? Edited June 8, 2021 by RoNin1971 Link to comment Share on other sites More sharing options...
Zorkaz Posted June 8, 2021 Author Share Posted June 8, 2021 I mean there's a clue in the bird script itself (Attached to Crows and Seagulls), but I cannot completely make sense of how it works Scriptname BirdCritterScript extends ObjectReference{Inivdial bird controls for individual bird behavior}String myPerchNameBool birdSpawned = false;place to go landObjectReference currentPerchObjectReference nextPerchKeyword Property LinkCustom01 auto{Keyword for Flee marker, used with interior fleeing}int numLinkedRefs;Timer id for timer used in basic fly behaviorint flyToTreeID = 1 constint hidingCaw = 2 const;soundsSound Property NPCCrowCall AutoSound Property NPCCrowCallDistressed AutoSound Property NPCCrowWingFlap AutoSound Property NPCCrowWingFlapLand AutoSound Property NPCCrowWingFlapTakeoff Autosound myCallSound;;BirdSpawnerScript Property myParentScript Auto{parent script on trigger}bool playerInZone = falseEvent OnLoad() loadBird()EndEventfunction spawnBird(String akPerchName, BirdSpawnerScript akParentScript ) myPerchName = akPerchName myParentScript = akParentScript birdSpawned = true loadBird()endFunctionfunction loadBird() if Is3dLoaded() && birdSpawned ;set up current location for distance checking currentPerch = myParentScript.GetLinkedRef() ;toggle call sound to not distressed myCallSound = NPCCrowCall ;grab the number of landing spots numLinkedRefs = myParentScript.countLinkedRefChain() ;start timer timerBetweenFlights() ;events to get from parent script registerForCustomEvent(myParentScript, "Flee") registerForCustomEvent(myParentScript, "Hide") registerForCustomEvent(myParentScript, "safe") self.SetScale(Utility.RandomFloat(0.8, 1.2)) GotoState("Waiting") endIfendFunctionEvent OnUnload() ;Break any registration to events so I can delete them unregisterForAllEvents() ;clean them up as they will spawn again on load disable() delete() ;future home of unregisterForAllEventsEndEventevent BirdSpawnerScript.flee(BirdSpawnerScript akSender, Var[] akArgs) ;If the event comes to flee do it no mateer what myCallSound = NPCCrowCallDistressed if myParentScript.InteriorFlee == false flee() else GotoState("InteriorFleeState") flyToTree(false, true) endifendEventevent BirdSpawnerScript.hide(BirdSpawnerScript akSender, Var[] akArgs) ;if this event comes hide no matter what debug.trace("got hide event") myCallSound = NPCCrowCallDistressed flyToTree(true) GotoState("Hiding")endEventevent BirdSpawnerScript.safe(BirdSpawnerScript akSender, Var[] akArgs) ;safe mode only takes if you are in hiding modeendEvent;basic flight beteen spotsstate Waiting Event OnTimer(int aiTimerID) if aiTimerID == flyToTreeID flyToTree(false) endif EndEvent ;landing flap animation control Event OnTranslationAlmostComplete() land() EndEvent ;landing flap animation control Event OnTranslationComplete() ;utility.wait(0.3) playAnimation("Land") timerBetweenFlights() EndEventendState;hiding when player is in triggerstate Hiding Event OnBeginState(string asOldState) startTimer(Utility.RandomInt(2, 15), hidingCaw) EndEvent event BirdSpawnerScript.safe(BirdSpawnerScript akSender, Var[] akArgs) playerInZone = false GotoState("safe") endEvent Event OnTimer(int aiTimerID) if aiTimerID == hidingCaw myCallSound.play(self) startTimer(Utility.RandomInt(2, 15), hidingCaw) endif EndEvent Event OnTranslationAlmostComplete() land() EndEvent ;landing flap animation control Event OnTranslationComplete() ;utility.wait(0.3) playAnimation("Land") ;GotoState("safe") EndEventendState;sperate statestate safe Event OnBeginState(string asOldState) ;if playerInZone == true myCallSound = NPCCrowCall utility.wait(Utility.RandomInt(2, 7)) flyToTree(false) timerBetweenFlights() GotoState("Waiting") ;endif EndEvent event BirdSpawnerScript.safe(BirdSpawnerScript akSender, Var[] akArgs) ;if you ever get the safe event switch back to using the non hide tree list myCallSound = NPCCrowCall utility.wait(Utility.RandomInt(2, 7)) flyToTree(false) timerBetweenFlights() GotoState("Waiting") playerInZone = false endEventendStatestate interiorFleeState Event OnTranslationAlmostComplete() land() EndEvent ;landing flap animation control Event OnTranslationComplete() playAnimation("Land") flee() EndEventendStatestate flee ;do nothingendState;;;functions-------------------------------------------------------------------------function timerBetweenFlights() startTimer(Utility.RandomInt(10, 25), flyToTreeID)endFunctionfunction flyToTree(bool akHide, bool InteriorFlee = false) float speedRandomFudge = Utility.RandomFloat(-10.0, 50.0) if akHide == false && InteriorFlee == false nextPerch = myParentScript.GetNthLinkedRef(Utility.RandomInt(1, numLinkedRefs)) elseif InteriorFlee == true && akHide == false nextPerch = myParentScript.GetLinkedRef(LinkCustom01) else nextPerch = myParentScript.GetLinkedRef() playerinZone = true endif if currentPerch == nextPerch timerBetweenFlights() else playTakeoffSounds() SetAnimationVariableFloat("fDampRate", 1.0) SetAnimationVariableFloat("fFlapSpeed", 2.0) playAnimation("Takeoff") utility.wait(0.1) float perchDistance = currentPerch.GetDistance(nextPerch) ;currentPerch = nextPerch SplineTranslateToRefNode(nextPerch, (myPerchName), (perchDistance * 2), 550.0 + speedRandomFudge) ;debug.trace("I am " + self + " and I am going to purch on " + crowNumber) utility.wait(0.6) ;slow down winflap speed over time(dampened in graph). SetAnimationVariableFloat("fDampRate", 0.05) SetAnimationVariableFloat("fFlapSpeed", utility.RandomFloat (1.0, 1.5)) NPCCrowWingFlap.play(self) endifendFunctionfunction flee() GotoState("flee") playTakeoffSounds() PlayAnimation("flee") utility.wait(4) disable() delete()endFunctionfunction land() SetAnimationVariableFloat("fDampRate", 1.0) SetAnimationVariableFloat("fFlapSpeed", 2.5) playAnimation("LandingGlide") playLandingSounds() currentPerch = nextPerchendFunction;Play takeoff soundsfunction playTakeoffSounds() myCallSound.play(self) ;flapSoundID = NPCCrowWingFlapLP.play(self) NPCCrowWingFlapTakeoff.play(self)endFunction;Play landing soundsfunction playLandingSounds() myCallSound.play(self) ;Sound.StopInstance(flapSoundID) NPCCrowWingFlapLand.play(self)endFunction;;;functions------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
Recommended Posts