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.
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
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
does the health powerup device actually allow for reductions of health? will definitely look into this!
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 ?
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
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