Survival - spawning "side" waves independent from main wave

Interesting mapping tools and mapping help.

Moderator: Morax

Survival - spawning "side" waves independent from main wave

Postby DDDX » 17 Feb 2018, 16:17

Hi everyone. Need some help.
. I am messing around with a survival map (5.th dimension). Added a bunch of Total Mayhem units in it, and they work like a charm and people love the changed waves.

But I have a problem - I NEED A SIMPLE COMMAND to create units separate from the waves, that would be independent from the wavetable that spawns the main waves (they would have their own spawn point, number of units spawned, time of spawn, order), while the regular survival waves still spawn like nothing happened.

I cannot, for the life of me, get alternate spawn points to function independently. Survival waves either spawn in the normal spawn points, or where I tell them - but never both.

It does not even have to be in a WaveTable form - I'd be perfectly satisfied with a code that did the following: (at time xy, spawn xy number of unit xy in the marker xy and order it to attack). And I just repeat it as many times as i need units spawned...

Should be fairly simple, but it is not. I checked 4-5 other survivals for hints, however I am a lawyer and not a programmer... when my wife tells me to go buy milk and if they have eggs, to get 10 - I don't return home with 10 milks :p (a little joke there).

So...HELLLLPPPPP!!!!! (a working piece of the so much desired spawn code from one of you "pfff I can do that in 20 seconds" guys would be awesome, but a link to instructions works too I guess...).
Live long and prosp...gank ACUs.
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 19 Feb 2018, 02:17

Can someone please provide some assistance?
I am trying to get ships from my navy scout platoon to spawn in the navy spawn point. What am doing wrong?
(also, it would be great if I could add a time index when those units spawn).

CreateUnitGroup = function(Blueprint, SpawnPoint, Quantity) --Used to creating enemy units outside the wave table

local strBluePrint = ''
strBluePrint = Blueprint
local POS = GetMarker(SURVIVAL_SPAWN_NAVY1).position
for i = 1, Quantity do
local NewUnit = CreateUnitHPR('NAVY_SCOUT_1', "ARMY_SURVIVAL_ENEMY", POS[1], POS[2], POS[3], 0, 0, 0)
end
end
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 20 Feb 2018, 15:16

The overwhelming assistance and enthusiasm of this forum makes me feel glad I am a part of this community :p

