Jump to content

How to add/change code to move units to simulate fighting between two armies


Wuyeh
 Share

Recommended Posts

Hello, we are working on a project to simulate fighting between two armies using the 0AD engine. We have a challenge getting started. Specifically, after creating our mod, we don't know what code to add and/or change to achieve our goal. Any tutorials or tips would be helpful.

  • Thanks 1
Link to comment
Share on other sites

Perhaps you want to be more specific on what changes do you want implemented exactly.

Generally, you'd probably be interested in https://trac.wildfiregames.com/wiki/Modding_Guide for beginners. https://trac.wildfiregames.com/wiki/Mod_Layout#simulation is probably what you want to be focused on, but you can read it entirely to get a gist on how 0AD code is organized.

Link to comment
Share on other sites

On 18/04/2021 at 5:48 AM, azayrahmad said:

Perhaps you want to be more specific on what changes do you want implemented exactly.

Generally, you'd probably be interested in https://trac.wildfiregames.com/wiki/Modding_Guide for beginners. https://trac.wildfiregames.com/wiki/Mod_Layout#simulation is probably what you want to be focused on, but you can read it entirely to get a gist on how 0AD code is organized.

We've taken a look at this and able to set up a mod and view it in the Game under "Mod Selection" but we found the simulation part overwhelming. 

If we want to move units in the game, for instance, where should be looking at and what should we add to the mod we created?

Link to comment
Share on other sites

2 hours ago, Wuyeh said:

What is a cohort?

Specifically the cohort system was such: (not literally, mistakes are certain)
It was a Operation system between Divisions.
Say, you would have a 5by5, then 4 more 5by5's north and south in a square. Like so:
AAAAA  AAAAA  AAAAA  AAAAA  AAAAA
AAAAA  AAAAA  AAAAA  AAAAA  AAAAA
AAAAA  AAAAA  AAAAA  AAAAA  AAAAA
AAAAA  AAAAA  AAAAA  AAAAA  AAAAA
AAAAA  AAAAA  AAAAA  AAAAA  AAAAA
It was the key to Romes Success. They had 100x supremacy because they were 100% more Organized. :)
Everyone else just shoved all their infantry into one big line and said "charge" or "lock shields" (or point pointy larrissa in Alexanders case)

The system is still used today by the great nations. Obviously with different names.
The Individual A being an infantry unit, and the AAAAA being the group. The advantage of this system is that when the front line is tired/breaking they can fall back and get some rest and the second line can go forward to replace them. And vice/versa.

Edited by Auron24015
Link to comment
Share on other sites

3 hours ago, Wuyeh said:

We've taken a look at this and able to set up a mod and view it in the Game under "Mod Selection" but we found the simulation part overwhelming. 

If we want to move units in the game, for instance, where should be looking at and what should we add to the mod we created?

Well, in this game we're supposed to move the units ourselves. But if you mean how to change how AI behaves, you probably want to look at ai/petra inside simulation. When you play single player against computer, you're fighting this Petra ai.

Does this answers your question? 

Link to comment
Share on other sites

Hi @Wuyeh and welcome to the forum,

To manually make units do tasks like move and attack (without AI) you might want to look into the UnitAI component. To spawn units you might want to look inside TriggerHelper.

4 hours ago, Wuyeh said:

but we found the simulation part overwhelming

Thats how it started for the most of us, at least for me :).

Do you have javascript knowledge? I'm asking so that we know how discriptive we need to be when explaining stuff.

Link to comment
Share on other sites

1 hour ago, Wuyeh said:

Where in the 0AD engine code can we move a soldier/civilian from one point to another?

You could use this function from Triggerhelper to get the entity ID of the unit you would want to move.

Make that entity the system entity like so: 

let cmpUnitAI = Engine.QueryInterface(putEntityIDHere, IID_UnitAI);

Check line 5294 of UnitAI.js. You can call that function like so:

cmpUnitAI.Walk(x, z, queued, pushFront);

 

If you want to move multiple id's you would have to use loops and if statements.

You can also learn alot from other maps, 2 maps are prime examples that spawn and move armies by code which are Danubius and Jebel Barkal

(more experienced modders, feel free to correct me)

Edited by Grapjas
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...