Download

Enemy groups - Only the last one killed should drop assigned loot

Aloha :slight_smile:

does anyone here have a simple solution to this Problem? How can i manage a larger number of enemy groups, where ONLY the last one standing of each group (not even wave, since several groups should exist at the same time) will drop the assigned loot?

Spawning loot from every killed enemy is not a problem, but i struggle a little bit with the logic to make so, that only the last one, that is alive will drop it, not even the last one spawned from that particular group, since they do not spawn at the same time, but indeed only the last living group member.

Right now i have several spawn points, in my level, that spawn each group. I thougt about using the spawn points as controlling units, that watches over the status of all its spawned enemies, but then again, what would be the best way to realize it, since they spawn one after another, and can be killed in the mean time, or not.

I am somehow not fond of the idea to use the “Get all actors of class”, if i only want to know the status of SOME actors of this class (namely, only the ones of one particular group, out of several coexisting groups). Or is there a way to make each group of the same enemy type it´s own class? ^.^

Tags are also an idea, that the Spawnpoint adds an individual tag to each of it´s spawned enemies, that identifies them as member of the group of this spawnpoint, but i am afraid, that the “get actors with tag” is just as expensive as the “get all actors of class”, since it has to check every enemy for this particular group tag.

The Spawnpoint (or whatever i will put in charge) then also has to know, if an enemy is killed and update its array/database, to either send a signal to the last survivor, so that this enemy then spawns the loot, or to get the position of the last survivor during its kill, to spawn the loot on that position (then the spawnpoint would be responsible for spawning the loot too).
I got Event Dispatchers working, just not sure, if there is an easier way for communication this stuff. Otherwise i would go with them, so that every enemy calls a dispatcher or event in it´s spawnpoint, so that this then can update it´s list.

Or maybe an enemy manager, that keeps track of all groups? But even then it has to know, who spawns, who gets killed and to which group did it belong, who should spawn what loot.
The loot won´t be random, it will be assigned to each group individually.

Could someone please push me in a good direction? :slight_smile:

It sounds like you have a subgroup of enemies that you want to identify, and from them you want to figure out which one is the last one standing, right?

Seems like you could make a child class from the main enemy class and assign these baddies to the class.

You could assume that “get all actors of class” is not good to do, but you should test it first. it might be no problem at all. If it is, perhaps you can change when they get assigned into an array to mask a hitch, if there was one. To me that seems like the simplest solution. Perhaps there is a fancier way but at least with this method we know it will work and can get your started.

I am not an experienced programmer but I can’t imagine a way to figure out who is the last guy left without assigning them into an array. Whether you identify them with a tag or anything else it seems it’s unavoidable.

I guess so, i am a rookie programmer myself, so i am not enirely sure, how those classes work, and what counts as class, and what not ^.^

Basically, imagine you have one type of enemies (all the same, like all foot soldiers, or basic worker ants), that comes as one big Legion, let´s say 10 000 Units. This Legion would be divided into several groups. f.e. 100 groups with 100 units, or something like that.
Forcing the system to check all 10 000 units just o identify the last living one of group 13 (as example) is what i want to avoid :slight_smile:
Especially, since it then would have to check 100 times, because 100 groups exist.

I know, thats an extreme example, but i want a solution, that works for larger groups too. I want to learn it right from the start, not just finding something, that works fine at small scale, but competely fries your machine, the moment, you try to upscale it to more and larger groups.

I guess, for now i try to let the spawnpoints create individual arrays, where they register each enemy they spawn. Then each enemy would only have to call it´s own spawnpoint to report it´s kill (and maybe position), before it gets destroyed.

Perhaps have another actor with a custom event that has an int of total # of ai the player has to kill: Have the enemy call the event sending its location when killed and - - that int var on every call. When that var == 0, spawn loot at the last location vector recieved.

No casting, no loops, no arrays. Just an event that - - an int. :grimacing:

… o.O … Gosh, you are right, a simple individual kill count is enough for this ^.^ And the Spawnpoints are perfect for having those kill counts and the event, since they already know exactly, how many enemies will spawn, and what loot to drop.

1 Like