Jump to content

New Aura scripts


Recommended Posts

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 by wowgetoffyourcellphone
Link to comment
Share on other sites

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. (y)

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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" ?

Link to comment
Share on other sites

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 by wowgetoffyourcellphone
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by wowgetoffyourcellphone
  • Like 1
Link to comment
Share on other sites

@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 by fatherbushido
  • Like 1
Link to comment
Share on other sites

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 by wowgetoffyourcellphone
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...