Page 1 of 1

RTS - Command Units Mod

Posted: Thu May 07, 2015 11:19 pm
by Earendel
I'm thinking about making a mod to add a few RTS aspects to the game. The key feature is:
Automated ground units that you can command.

I'm envisioning that vehicle commands would mainly be managed by assigning the vehicle to a number of named regions. Regions would be created with a blueprint-like tool, and vehicles would have assigned regions in the same way trains have stations. The vehicle travels to the region, patrols within it, and auto-attacks enemies in range. You would set up your base to mass-produce vehicles, deploy them, fuel them, and assign them a default region - like 'Rally 1'. 'Rally 1' could be a set or rectangles that circles your base for patrols, or it could be a single rectangle that you keep moving over the next enemy base.

From a style and diversity point of view, the main sources of inspiration add are Dark Reign, and Planetary Annihilation, but everything would be done with a focus on logistics and automation.

Nice-to-have features would be things like:
Garage building places / deploys the vehicle object (not as an item) so it can drive itself out of the garage.
Modularise chassis /weapons, so make them separately and combine for dedicated vehicle roles. Attach any weapon to a chassis - certain combinations boost and reduce certain stats to match the weapon role. (Rocket tank weaker than a flame tank or shotgun 'flak' tank).
Aircraft that can be automated and piloted.
Order units to attack specific targets.
Rally points.
Behaviours - like damage threshold before retreat, follow distance
Automated vehicles could be commandeered for manual control.
Vehicles could have logic: move here if cargo is less than, else move here...
Electrical vehicles, need to recharge instead of refuel.
Modularise turrets based on vehicle system.
Overhaul biter classes to make weapon diversity more important.
Utility vehicles for hauling, mining, roboports, repairs, mobile logistics chests, mobile refuelling platforms, mobile recharging platforms, etc.

So my first question is:
Has anyone done anything like this?

If so, I'd prefer to help with their project than start from scratch.
If not, then I would like a few tips on the best way to approach the core unit functionality. Here are a few thoughts that I'm not sure about:

From what I've seen so far, there are a number of entity types, but there's no way to add new types in the same way that the core ones are added?
I'll have to add lua scripts to an existing type that's the closest match to add on the missing functionality.
The starting types that might be useful seem to be:

Unit (Enemy) - Has existing Ai, pathfinding, auto-attack, order / behaviour system. Lacks vehicle physics, turning rate. Cannot be possessed (manually driven). No inventory, fuel burning. Seems to randomly decide to go on a killing spree even when part of the player faction. Overriding existing behaviour might be more work than adding to a different type.
Car - Has vehicle physics, attacks, inventory / storage, burns fuel, can be possessed (manually driven). Lacks AI, Pathfinding, auto-attack.
Combat Robot - Has auto-attack.
Turret - Has auto-attack, inventory (ammo only).

Initially I thought that 'Enemy' would be the best starting point, but maybe extending the car type would be the best option in the long run?

Re: RTS - Command Units Mod

Posted: Tue Jun 23, 2015 11:22 pm
by SigmatroN
Wow, that's a very ambitious project you have there.
First of all, I don't think that's a good idea to make an AI, that commands an object with physics. You need to make not only a pathfinding, but take into the account acceleration, deceleration, turn speed. Damn, this would be processor hungry! I would be surprised if Factorio can handle a single AI of these, not to mention a dozen. I just don't really grasp a concept of an RTS with units affected by physics.
As for units' AI, I think it's more suitable for your need's that you might think. Well, inventory, fuel and possession - the things I don't think it is capable of. (Fuel, however can be implemented by some other means) I think biters don't really run to attack, they are just being recalled by the nearest spawner. You can try to create unit groups from them, this will make them far more obedient (Remember biters, gathering to make an attack, staying still in place and not twitching a muscle). I think this also can solve their 'expiration' problem, which makes them to die over time.
EDIT: For non-combat applications i think it would be better to start off from train

Re: RTS - Command Units Mod

Posted: Wed Jul 01, 2015 11:54 am
by jorgenRe
That sounds like an awesome idea :D!
I think if i where to do such a mod i would probably have for simplicity the machines to move in straight lines between two points you have put down :)
How?
Well when they move they use the findentitiesfiltered function to look for that point you put down. And when it finds one it turns around and moves the other direction!
Though you are totally free to do it however you like and this is just a very simple way of doing it that i'm suggesting ;)

Re: RTS - Command Units Mod

Posted: Wed Jul 01, 2015 12:39 pm
by ThaPear
jorgenRe wrote:That sounds like an awesome idea :D!
I think if i where to do such a mod i would probably have for simplicity the machines to move in straight lines between two points you have put down :)
How?
Well when they move they use the findentitiesfiltered function to look for that point you put down. And when it finds one it turns around and moves the other direction!
Though you are totally free to do it however you like and this is just a very simple way of doing it that i'm suggesting ;)
This is more easily achieved by just remembering the two markers and calculating the distance to the next one. (Close enough -> go to next marker)
That would also allow you to do more complex paths with more markers.

Re: RTS - Command Units Mod

Posted: Sat Jul 04, 2015 9:22 pm
by dalsio
I commend you for thinking ambitiously. I certainly have not seen of anyone making such a mod, and it would be an interesting alternative/supplement to turret defense systems. Unfortunately, you're fighting an uphill battle. Factorio's prototype definitions are pretty much set in stone as far as what they can do. Most of what you want to do would need t be done through scripts which take time and cpu resources. A complex AI is technically possible, but as SigmatroN mentioned would probably be difficult and power-hungry.

My best advice: Start small and basic. Begin with a simple "skeleton" of what you might want and work up from there. The base you work from is all dependent on what entity you start with.

If you're dead-set on having smooth car-like movement and physics, you're most assuredly going to want to start with either a car or locomotive entity as your base. Almost nothing else has physics and motion the way they do and programming that from a script would be a nightmare. If you really want completely free motion, try the car. If you're OK with a predetermined path for your vehicles, and want your life easier, use the locomotive. It already I believe has a lot of what you might want in it's programming.

If you want to start more with the AI and commands, and add other stuff later, start with prototypes/unit. It has some functionality related to basic AI and ability t command where it goes that can be useful if that's your focus.

Prototype/character is an interesting start, since it already has provisions for equipment, health, weapons, inventory, and movement, though you'll have to figure out how to control one remotely and create/operate them separate from an actual player.

No matter what you start with though, what you're proposing is not in any way easy. As I said, these prototype definitions are insanely inflexible so anything you do will have to be essentially made from scratch. If you're new to modding, I don't suggest you do it for your first mod. Such an endeavor will likely cause a lot of frustration and take a lot of time and effort, and you might get discouraged before you've been able to finish and release it. It would be better imo to start with something smaller, where you can get it released quickly and get feedback, experience, and that sweet, sweet feeling of reward. Then maybe once you've had a taste, go for the bigger project. But don't let me discourage you; if you're serious about persevering through the frustration and difficulty, more power to you.