GeminiVoid Posted March 21, 2024 Share Posted March 21, 2024 Hello everyone! I've been attempting to write a script for FO4 over the last few days, the intention of which is to make the player take damage when passing through the markers that spawn crows (to simulate them attacking the player). My issue is. I'd like the script to track how many birds are currently spawned with the marker, and if the number is 0 the player would not take damage when passing through. Scripting is not my specialty, I can write some fairly basic scripts but that's it, as I spend most of my time making models and textures. Here is the script I currently have compiled: Scriptname _CrowDMG extends ObjectReference Sound Property TriggerSound auto Hazard Property DamageHazard Auto Activator Property BirdBase Auto Const ObjectReference Property MyHazard Auto Hidden int Property BirdCount = 0 Auto {How many birds are in the zone.} ;================================================== ; State Block ;================================================== Auto state Active Event OnTriggerEnter(ObjectReference akActionRef) debug.Trace(self + ": Entered by >> " + akActionRef) ;If BirdBase.>=5 TriggerSound.play(self) MyHazard = placeatme(DamageHazard) ;elsif BirdBase.<1 GotoState("") EndEvent EndState State DoNothing ;do nothing EndState The script works for applying the damage values to the player and everything, but it does not prevent damage when the crows are gone. Any help would be much appreciated, I've hit a bit of a wall here and would hate to give up on this project. Thanks in advance! Link to comment Share on other sites More sharing options...
DieFeM Posted March 22, 2024 Share Posted March 22, 2024 The commented conditional is comparing a number against a base object, that doesn't work, you need to compare two objects of the same type. In first place you would need to find out the ObjectReference for each of the spawned crows in order to check if they are "alive", you can't use IsDead() on a non-actor, so you would need to check its destruction stage. You can get an array of crows references at a certain radius distance with FindAllReferencesOfType, then use a loop to check how many of them are alive by their destruction stage with GetCurrentDestructionStage. Once you count the "alive" crows you can then check if that number is higher than 0. 1 Link to comment Share on other sites More sharing options...
GeminiVoid Posted March 22, 2024 Author Share Posted March 22, 2024 8 hours ago, DieFeM said: The commented conditional is comparing a number against a base object, that doesn't work, you need to compare two objects of the same type. In first place you would need to find out the ObjectReference for each of the spawned crows in order to check if they are "alive", you can't use IsDead() on a non-actor, so you would need to check its destruction stage. You can get an array of crows references at a certain radius distance with FindAllReferencesOfType, then use a loop to check how many of them are alive by their destruction stage with GetCurrentDestructionStage. Once you count the "alive" crows you can then check if that number is higher than 0. Thanks for this! I'm going to look over this and make an attempt at it tonight. Much appreciated Link to comment Share on other sites More sharing options...
Recommended Posts