Page 1 of 1

Can you "spawn" aircraft in scenario?

Posted: 25 Nov 2020, 17:50
by Sat42
Hey there!

As per the title of the topic: can you "spawn" aircraft in a scenario, regardless of whether player (human or AI) has an airport?

Application: scripted scene (air raid), spawn aircraft then control group to attack target, then retreat and "despawn"

Re: Can you "spawn" aircraft in scenario?

Posted: 26 Nov 2020, 01:29
by Dr.MonaLisa
Hi.

Do you mean CreateNamedUnitAtLocation(), CreateNamedUnitInArea(), CreateGroupedUnitAtLocation() and such?

Then yes, they can be spawned normally with the .IES and they'll have a full ammunition. Then you can order each unit (or group) to attack a separate target, or use MoveSelectionWithAttack() or MoveSelectionToAreaWithAttack().

When you finish you can move MoveSelection() / MoveSelectionToArea() to some point outside of the map (like -200, -200 and such), to make it more realistic if any player sees where they escape. Then RemoveSelection(), like in my planes scenario:

Code: Select all

if(DoesUnitExist(sEnemyTruck1)){
if(NamedUnitIsInArea(sEnemyTruck1, sAreaTruckRemove)){
SelectUnit(sEnemyTruck1);
RemoveSelection();
ClearSelection();
iNextTimeTruck = GetElapsedGameTime() + 15;
bTruckDiedInArea1 = true;
}
}
So it wouldn't show death animation, just make them disappear.

Re: Can you "spawn" aircraft in scenario?

Posted: 26 Nov 2020, 11:44
by Sat42
Super info, thanks Mona!

If the targets (for the spawned aircraft) are mobile and aren't better defined than "generic player 1 forces" (I might specify the type like heavy mounted, heavy infantry as different targets but cannot be sure what exact units the player will still have at this point), is it better to rely on MoveSelectionToAreaWithAttack()? and perhaps have the aircraft rotate through several areas, so they can for sure hit any stray target?

Also, you say that to finish I can move MoveSelection() / MoveSelectionToArea() to some point outside of the map (like -200, -200 and such), to make it more realistic if any player sees where they escape - love that, I suppose you can do that with any unit (like your truck example), and can you spawn the units (aircraft or other, with CreateNamedUnitInArea(), CreateGroupedUnitAtLocation() etc.) also at some point outside the map, then have them MoveSelectionToAreaWithAttack(), so we don't just see them "pop" into existence?

This would solve a concern I had regarding spawning an army (this time a land force) into the map: I was like, what if the area has (over the course of the scenario) been built over? even if I make the terrain at spawn location rough, what if a player has lots of units stationed there at time of spawning? could it block the spawning? never mind that it would look super odd if player can see the "pop-in" effect :p whereas if the land invasion came through the "black edge" of map (and provided the initial map area where it arrives is rough so no buildings can block the way) not only would it look better, but also a cheeky player won't be able to "block" the land force's arrival.

Re: Can you "spawn" aircraft in scenario?

Posted: 26 Nov 2020, 13:49
by Dr.MonaLisa
If the targets (for the spawned aircraft) are mobile and aren't better defined than "generic player 1 forces" (I might specify the type like heavy mounted, heavy infantry as different targets but cannot be sure what exact units the player will still have at this point)
For a bombing scenario, it's also funny to use:

Code: Select all

// void AttackAreaWithSelection(const char *in_szAreaName)
// Give an attack area goal to the currently selected units, targeted
// at the area named in_szAttackee.  This is only for units with area
// attacks (projectiles, etc.), not for telling the selection to kill
// everyone in a given area. After giving the goal, this flushes the
// current selection.
// example usage:
	SelectGroup("Bombers");
	AttackAreaWithSelection("Guernica");
Depending on the size of the map, and the number of bombers you're trying to use. It might look very nice when bombers arrive, drop bombs without rotating, and then leave the map. Like every single bomber is set to drop a bomb at different location. Areas placed in the Map Editor can have very tiny sizes. With a good timing you are able to leave the map without rotating.
But it's just my idea, so don't keep it in minds too much. On the other hand attacking the empty ground is also unrealistic in real-life (unless you fight with forest wildfires in Sweden).

Also, you say that to finish I can move MoveSelection() / MoveSelectionToArea() to some point outside of the map (like -200, -200 and such), to make it more realistic if any player sees where they escape - love that, I suppose you can do that with any unit (like your truck example), and can you spawn the units (aircraft or other, with CreateNamedUnitInArea(), CreateGroupedUnitAtLocation() etc.) also at some point outside the map, then have them MoveSelectionToAreaWithAttack(), so we don't just see them "pop" into existence?
I could be misleading. It's possible that units can't be spawned / moved to negative locations (like less than 0). It would need to be tested. But then, you can move to 0,0 or 500,500 (if the map is 500x500) and make them disappear here. I would recommend to check my planes scenario script, as there are bombers used that disappear when they're in the area at the end of the map.
However, my scripting methods were unique and hard to understand. I generally created a world based on looped events, so it's like multithreaded scenario, where events repeat multiple times, using exactly the same function in the .IES. It required a lot of tests like "DoesUnitExists", bools, and other stuff to make it error-free. After this scenario I decided to never do anything .IES related in the future. It gives too many headaches. In my opinion IES is nice for easy stuff. Not to mention the unique camera rotation method that I made especially for it.
what if a player has lots of units stationed there at time of spawning? could it block the spawning? never mind that it would look super odd if player can see the "pop-in" effect :p
Well, it's not a big problem. In EE2: AOS "Rorke's Drift" Turning Point, they spwan all the time, and you can see it. Maybe it's not worth too put too many attention on details that even the main game studio didn't care about. I'm a bit hypocrite saying this (based on even littles possible bug fixes in UP1.5), but this attitude helps not to go crazy with stuff.

Re: Can you "spawn" aircraft in scenario?

Posted: 26 Nov 2020, 14:17
by Sat42
Yo, thanks again for the ideas and information!
Yes I guess testing (also in the context of a particular level design) would reveal how feasible things are - I will be doing that in due time!

One technique which was used in Age of Empires II was to have a path near the edge of the map be blocked either by trees or boulders (depending) and have those be "cleared" by a trigger when it was time to spawn in an army or something - that way, the "spawning ground" would not be approached or built on by players - until after the spawning. Maybe something similar can be achieved in EEII...