Issues creating attack waves when named actor's are destroyed

Is it possible to Name an Actor on creation?

Information and discussion for custom maps and mods.
Post Reply
Wilmatron
Posts: 10
Joined: Sat May 25, 2019 10:13 am

Issues creating attack waves when named actor's are destroyed

Post by Wilmatron »

Hi All,

I've run into a slight snag. I have 2 enemy infantry facilities and 2 enemy vehicle facilities, with scripted events at various intervals that spawn attack waves, where the attacking forces are built from a pre-defined facility. All of these facilities are available on map start and so have Actor Names. I've referenced these names when declaring the attacking forces as follows:

NODAttackWave1 = { barracks = NODHand2, types = { "e1", "e1", "e1", "e1", "e3", "e3" }, factory = { }, vehicles = { } }
NODAttackWave2 = { barracks = NODHand2, types = { "e4", "e4" }, factory = NODAirF2, vehicles = { "bggy" } }
NODAttackWave3 = { barracks = NODHand1, types = { "e3", "e3", "e4", "e4" }, factory = { }, vehicles = { } }
NODAttackWave4 = { barracks = NODHand1, types = { "e3", "e3" }, factory = NODAirF1, vehicles = { "ltnk" } }
NODAttackWave5 = { barracks = NODHand1, types = { "e1", "e1", "e1" }, factory = NODAirF1, vehicles = { "arty" } }

The problem I have is that when the player destroys one of the named actors, subsequent attacks fail regardless if the enemy re-builds the facility. I assume that this is because when the new actor is created, it is not known by the original Actor Name.

It appears I may have made the wrong decision when choosing to hard code the Actor Name of the production facility? Is there a way to have an attack wave be created by defining the ActorType of "hand" or "afld"? Does it matter that I have multiple production facilities, Or will the creation of the attack wave be shared amongst all necessary ActorType's it finds?

Ideally, if the enemy has 2 Hand of NODs and one of them is destroyed, the attack wave will continue to be created from the remaining Hand of NOD. Again, thank you for all the support you've provided so far. (I've added my new LUA script file with additional code that handles AI rebuilds)

Cheers,
Dave.
Attachments
gdi15a.zip
(3.48 KiB) Downloaded 231 times

User avatar
Materianer
Posts: 199
Joined: Mon Jul 04, 2016 8:27 am

Re: Issues creating attack waves when named actor's are destroyed

Post by Materianer »

Hmm the problem you have is that if the specified building actor is destroyed the production will stop if i understood you right.

You can try to give the rebuild actor the name of the old specified actor.
in the BuildBuilding function you rebuild it that way right now

Code: Select all

		local actor = Actor.Create(building.type, true, { Owner = enemy, Location = building.pos })
Just give it the name of the destroyed actor.

Code: Select all

		local NODHand2 = Actor.Create(building.type, true, { Owner = enemy, Location = building.pos })
But that will not work that way because you use the function for multiple buildings ( or maybe there is a way i just dont get atm ;) )

Maybe use a trigger on killed trigger for your buildings that will call a seperate function wich checks if conyard is able to build a new building and does so if it is.
If not the function is called after 30 sec again.

Just an idea how it could work ...

Wilmatron
Posts: 10
Joined: Sat May 25, 2019 10:13 am

Re: Issues creating attack waves when named actor's are destroyed

Post by Wilmatron »

Hi - I'm afraid this does not appear to have any effect. I'm not entirely sure the new actor (when re-created) is identified as the original actor name, even though I am specifying it as a local variable.

Is there a way you can parse the name of the actor on creation when declaring the owner and location?
For example:

local X = Actor.Create(building.type, true, { Owner = enemy, Location = building.pos, Name = NODHand2 })

This line of code doesn't work, as it generates an LUA error of - Unknown initializer type 'Name'

If this is possible, could anyone tell me what the initializer type should be that represents the name of the actor?

Cheers,
D

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Re: Issues creating attack waves when named actor's are destroyed

Post by abcdefg30 »

NODHand2 = Actor.Create(building.type, true, { Owner = enemy, Location = building.pos })

the actor names are global, not local variables, so above should overwrite it.

Wilmatron
Posts: 10
Joined: Sat May 25, 2019 10:13 am

Re: Issues creating attack waves when named actor's are destroyed

Post by Wilmatron »

Thanks for that - I'm slowly getting there. The problem now is that when the newly created actor is given a command to build, it throws an error reporting the actor is dead.

Timeline as follows:

1. AttackWave1 is triggered 5 seconds into game time. NODHand2 (the actor name of the enemy barracks) creates the necessary units and moves them to a pre-defined patrol route.

2. NODHand2 is destroyed sometime before AttackWave2 is triggered.

3. The enemy is given a command to rebuild NODHand2 and this is completed.

4. AttackWave2 is triggered, and an LUA error is returned Actor 'hand (dead)' does not define a property 'Build'

So, it would appear the game is still under the impression that the actor is dead, when it is not. How would I reset it to alive again when it is returned via rebuild function?

Cheers,
D

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Re: Issues creating attack waves when named actor's are destroyed

Post by abcdefg30 »

I guess you might need to set "NODAttackWave2.barracks" to the new actor as well, i.e. "NODAttackWave1.barracks = NODHand2". Did you disable the IsDead checks? Because I don't see how it would crash otherwise.

Wilmatron
Posts: 10
Joined: Sat May 25, 2019 10:13 am

Re: Issues creating attack waves when named actor's are destroyed

Post by Wilmatron »

Thanks again - all sorted.

Post Reply