Jump to content

CK Scripting Help


Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...