Jump to content

Morale System for 0 A.D


azayrahmad
 Share

Recommended Posts

Overview

This mod adds morale system to 0 A.D. Please read an overview of morale in Wikipedia page here. This mod tries to represent military morale and to some extent also employee morale (for workers).

Morale system here is inspired from a mix between Total War and Stronghold style morale. So basically the higher the morale, the better your units at gathering, building, and fighting, and vice versa. Morale is influenced by unit's health, being attacked, being near other units, etc. On a very low morale, units will flee the battlefield.

I originally develop this mod for Happiness system in my City Building Mod, however it became more complicated so I decided to release it separately as Morale system. Therefore, this mod is designed to be as bare-boned and customizable as possible, so it will be compatible to many mods, although the mod should be quite playable as it is. 

screenshot0008.png.c4240e4c3a497f8eca219b96f7b60cd4.thumb.png.35e13028b31510d827116b4e76512053.png

Features

  • Every unit has morale icon to represent its current state. 
  • Some aspects that can influence unit morale:
    • Presence of other units on viewing distance. Allies increase morale and enemies decrease morale.
    • Being attacked. Arrow shots would decrease morale, even if it missed.
    • Health increase/decrease. Morale would increase/decrease accordingly.
    • Unit death would cause significant morale decrease to nearby allies and vice versa.
  • Low morale can cause a unit to have decreased gathering rate, building rate, and attack rate. Extremely low morale cause unit to flee from enemy and became passive. Units reaching max morale would cheer and start becoming violent.
  • Structures can also have morale. Structures with low morale can have reduced attacks speed and also slower training and research time. Garrison units with high morale inside for increased morale.
  • Some variables that can be customized for further modding (mostly need to edit component variable but later planned to be customizable via template):
    • Significance (the higher unit significance the higher influence it has on nearby units)
    • Range (by default it uses unit vision but can be altered)
    • RegenRate (default morale regenerate rate)
    • etc (please look at Init function of Morale.js)

Installation

Clone or download the mod from GitHub page to My Games/0ad/mods folder. (I will add mod.io link later)

Contribute

This mod is very much a work in progress. Everyone is certainly welcome to contribute by testing the mod and tell me what you think! If you found issue or have some ideas you'd like to implement, feel free to discuss here or even create Pull Request to the GitHub repo. 

I also currently have no access to a better quality computer to create high quality screenshot/video preview, so you can share your screenshots here as well!

Credits

Thank you very much to:

  • @Freagarach, @wraitii for helping out on problems I encountered with some components (see the discussion behind the scene here)
  • @Grapjasfor letting me adapt his Wounded feature from Grapejuice mod (another interesting mod you should check)
  • @wowgetoffyourcellphone for arrow morale damage suggestion and fear units (implementable by Significance, but not yet). 
Edited by azayrahmad
vid
  • Like 10
  • Thanks 7
Link to comment
Share on other sites

On 29/3/2021 at 10:34 AM, wowgetoffyourcellphone said:

Nice. You could make the presence of a hero give a morale boost, while his/her death would cause a morale decrease. :) 

This is achievable using Significance, which multiplies morale regenerate rate effect and death instant morale damage/bonus to nearby enemies/allies. 

However I avoid editing template files for now to keep compatibility with as many Alpha versions and mods as possible. I'd probably release template changes either as separate mod or as part of City Building mod. 

Edited by azayrahmad
  • Like 1
  • Thanks 3
Link to comment
Share on other sites

  • 2 weeks later...

Recent changelog:

  • Improved fleeing behavior (low morale units flee when sighting enemy or being attacked)
  • Unit Stance change based on morale (low morale units automatically have Passive stance, high morale units have Violent stance).
  • Units reaching maximum morale will cheer.
  • Average morale display on multiple units selection in selection panel.
  • Morale for structures is now supported, complete with garrison morale effect and capture points reduction on low morale.