All joke aside, now. I really do need some assistance. Anyone? Please?
You will get cake... (it's delicious and moist).
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 20 Feb 2018, 17:38

Still noone :(

This is, roughly and ofc wrongly written (cause it does not work), what I want to get:

-- navy spawn in Survival 5thDimension
---------------------------------------------------------------------------------------------
SpawnNavyWave = function(UnitID, ArmyID, POS, OrderID, Quantity, SpawnTime) -- This is all I need :p but cannot get it to work

local UnitID = 'URS0201';
local ArmyID = "ARMY_SURVIVAL_ENEMY";
local POS = ScenarioUtils.MarkerToPosition("SURVIVAL_SPAWN_NAVY_1"); -- My added extra sea marker, 2 total
local OrderID = 2; -- this is supposed to be "attack move", no?
local Quantity = 1; -- or more
local SpawnTime = 1.5; -- Or whenever

Survival_SpawnUnit(UnitID, ArmyID, POS, OrderID, Quantity, SpawnTime) -- Does this do anything, is it needed?
end

Ok. The system has all the info it requires, but clearly I am missing something in the way it is executed, something the code needs. God I hate LUA...zero logic, zero user friendliness...how the hell are lawyers supposed to code, LUA? :p
HALP!
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby speed2 » 20 Feb 2018, 18:39

First there are dozens versions of 5th dimension survival. You didn't specify which one you're trying to edit. Mention what line you're changing and show us some code. I dont know how you expect anyone to help you without these information.

Then I have to say that all survival code I've seen to far was kinda not the best. It's working, but sometimes hard to find out what does what and how.

This is a function that can create a single unit https://github.com/FAForever/fa/blob/de ... #L247-L249 documentation is missing, but the parameter names should be clear, if not, you can check some examples here https://github.com/FAForever/fa/blob/de ... #L247-L249

For creating groups of units, you need to have some tables that will contain all the info about what units and where to spawn (and what to do with them) then either using some existing funtion from the survival to spawn them or making your own.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 20 Feb 2018, 20:14

Hi. Thank you for the reply.
The map I am altering is the standard Survival 5.th Dimension map, v2. (as far as I have seen all of them have the identical basic code, with some alteration to starting units for example. That is why I didnt refference which one).

The code in question starts from line 1243 - this, ore something that does this, is what I hope to use to spawn additional naval waves TOGETHER with the existing standard land waves. I have the naval spawn nodes, even copied the code that makes an additional MarkerId for the new naval spawn points (number 6, 1-5 referenced other locations)...but the problem is that I have to have the code below spawning stuff in land spawns and another like it spawning in naval spawns:

-- spawns a wave of units
--------------------------------------------------------------------------
Survival_SpawnWave = function(SpawnTime)

-- LOG("----- Survival MOD: Performing a wave spawn at " .. SecondsToTime(SpawnTime));

local WaveTable = nil;
local UnitTable = nil;

local UnitID = nil;
local OrderID = nil;
local POS = nil;
local RandID = nil;

-- check the wave table times vs the wave spawn time to see which waves we spawn
-- START AT TABLE 2 BECAUSE TABLE 1 IS SPECIAL UNITS (ARTY/NUKE)
for x = 2, table.getn(Survival_WaveTables) do -- loop through each of the wavetable entries (ground/air/sea...)

-- LOG("----- Survival MOD: Category(" .. x .. ") Wave Set (" .. Survival_WaveTables[x][1] - 1 .. ") (ID: " .. Survival_WaveTables[x][1] .. ");

-- for the amount of units we spawn in per wave
if (table.getn(Survival_WaveTables[x][Survival_WaveTables[x][1]]) > 1) then -- only do a wave spawn if there is a wave table available
-- for the amount of units we spawn in per wave
for z = 1,Survival_UnitCountPerWave do

WaveTable = Survival_WaveTables[x][Survival_WaveTables[x][1]]; -- grab the wave set table we're spawning from
RandID = math.random(2, table.getn(WaveTable)); -- pick a random unit table from within this wave set
UnitTable = WaveTable[RandID]; -- reference that unit table

UnitID = Survival_GetUnitFromTable(UnitTable); -- pick a random unit id from this table
OrderID = UnitTable[2]; -- get the order id from this unit table (always 2nd entry)

POS = Survival_GetPOS(3, 25);

Survival_SpawnUnit(UnitID, "ARMY_SURVIVAL_ENEMY", POS, OrderID);
end
end

end

end


(((---------ALTERNATIVELY THIS)))

-- spawns a specified unit
--------------------------------------------------------------------------
Survival_SpawnUnit = function(UnitID, ArmyID, POS, OrderID) -- blueprint, army, position, order

-- LOG("----- Survival MOD: SPAWNUNIT: Start function...");
local PlatoonList = {};

local NewUnit = CreateUnitHPR(UnitID, ArmyID, POS[1], POS[2], POS[3], 0,0,0);

-- prevent wreckage from enemy units
-- local BP = NewUnit:GetBlueprint();
-- if (BP != nil) then
-- BP.Wreckage = nil;
-- end

NewUnit:SetProductionPerSecondEnergy(325);

table.insert(PlatoonList, NewUnit); -- add unit to a platoon
Survival_PlatoonOrder(ArmyID, PlatoonList, OrderID); -- give the unit orders

end

Also, i have tried the code you provided earlier, but cannot get it to work (since I do not know what the parameters should look like, and the 2.nd link you provided is identical by oversight I guess). This one, I mean

function CreateUnitHPR(blueprint, army, x, y, z, pitch, yaw, roll)
end
(blueprint is unit blueprint, army is easy too, but xyz? Pitch etc... is all 0 I guess?).


And the reason I dod not show any code earlier is because I thought I was asking something very basic and widely used- (how to spawn a unit at a given time at a given location and order it). Guess nothing is basic about LUA :p

anyways...thank you!
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 20 Feb 2018, 20:48

also sorry for my impatience, however I have been reading 10 different survival's data for the last 5 days now, trying to figure out for myself before I ask for help.

It is...frustrating. i have so many ideas but this language is way too abstract for me, to put them to life. Way, waaaaaaaaay too many unknown variables and parameters for me to solve by logic, or guessing.
I am a map maker, always been, be it Heroes of might and magic or Starcraft...god, what I would do for SupCom to have a brilliant map Editor like Starcraft...
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 21 Feb 2018, 02:40

ok so here's what I did - added 2 new functions based on the Survival_SpawnWave (line 1243)) and the Survival_SpawnUnit functions (line 1287)

-- spawns a wave of units
--------------------------------------------------------------------------
Survival_SpawnNavy = function(SpawnTime) ((I TRIED ADDING AN EXTRA SPAWN FUNCTION))

-- LOG("----- Survival MOD: Performing a wave spawn at " .. SecondsToTime(SpawnTime));

local WaveTable = nil;
local UnitTable = nil;

local UnitID = nil;
local POS = nil;
local RandID = nil;

for x = 3, table.getn(Survival_WaveTables) do ((I ADDED AN EXTRA WAVE ID IN THE WAVETABLE, REFFERENCING IT HERE WITH THE 3, ALSO ADDED AN EXTRA COLUMN IN THAT TABLE TO REFFERENCE MARKER POSITION))

if (table.getn(Survival_WaveTables[x][Survival_WaveTables[x][1]]) > 1) then
-- for the amount of units we spawn in per wave
for z = 1,Survival_UnitCountPerWave do

WaveTable = Survival_WaveTables[x][Survival_WaveTables[x][1]]; -- grab the wave set table we're spawning from
RandID = math.random(3, table.getn(WaveTable));
UnitTable = WaveTable[RandID]; -- reference that unit table

UnitID = Survival_GetUnitFromTable(UnitTable); -- pick a random unit id from this table
OrderID = UnitTable[2];
POS = Survival_GetPOS(UnitTable[3], 0); ((BORROWED THIS FROM SURVIVAL_SPAWNSPECIALWAVE, ADDED AN EXTRA COLUMN WITH THE MARKER VALUE IN THE NEWLY ADDED WAVETABLE))

Survival_SpawnNavy(UnitID, "ARMY_SURVIVAL_ENEMY", POS, OrderID); ((THIS FOR THE NEXT FUNCTION BELOW))

end
end
end
end

-- spawns a specified unit
--------------------------------------------------------------------------
Survival_SpawnNavy = function(UnitID, ArmyID, POS, OrderID) -- blueprint, army, position, order ((ADDED A NEW FUNCTION BASED ON THE SURVIVAL_SPAWNUNIT))

-- LOG("----- Survival MOD: SPAWNUNIT: Start function...");
local PlatoonList = {};

local NewUnit = CreateUnitHPR(UnitID, ArmyID, POS[1], POS[2], POS[3], 0,0,0);

NewUnit:SetProductionPerSecondEnergy(325);

table.insert(PlatoonList, NewUnit); -- add unit to a platoon
Survival_PlatoonOrder(ArmyID, PlatoonList, OrderID); -- give the unit orders

end


the ((CAPLOCKS)) are not in the code ofc ;)
well...if I got everything right that code should work I guess...but I cannot implement it in the Survival_Tick = function (line 1112) where i see that the Survival_SpawnWave(Survival_NextSpawnTime); is (line 1149), which I guess is how the game initializes it. Any ideas how to do it, and if the stuff I copy-pasted make sense at all?
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Survival - spawning "side" waves independent from main w

Postby speed2 » 21 Feb 2018, 03:10

Can you use pastebin when posting code? Or theres even formating when you re typing a reply on the forums that says code

Without that its unreadable
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Survival - spawning "side" waves independent from main w

Postby DDDX » 21 Feb 2018, 03:18

pastebin. Cool, did not know of it.
Here's a link

https://pastebin.com/b39kqg48



Code: Select all
-- spawns a wave of units
--------------------------------------------------------------------------
Survival_SpawnNavy = function(SpawnTime) ((I TRIED ADDING AN EXTRA SPAWN FUNCTION))

-- LOG("----- Survival MOD: Performing a wave spawn at " .. SecondsToTime(SpawnTime));

local WaveTable = nil;
local UnitTable = nil;

local UnitID = nil;
local POS = nil;
local RandID = nil;

for x = 3, table.getn(Survival_WaveTables) do ((I ADDED AN EXTRA WAVE ID IN THE WAVETABLE, REFFERENCING IT HERE WITH THE 3, ALSO ADDED AN EXTRA COLUMN IN THAT TABLE TO REFFERENCE MARKER POSITION))

if (table.getn(Survival_WaveTables[x][Survival_WaveTables[x][1]]) > 1) then
-- for the amount of units we spawn in per wave
for z = 1,Survival_UnitCountPerWave do

WaveTable = Survival_WaveTables[x][Survival_WaveTables[x][1]]; -- grab the wave set table we're spawning from
RandID = math.random(3, table.getn(WaveTable));
UnitTable = WaveTable[RandID]; -- reference that unit table

UnitID = Survival_GetUnitFromTable(UnitTable); -- pick a random unit id from this table
OrderID = UnitTable[2];
POS = Survival_GetPOS(UnitTable[3], 0); ((BORROWED THIS FROM SURVIVAL_SPAWNSPECIALWAVE, ADDED AN EXTRA COLUMN WITH THE MARKER VALUE IN THE NEWLY ADDED WAVETABLE))

Survival_SpawnNavy(UnitID, "ARMY_SURVIVAL_ENEMY", POS, OrderID); ((THIS FOR THE NEXT FUNCTION BELOW))

end
end
end
end

-- spawns a specified unit
--------------------------------------------------------------------------
Survival_SpawnNavy = function(UnitID, ArmyID, POS, OrderID) -- blueprint, army, position, order ((ADDED A NEW FUNCTION BASED ON THE SURVIVAL_SPAWNUNIT))

-- LOG("----- Survival MOD: SPAWNUNIT: Start function...");
local PlatoonList = {};

local NewUnit = CreateUnitHPR(UnitID, ArmyID, POS[1], POS[2], POS[3], 0,0,0);

NewUnit:SetProductionPerSecondEnergy(325);

table.insert(PlatoonList, NewUnit); -- add unit to a platoon
Survival_PlatoonOrder(ArmyID, PlatoonList, OrderID); -- give the unit orders

end
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Next

Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest