Damage creatures spawned from a creature_spawner with Verse?

Hi all! I have a function that applies damage to all players within a certain radius.

This works great for players. I grab all players with

var PlayerList : []agent = GetPlayspace().GetPlayers()

iterate over each ones position, and compare that to the distance of the damage radius. I noticed that creature_spawner_devices have two events that I can subscribe to, SpawnedEvent and EliminatedEvent each providing the creature that was spawned/eliminated

Within my damage function, I modified the array such that

set PlayerList += SpawnedCreatures

From there, I’m calling the following.

   for (TargetPlayer : PlayerList):
            if (TargetCharacter := TargetPlayer.GetFortCharacter[]):
                

I noticed that the .GetFortCharacter method fails – this makes sense to me, but, if that’s the case, how else can I damage agents via Verse? agent doesn’t implement the damageable interface, which means I can’t call Damage.

Any ideas? I’m trying to avoid using damage volume devices, as I can’t dynamically spawn those, and my experience uses a lot of dynamically spawned damage volumes.

you can use the explosive device, but that’s about it.

Have you considered using health powerup device? it accepts agent as parameter and you can modify the damage/health applied using verse. This is what I thought on top of my head :man_shrugging:

Have you considered using health powerup device? it accepts agent as parameter and you can modify the damage/health applied using verse. This is what I thought on top of my head :man_shrugging:

does the health powerup device actually allow for reductions of health? will definitely look into this!

Yes it does allow that.

1 Like

Hey, actually, the .GetFortCharacter[] method should work, I use it with wildlife and it returns the character of the wildlife.

If you can retrieve the fort_character of the creature then you can just call the .Damage() method, which will take less memory than placing a powerup health device, I guess.

Can you show us how you tried to retrieve the fort_character of the creature ?

1 Like

I went ahead and checked this morning, and it seems like everything is working now. I’m guessing I forgot to push changes on a reference or something. Either way, happy to see the reply from @SeedohFN about using a powerup health device, and thank you for your knowledge here too.

For posterity’s sake, all I did was poll for the players in the game and combine that with an array filled with creature_spawner_device agents.

var PlayerList : []agent = GetPlayspace().GetPlayers() 
set PlayerList += CreaturesList

for (TargetPlayer : PlayerList):
     if (TargetCharacter := TargetPlayer.GetFortCharacter[]):
          var ShouldCalculateDamage : logic := true

Marking this as closed!

2 Likes

I guess this does beg the question though, now that I’m thinking about this – is there a better way to grab wildlife in a world than attaching to a creature spawner callback?

I’m not sure, I think Mutator Zones are glitchy about this. But I think the actual spawners SpawnedEvent are not such a bad way of retrieving those agents :person_shrugging:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.