Plans for next updates:

  • Improve performance (currently noticeable in large battles, but should be fine on smaller maps).
  • Rage/amok behavior (raging unit attacks both ally and enemy)
  • Multipliers for specific classes (e.g. cavalry should decrease enemy infantry morale more, or camel's stench should decrease cavalry morale for allies and enemies alike).
  • Player's multiplier (players with bigger city and more kills will decrease enemies' morale more)
  • Complete morale setting differentiation of different unit types and ranks and also structures. (Higher ranks units, champions and heroes should have higher Significance and max morale)
  • Complete code documentation to make the mod easier to use as dependency for other mods.

Let me know if you guys have some more suggestions!

Edited by azayrahmad
  • Like 5
Link to comment
Share on other sites

  • 2 weeks later...

Recent changelog:

  • Cheat codes for morale. Type 'moralize' or 'demoralize' on selected unit(s) to fill up or empty morale respectively.
  • Flank morale bonus. Units attacked from the side or behind deplete morale faster.
  • Class morale bonus. Units can have morale influence bonus on specific classes and alliance.
  • Template differentiation. Now units with different classes and ranks have different morale points and significance.
  • Code has been documented for easier modding.
  • Separate Morale and Influence. It is now possible for an entity to have influence without being affected itself.

0AD-morale-system-0.0.1.pyromod

Edited by azayrahmad
Add template differentiation
  • Like 5
Link to comment
Share on other sites

Then civs will have morale bonuses, whether they use formation or not
Romans and Greeks, with closed formations will have bonuses, on the other hand the Celts and Iberians in open formations or without formations
The naked fans and the fire cav iber will have more morale than normal if they go alone and have more than x% HP 

i love this concept 

Link to comment
Share on other sites

  • 4 months later...

Formations should have a very important role on morale, shouldn't they ?

(going both way : units with low morale leaving formation - historically, mainly from the rear, that's one of the reasons to have multiple ranks - and units still in formation getting some morale bonus, the level of which depends on the formation)

Link to comment
Share on other sites

  • 8 months later...

Wow, this is incredible. Glad I came across it. Will you release another update?

If so, it would be cool if the units with super low morale could switch sides.

It would be great for my mod where I could implement a morale system for my Lords who could lose morale and turn against me if I don't keep them happy.

  • Like 1
Link to comment
Share on other sites

26 minutes ago, LordStark said:

If so, it would be cool if the units with super low morale could switch sides.

I would LOVE this, especially for Mercenaries in my opinion. Mercenaries aren't going to die for you haha. This has always been their problem, so paying them off or cornering them could be an important strategy.

  • Like 1
Link to comment
Share on other sites

Yes, good point. I would only want certain units to be potentially traitors. Perhaps it could be a option that we can mod into the units ourselves.

I would have my Lords and Mercenaries as potential traitors but the Men at Arms of my retinue are 100% loyal.

Also, it would be good if there was some way that a group of units could betray you together. As an example, if it were a feature in my mod, one of my Lords might have an aura that can be used to convert nearby citizen soldiers ((but not the main Lord's (the player) Men at Arms)  to him which he stitches sides. 

  • Like 1
Link to comment
Share on other sites

14 minutes ago, LordStark said:

Yes, good point. I would only want certain units to be potentially traitors. Perhaps it could be a option that we can mod into the units ourselves.

I would have my Lords and Mercenaries as potential traitors but the Men at Arms of my retinue are 100% loyal.

Also, it would be good if there was some way that a group of units could betray you together. As an example, if it were a feature in my mod, one of my Lords might have an aura that can be used to convert nearby citizen soldiers ((but not the main Lord's (the player) Men at Arms)  to him which he stitches sides. 

Yes I would agree. I think certain units would have very high morale and they would fight more ferociously when wounded, rather than betray you. This could apply to Norse maybe, and a lot of elite units and heroes.

Edited by myou5e
spelling
Link to comment
Share on other sites

  • 10 months later...
On 12/06/2022 at 3:21 PM, myou5e said:

I would LOVE this, especially for Mercenaries in my opinion. Mercenaries aren't going to die for you haha. This has always been their problem, so paying them off or cornering them could be an important strategy.

Interesting indeed, especially if there's an upkeep for Mercenaries, and the mercenaries' morale largely depends on whether this upkeep is paid in full or not.

  • Like 1
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...