Jump to content

Search the Community

Showing results for tags 'rangemanager'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome
    • Announcements / News
    • Introductions & Off-Topic Discussion
    • Help & Feedback
  • 0 A.D.
    • General Discussion
    • Gameplay Discussion
    • Game Development & Technical Discussion
    • Art Development
    • Game Modification
    • Project Governance
    • Testing

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


First Name


Last Name


Skype ID

Found 1 result

  1. So I'd like to create a Morale system mod... My plan is to make it to be some kind of Aura of units that influences other units in range. However I need it to be more dynamic, i.e. the effect strength would change according to unit's own morale strength. I decided to create separate component. Morale.js. There are two mechanisms in this component: (1) Morale level and how it affects unit performance. This is similar to how Health.js works. (2) Unit effect on other units in range based on its own morale level. This is intended to be similar to how Auras.js works. The first one already work, but the second one is not yet. I still don't understand why the effect is not applied yet. This is the repository on GitHub: https://github.com/azayrahmad/morale-system The problematic part is in simulation/components/Morale.js. Here are the snippet of the relevant parts: Init: Morale.prototype.Init = function() { this.affectedPlayers = []; ... this.CleanMoraleInfluence(); ... }; The CleanMoraleInfluence(), intended to be similar to Clean() function from Aura.js. The target here is to apply morale influence to any allied units in 10m range. (GetAllies() also includes player's own units right?) Morale.prototype.CleanMoraleInfluence = function() { var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); //Remove Morale let targetUnitsClone = []; if (this.targetUnits) { targetUnitsClone = this.targetUnits.slice(); this.RemoveMoraleInfluence(this.targetUnits); } if (this.rangeQuery) cmpRangeManager.DestroyActiveQuery(this.rangeQuery); //Add Morale var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); if (!cmpPlayer) cmpPlayer = QueryOwnerInterface(this.entity); if (!cmpPlayer || cmpPlayer.GetState() == "defeated") return; this.targetUnits = []; let affectedPlayers = cmpPlayer.GetAllies(); this.rangeQuery = cmpRangeManager.CreateActiveQuery( this.entity, 0, 10, affectedPlayers, IID_Identity, cmpRangeManager.GetEntityFlagMask("normal"), false ); cmpRangeManager.EnableActiveQuery(this.rangeQuery); } Here is the apply and remove morale influence functions. The intention is to apply the effect (add Morale regenrate by 1 per second) and remove it if no longer in range). Morale.prototype.ApplyMoraleInfluence = function(ents) { var cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); cmpModifiersManager.AddModifiers( "MoraleSupport", { "Morale/RegenRate": [{ "affects": ["Unit"], "add": 1 }] }, ents ); } Morale.prototype.RemoveMoraleInfluence = function(ents) { if (!ents.length) return; var cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); cmpModifiersManager.RemoveAllModifiers("MoraleSupport", ents); } And lastly OnRangeUpdate. This should run apply and remove functions when units are moving in/out of other units range right? Morale.prototype.OnRangeUpdate = function(msg) { if(this.rangeQuery) { this.ApplyMoraleInfluence(msg.added); this.RemoveMoraleInfluence(msg.removed); } } I have been looking at the code all day and still don't understand why does the effect not apply. In the repo I added template units that includes Morale which start at 50%. The intention is that every players unit within 10m range should have increased Morale, but they don't. If you want to test this with Aura and see how I intend this to work, you can put these snippet inside template_unit.xml: <Auras datatype="tokens"> morale_friendly </Auras> Any help would be extremely appreciated. Thank you!
×
×
  • Create New...