Another random unit spawning module

Go down

Another random unit spawning module Empty Another random unit spawning module

Post by Regg on Wed 01 May 2013, 03:39

First of all, I need to give credit to tjdagger for his random unit spawn module, as this module is completely based upon his work. Set up varies slightly...

  1. Download, extract, and import randomSpawnZone.markerscollection.xml to your mission. (Don't forget to update the Autocomplete.xml and LuaSyntax.xml files.)
  2. Make sure player and mp players are registered with EDX:registerPlayer() and EDX:registerPlayable(), respectively. This is required!
  3. Create exportable entity sets for each unit type (rifleman, engineer, medic, etc.) you want to spawn. Each entity set should contain a single unit and a parent echelon for that unit.
  4. Create a trigger zone on the map.
  5. Create an exportable entity set containing all the recon points to use as spawn locations. The recon point names must start with one of the listed spawn point types, or they will not be used. Paths placed in this entity set will be used for units spawned at patrol spawn points. Additionally, props can be placed in this entity set and will be spawned and despawned as triggered.
  6. Add the following function to your code:
    EDX:addRandomSpawnZone(string zoneName, number minSpawn, number maxSpawn, number despawnDistance, string side, table entitySetsPLA, table entitySetsUS, string zoneEntitySet, boolean enabled)
  7. Have fun!

I play a lot of co-op DR, so this module was built with that in mind. Spawning will begin when any player enters the trigger zone, and despawning will only happen after the last player leaves the zone (accounts for player deaths and respawns, too). Units will not despawn if they are within the specified 'despawnDistance' of any EDX-registered player.

Zones will change sides after all units are killed, but if no entity sets are given for the opposing side, the zone is essentially cleared. No more spawning of units will occur, although props will continue to spawn and despawn. If entity sets are available for both sides, the number spawned will be randomized (within range) each time the side changes.

The first four letters of each spawn point name must be one of the following:
  • "assa" -- assault nearest enemy
  • "defe" -- defendLocation of spawn point
  • "pbaf" -- patrol "backandforth" along nearest path, starting from nearest point
  • "pcyc" -- patrol "cyclic" along nearest path, starting from nearest point
  • "rush" -- rapidMove to nearest enemy
  • "sear" -- searchAndDestroy around spawn point, radius defined by searchRadius

Paths are automatically detected, so there is no need to place them in a group. Single waypoints are ignored. Patrolling units will move past their closest waypoint and pause for random time at each subsequent waypoint in the path.

There are a few global settings at the top of the script, and they are documented there. A sample mission is included, and lots of debugging is available by setting those flags to true.

Available commands:

  • EDX:addRandomSpawnZone(zoneName, minSpawn, maxSpawn, despawnDistance, side, entitySetsPLA, entitySetsUS, zoneEntitySet, enabled) --Creates a zone for randomly spawning units. Returns true if successful.
  • EDX:disableRandomSpawnZone(zoneName) --Disables a zone for randomly spawning units. Returns true if successful.
  • EDX:enableRandomSpawnZone(zoneName) --Enables a zone for randomly spawning units. Returns true if successful.
  • EDX:isRandomSpawnZoneEnabled(zoneName) --Returns true if random unit spawn zone is enabled.
  • EDX:removeRandomSpawnZone(zoneName) --Removes zone for randomly spawning units, but will not despawn any currently spawned units or props. Returns true if successful.
  • EDX:setRandomSpawnZoneLimits(zoneName, minSpawn, maxSpawn) --Changes spawning limits for a zone's next spawn cycle. Returns true if successful.
Events:

  • onZoneSideChange(zoneName, side) --Fires after all randomly spawned units are killed.

Download version 1.0

Feel free to ask questions and tear my work to shreds!!
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by John J. Stevens on Wed 01 May 2013, 12:19

Seems like you are getting more than knee deep into the code - continue the ride since it is a pain to get back on. Need to look at the (both sets) code to see how it deals with manned vehicle like a helicopter.


Another random unit spawning module Steven13
John J. Stevens
John J. Stevens
Admin

Location : WV/PA
Points : 284
Reputation : 21
Join date : 2012-12-19

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by Regg on Wed 01 May 2013, 18:10

I didn't take into account vehicles with this module, so expect interesting results. Wink

At least initially, I just wanted to mirror the functionality of tjdagger's random spawn module. Since he's also been working on a vehicle module (don't think it's been officially posted yet), I decided not to mess with vehicles.
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by TheGeneral on Wed 01 May 2013, 22:52

Excellent work Regg!

I'm pretty sure Mr Dagger will appreciate this, what we need to be mindful off though with creating other modules is falling into the "extension off" approach to modifying other peoples files. I say this only because during the older days of DR when the CM forums were thriving with coders and programmers, a whole heap of DB's got produced and it became a mindfuck trying to figure out what was the best one to suit for the mission purpose. I think I was discussing this the ohter day with J.S.

Like Tvig used to say, "If it ain't broke don't fix it!"

But I'm sure there will be added benefits to this as I believe you are not out of your depth with coding LUA etc. Any chance you can show us a vidoe tut on it all. I would ideally like to see a whole heap of video tuts on all the modules for the sake of the noob when it comes to the edx so that it doesn't seem so daunting to use.

Side note: I have now got my files trnasfered over from the old pc and will look at posting them up on here by the weekend. This includes the last "update" of the EDx and the Quickstart module. I will also release the modules I have so that they are available from one location. then get into making a some videos. (when I get round to it, work for me is picking up now).

Nice work once again Regg! keep it up!

MD. Smile


tvig0r0us wrote:Thanks to everyone that has supported and stuck with OFDR along the way. It is a great game and is largely under appreciated, but those of us that love it are happy to have others to enjoy it with.

tvig


Another random unit spawning module Nst_md15
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by Regg on Wed 01 May 2013, 23:36

Thanks for the kind words, MDog!

As I've already been dealing with the DB debacle, I know where you're coming from. This module works independently of TJDagger's module, and is essentially an upgraded version of his work. Maybe I should have called it 'v2.0'. If you're familiar with his random spawn module, then setup is the same. The main difference is that his module requires adding all the data (names, etc.) to the top of his script, while my module uses a function (placed in onMissionStart or wherever you want).

TJDagger did a nice little PDF for his module, so maybe we could just update that and include it with this module. I've never recorded a video on my PC, but I know other members have. Maybe someone will put one together?

My intent is not to duplicate efforts or confuse people. I just saw an opportunity for improvement. If the community, particularly TJDagger, agrees, I would like to focus future development on a single random spawn module.
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by tjdagger on Thu 02 May 2013, 03:13

Wow!
I had a look over the code.
I can easily see the the difference between a "self taught" coder and an "old hand" at it.
It would take some serious mental power to digest all the changes, so I will not even try at this stage.

However, I got some "big picture" issues to point out.
1.
Paths are automatically detected, so there is no need to place them in a group.
Originally this was my line of thinking also, but as you progress towards ground vehicles and helos you will encounter the need to separate paths into categories. eg flightpath, roadpath, patrolpath.
This will prevent vehicles from auto finding patrolpaths and wandering away from roads, units trying to reach a point 100m in the air, helos from touching the ground etc. PLUS there comes a whole other level of dynamics involved with having vehicles traverse across the map in relation to player movements.
Food for though.
2.
I play a lot of co-op DR, so this module was built with that in mind. Spawning will begin when any player enters the trigger zone, and despawning will only happen after the last player leaves the zone (accounts for player deaths and respawns, too).
Have you had a chance to test this in a large setting during co-op? During my tests I found that situations arose where multiple zones became active with spawning of units and props. While this is of course is intended, multiple units led to zones not fully spawning, props being invisible etc, and the opportunity to clear a zone without encountering enemy. The original concept was for a full island map with overlapping spawn zones, which is essential for the type of maps I've previously made.
I found it was a requirement for prop and unit placement to be mindful continuously of prop rendering and unit limits in relation to how many zones could be active at one time and the content of those zones. Not to prevent a spawn crash, because as you know the code accounts for such things, but instead to have a mission dynamic but at the same time be able to exert a desired level of control as a mission maker. With one unit you can easily foresee what can be activated at any one time with a high level of certainty. But with up to four spawners you need to consider what can be potentially activated from with a 250m radius from any given point on the map.
First and foremost from a mission making point of view I concluded that the benefits (and pitfalls) of having one unit control spawning outweighed the added potential considerations (and pros) involved in having multiple units effect spawning.

Regg, we should get together and play a couple mission like "D-day", "nighthawk", "SFGW" and "Island Adventure" together to high light some issues/solutions I've encountered.

Other than that I'm blown away by your coding and dedication to the project.
Cheers


Another random unit spawning module 8adb54ef2dbe24a4ccf87626e12261e7

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 43

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by Regg on Sun 05 May 2013, 00:09

Item #1 wouldn't be too difficult to change. Maybe have the script check each waypoint in the set for membership in a 'patrolpath' group, just to make sure points are available for patrolling. Of course, depending on how things are laid out, a 'patrolpath' which isn't part of the zone's entity set could be closer than any included path. I was trying to keep things self-contained.

I'm still undecided about your second point. While I haven't yet deployed and tested this in a large MP mission, I can definitely understand your concerns. Thankfully, this module will not allow a zone to be cleared without something getting killed! But you could still have zones not spawning any units due to quota limits, requiring players to leave and re-enter the zone after the quota drops.

It comes down to mission design, and no one size seems to fit all. I've been tossing around the idea of making the trigger system a global setting, thus allowing the mission maker to choose either single or MP spawning. But I'm interested in feedback from others out there. How does everyone (or anyone) else feel about this?
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Another random unit spawning module Empty Re: Another random unit spawning module

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum