wowgetoffyourcellphone Posted April 6, 2016 Report Share Posted April 6, 2016 (edited) Hi guys. Would an aura script like this work? Thanks. { "type": "global", "affects": ["Warship"], "affectedPlayers": ["MutualAlly"], "modifications": [ {"value": "Cost/BuildTime", "multiply": 0.75} ], "auraName": "Delian League", "auraDescription": "Allied warships -25% build time as long as the Athenian player has a shipyard." } Should use MutualAlly or just Ally? Thanls. Edited April 6, 2016 by wowgetoffyourcellphone Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 6, 2016 Report Share Posted April 6, 2016 Both would work: Ally and MutualAlly. But they have different meanings. Ally gives the bonus to all your allies, MutualAlly only gives the bonus to your allies of whom you're also an ally. 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 6, 2016 Author Report Share Posted April 6, 2016 6 minutes ago, sanderd17 said: Both would work: Ally and MutualAlly. But they have different meanings. Ally gives the bonus to all your allies, MutualAlly only gives the bonus to your allies of whom you're also an ally. Thank you. I'll try it out and report back resuts. It seemed to be bugged when auras were in the template. Maybe fixed now. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 6, 2016 Report Share Posted April 6, 2016 Hmm, I didn't know it was bugged, so didn't fix it specifically. But it could indeed be fixed as a side effect. If it's still bugged, please report it back to us, so we can find where the issue is. 3 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 6, 2016 Author Report Share Posted April 6, 2016 Hey, it works! Small problem, it also affect the player too. I just want it to affect the ally. Possible? Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 6, 2016 Report Share Posted April 6, 2016 Perhaps player is ally with himself (seems logical). It needs to be check in Player component. Why have you this specific need ?   Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 7, 2016 Author Report Share Posted April 7, 2016 14 hours ago, fatherbushido said: Perhaps player is ally with himself (seems logical). It needs to be check in Player component. Why have you this specific need ?   It's a bonus for the player's allys not the player. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 7, 2016 Report Share Posted April 7, 2016 The player is always considered as his own ally. The Auras code just uses the terms of the diplomacy code directly. Changing the diplo code would probably result in some bad bugs. And using the same terms for different meanings would be annoying too. Perhaps making a new diplomacy term, something like "StrictAlly", that excludes the own player would be the best. Any suggestions for names (or other solutions)? Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 7, 2016 Report Share Posted April 7, 2016 Actually, think about it, this is an ideal way to show the moddability of the game. As a mod, you'd only have to create a file simulation/components/Player_MyMod.js with the following lines in it, and it would work (note that the file needs to be alphabetically loaded after Player.js, so that's the reason to use an underscore and not a dot). Player.prototype.IsStrictAlly = function(id) { return (this.playerID != id) && this.IsAlly(id); }; But since we could also benefit from this code, we'll just commit it to the public mod, so you don't have to bother with it. Quote Link to comment Share on other sites More sharing options...
av93 Posted April 7, 2016 Report Share Posted April 7, 2016 Then, team bonus are possible, right? with an "autoResearch" tech + mutual allies as affectedPlayers. 2 hours ago, sanderd17 said: Perhaps making a new diplomacy term, something like "StrictAlly", that excludes the own player would be the best. Any suggestions for names (or other solutions)? "OnlyAlly" ? Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 7, 2016 Report Share Posted April 7, 2016 Not really, since techs can't modify stats on other players, and auras would need modifications to be put on abstract entities (like the player entity). So neither is currently adequate to encode team bonuses with. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 7, 2016 Report Share Posted April 7, 2016 Apparently, the AI code already used a term for this, so it's now called "ExclusiveAlly" (and "ExclusiveMutualAlly"). Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 8, 2016 Author Report Share Posted April 8, 2016 (edited) 22 hours ago, sanderd17 said: Actually, think about it, this is an ideal way to show the moddability of the game. As a mod, you'd only have to create a file simulation/components/Player_MyMod.js with the following lines in it, and it would work (note that the file needs to be alphabetically loaded after Player.js, so that's the reason to use an underscore and not a dot). Player.prototype.IsStrictAlly = function(id) { return (this.playerID != id) && this.IsAlly(id); }; But since we could also benefit from this code, we'll just commit it to the public mod, so you don't have to bother with it. Wait. What? Was this function in the game all along or new? I mean adding code to the javascript files with the _mymod file? Â And btw, thanks for this quick fix. It was not an emergency, but it looks like it was relatively simple. Edited April 8, 2016 by wowgetoffyourcellphone Quote Link to comment Share on other sites More sharing options...
niektb Posted April 8, 2016 Report Share Posted April 8, 2016 4 minutes ago, wowgetoffyourcellphone said: I mean adding code to the javascript files with the _mymod file? Yes, it is around for quite a long time (AFAIK). Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 8, 2016 Report Share Posted April 8, 2016 4 hours ago, wowgetoffyourcellphone said: Wait. What? Was this function in the game all along or new? I mean adding code to the javascript files with the _mymod file? This works since a year or two, but it was a small fix. Before that fix, every component had its own scope, so you couldn't modify the code of a component in a different file. Which is safer from a code POV, but doesn't work as well with mods, since they have to replace complete files that way, and possibly have to maintain pieces of code that are hard to maintain (imagine you add some different states to UnitAI and you have to maintain the entire UnitAI file for every change we make to it). Now, the component prototypes are global variables, so once they are created, you can modify them from any other file. Thus if you make that your file is loaded after the original file, it's quite easy to add methods to it, or replace methods with different code. In some cases (like when you add listeners to other messages), you have to re-register the component with a call like Engine.ReRegisterComponentType(IID_Player, "Player", Player), else the engine won't pick up the extra messages. Btw, this is also how triggers work (extending the existing trigger component), and trigger scripts can acually extend any component they want ... but I guess when you need that, it's better to make a complete mod. Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 9, 2016 Author Report Share Posted April 9, 2016 (edited) On 4/7/2016 at 6:50 AM, sanderd17 said: Not really, since techs can't modify stats on other players, and auras would need modifications to be put on abstract entities (like the player entity). So neither is currently adequate to encode team bonuses with. This aura I make is a team bonus. Attempt to make Delian League for Athenians team bonus work. Seems to work great now, really. You are right though, it attach to the Athenian dock (specifically Shipyard, my mod has 2 dock), not the abstract Athenian player. Edited April 9, 2016 by wowgetoffyourcellphone 1 Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 9, 2016 Report Share Posted April 9, 2016 Quote not the abstract Athenian player You can do that too. Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 9, 2016 Author Report Share Posted April 9, 2016 3 minutes ago, fatherbushido said: You can do that too. Hello, father. How do we do this? Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 10, 2016 Report Share Posted April 10, 2016 (edited) @wowgetoffyourcellphone: first you need an athenian player template: special/player_athen.xml <?xml version="1.0" encoding="utf-8"?> <Entity parent="special/player"> <Auras>player_athen_delian_league</Auras> </Entity> Â Then you need an aura file player_athen_delian_league.json { "type": "global", "affects": ["Warship"], "affectedPlayers": ["ExclusiveMutualAlly"], "modifications": [ {"value": "Cost/BuildTime", "multiply": 0.75} ], "auraName": "Delian League", "auraDescription": "Allied warships -25% build time as long as the Athenian player has a shipyard." } (But in this case no need to have a shipyard). Feel free to use another filename for the aura :-) Edited April 10, 2016 by fatherbushido 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 10, 2016 Author Report Share Posted April 10, 2016 Great! I will try and report back. Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 10, 2016 Author Report Share Posted April 10, 2016 (edited) 37 minutes ago, wowgetoffyourcellphone said: Great! I will try and report back. HAHA nope. Errors a lot. Â ERROR: RelaxNGValidator: Validation error: special/player_athen:1: Element Auras failed to validate content ERROR: RelaxNGValidator: Validation failed for '(null)' ERROR: Failed to validate entity template 'special/player_athen' ERROR: JavaScript error: uncaught exception: Player.js: Error creating player entity 1 Â Then a thousand more errors. Â EDIT: Sanderd is right. Edited April 10, 2016 by wowgetoffyourcellphone Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 10, 2016 Report Share Posted April 10, 2016 The datatype="tokes" thing in the xml is missing. 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 10, 2016 Author Report Share Posted April 10, 2016 It didn't seem to work for some reason. Works as aura for Shipyard tho. Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 10, 2016 Report Share Posted April 10, 2016 (edited) Yes i forgot <?xml version="1.0" encoding="utf-8"?> <Entity parent="special/player"> <Auras datatype="tokens">player_athen_delian_league</Auras> </Entity> EDIT: Finally it can't work like that. Edited April 10, 2016 by fatherbushido 1 Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted April 10, 2016 Report Share Posted April 10, 2016 Clarifying @fatherbushido's comment: it indeed can't work like that for the following reasons The Player has no owner (but it is the owner), which makes the code in a lot of different places just a bit different The auras were first made as only range-based auras. And as a result, the aura-giver must still have a valid position. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.