Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2048 closed enhancement (fixed)

[PATCH] Implement Auras

Reported by: sanderd17 Owned by: sanderd17
Priority: Should Have Milestone: Alpha 15
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by sanderd17)

I have a patch for Aura implementation.

The main patch, auras.diff, contains the other patches combined.

Main JS changes

It works basically as ranged-based technologies. So you can edit every template value you want (at least the ones prepared for technologies).

I also made an AuraManager, basically, that keeps track of all the added bonuses to units in auras. A bit like the TechnologyManager.

The auras themselves can also be changed by technologies (f.e. a technology to enlarge the healing range of a temple). Recalculating all auras isn't a very cheap operation though, so it's best to not change auras too often.

As the changes depend on things needed by the technologyManager, some stuff isn't yet ready to be changeable:

  • Motion speeds can't be changed (at least I've found no way how). They probably aren't updated during the game
  • Automatic heal or damage aura (= negative healing) can't work until the Health/RegenRate is implemented
  • TraderGain isn't implemented yet

The JS changes do introduce a system component. So when applying the JS patch, a quick compile is needed.

All js changes can be found in auras_js.diff. This patch needs the template changes to work.

Renaming methods and messages

There are a few things I want to rename. First, I want to rename the MT_TechnologyModification message to something more general like MT_ValueModification. It's logical it's used by multiple components (at least Auras and Technologies). I also want to remove the player parameter from it, as the technology and aura components already send it to the right entities. So that player check is not needed.

Next, I also want an extra ValueManager component, which should work as the current TechnologyManager on the c++ side (consequently, remove the c++ side of the TechnologyManager), but as a different component on the JS side, where the implementation of the old Technology helper functions really happens. The ValueManager should a system component and be the only one that knows about all components that can change values (currently Auras and Technologies).

The JS global technology helper functions should also be renamed to things like ApplyValueModificationsToEntity and similar. So their names are more general.

I have no patches ready for this, as I'd like to get these in using cumulative patches.

cpp changes

The current cpp patch is rubbish. Instead, the only changes needed are renaming the methods so they comply with the above renamed things. Also get the player checks out of it, as it doesn't matter. The patch is still available here, but not for inclusion, just to easily see where current c++ technologies are used.

Changed templates:

Of course, lots of templates need to be changed. Only the temple template is edited for now (as example), but here's a list of the templates that need auras.

Temple > added heal aura

Female support unit > +10% build and gather speed for nearby CitizenSoldiers

HEROES

athen_hero_iphicrates.xml > Added speed and armour bonus to units in its range + 15% extra speed to all peltasts

athen_hero_pericles.xml > +20% building speed for units in his visions. 30% cheaper temples while he lives.

athen_hero_themistocles.xml > moved template to hele_hero_themistocles

brit_hero_boudicca_sword.xml > Aura TBD

brit_hero_boudicca.xml > moved template to celt_hero_boudicca

brit_hero_caratacos.xml > moved template to celt_hero_caratacos

brit_hero_cynvelin.xml > moved template to celt_hero_cynvelin

cart_hero_hamilcar.xml > Aura TBD

cart_hero_hannibal.xml > Aura TBD

cart_hero_maharbal.xml > +2 Attack for units in his aura

celt_hero_boudicca.xml > +5 Hack/Pierce attack and +15 speed for champions

celt_hero_brennus.xml > +5 loot (NOT IMPLEMENTED) would require changes in the Looter component

celt_hero_britomartus.xml > +50% gathering speed during his lifetime

celt_hero_caratacos.xml > +25% speed for units in his formation (doesn't work yet)

celt_hero_cynvelin.xml > Adds 0.5 to the RegenRate of nearby units (droped the idle requirement)

celt_hero_vercingetorix.xml > add 2 attack for units in his range

gaul_hero_brennus.xml > moved template to celt_hero_brennus

gaul_hero_britomartus.xml > moved template to celt_hero_britomanus

gaul_hero_vercingetorix.xml > moved template to celt_hero_vercingetorix

hele_hero_alexander.xml > "Imperialism" Bonus (+25% territory effect for all buildings while he lives.)

hele_hero_demetrius.xml > "Poliorkḗtēs" Aura (+5 Hack/Pierce/Crush attack and +10m range increase for sieges during his lifetime.)

hele_hero_leonidas.xml > +3 Hack attack for spear infantry. +1 armor level for spear infantry.

hele_hero_philip.xml > +3 Hack/Pierce/Crush attack for champion units

hele_hero_themistocles.xml > Ships are build 20% faster, and the ship he's garrisoned in moves 50% faster

hele_hero_xenophon.xml > Added +2 armour and +15% speed to units in his formation. And extra +15% speed to all peltasts

iber_hero_caros.xml > Aura TBD

iber_hero_indibil.xml > Aura TBD iber_hero_variato.xml > Aura TBD

mace_hero_alexander.xml > moved template to hele_hero_alexander + 25% extra territory

mace_hero_craterus.xml > moved template to hele_hero_craterus

mace_hero_demetrius.xml > moved template to hele_hero_demetrius

mace_hero_philip.xml > moved template to hele_hero_philip

maur_hero_ashoka.xml > Aura TBD

maur_hero_chanakya.xml > Aura TBD

maur_hero_maurya.xml > Aura TBD

pers_hero_cyrus.xml > Add +3 Hack/Crush/Pierce attack to nearby cavalry

pers_hero_darius.xml > Increase movement speed of infantry with 25%. +50% Trading gain bonus (not implemented in Trader.js yet)

pers_hero_xerxes_chariot.xml > +25% gather and build speed for units nearby

pers_hero_xerxes.xml > +25% gather and build speed for units nearby

rome_hero_marcellus.xml > Infantry have +20% greater attack within his aura.

rome_hero_maximus.xml > Nearby units +3 armor, all types.

rome_hero_scipio.xml > "Divide et Impera" Special (He has the ability to convert enemy units en masse at a great cost of metal).

spart_hero_agis.xml > "Last Stand" bonus. Has triple the Health of most infantry heroes. No other bonuses or auras.

spart_hero_brasidas.xml > +2 pierce attack and +3 pierce armour for nearby skirmishers

spart_hero_leonidas.xml > moved template to hele_hero_leonidas

Attachments (8)

auras_cpp.diff (8.2 KB ) - added by sanderd17 11 years ago.
auras_templates.diff (60.7 KB ) - added by sanderd17 11 years ago.
auras_js.diff (17.5 KB ) - added by sanderd17 11 years ago.
auras_json.diff (28.5 KB ) - added by sanderd17 11 years ago.
auras_json_2.diff (31.8 KB ) - added by alpha123 11 years ago.
WIP; fixes most bugs and enables greater reuse of aura files
auras_json_2.2.diff (31.7 KB ) - added by alpha123 11 years ago.
WIP; fixes most bugs and enables greater reuse of aura files
auras_json_2.3.diff (27.1 KB ) - added by sanderd17 11 years ago.
auras_json_2.4.diff (26.9 KB ) - added by sanderd17 11 years ago.

Download all attachments as: .zip

Change History (41)

comment:1 by sanderd17, 11 years ago

Description: modified (diff)

comment:2 by sanderd17, 11 years ago

Added support for templates, although it doesn't work completely yet.

comment:3 by sanderd17, 11 years ago

Description: modified (diff)

comment:4 by sanderd17, 11 years ago

Description: modified (diff)

comment:5 by sanderd17, 11 years ago

Implemented the "don't stack auras" (i.e. don't apply the same aura twice).

comment:6 by sanderd17, 11 years ago

Added some code to chose for "Formation" or "InfiniteRadius" instead of giving a fixed radius.

The only problem is that a formation only exists as long as the units are walking. So it's rather useless for stuff that has something to do with attack values. As it disappears the moment they start to attack. But it can give extra armour/health/speed to a group of walking units.

comment:7 by sanderd17, 11 years ago

Solved some bugs with destroyed entities (now making sure the bonus is removed).

comment:8 by sanderd17, 11 years ago

I think we're getting there. Now you can choose between

  • Radius auras - apply on the chosen units in a radius around the entity with an aura
  • Template auras - apply on all chosen units and on templates
  • Formation auras - apply on all units inside the formation of the entity with an aura
  • Garrison auras - apply on the chosen structure an entity with an aura is in

All auras are also only applied once thanks to key-checking.

comment:9 by sanderd17, 11 years ago

Description: modified (diff)

comment:10 by sanderd17, 11 years ago

Description: modified (diff)

comment:11 by sanderd17, 11 years ago

Description: modified (diff)
Keywords: review added
Summary: [PATCH][WIP] Implement Auras[PATCH] Implement Auras

comment:12 by sanderd17, 11 years ago

Description: modified (diff)
Keywords: review removed

comment:13 by sanderd17, 11 years ago

Description: modified (diff)

comment:14 by sanderd17, 11 years ago

Description: modified (diff)

comment:15 by michael, 11 years ago

Description: modified (diff)

comment:16 by michael, 11 years ago

Changed some of the descriptions. Added the Roman hero bonuses.

I don't like how the Athenian, Spartan, Macedonian, Briton, and Gallic heroes don't have their own code and "inherit" from the hele_ and celt_ templates instead. Why are you doing this?

in reply to:  16 comment:17 by sanderd17, 11 years ago

Replying to michael:

I don't like how the Athenian, Spartan, Macedonian, Briton, and Gallic heroes don't have their own code and "inherit" from the hele_ and celt_ templates instead. Why are you doing this?

Well, from the "less is more" principle. If large parts are the same, there's no need to maintain them both. It's enough to maintain one, and let the other inherit from the first. If you want them to be different in some stats anyway, you can use the same inheritance to overwrite the different parts.

Maintaining 12 extra templates was a fair bit of work added.

comment:18 by sanderd17, 11 years ago

Description: modified (diff)

by sanderd17, 11 years ago

Attachment: auras_cpp.diff added

comment:19 by sanderd17, 11 years ago

Split the patch up in three parts for easy review

  • auras_temlates > all template modifications
  • auras_js > all code to make the js components work with auras. (this does require re-compilation)
  • auras_cpp > code to make the cpp components work with auras (should only use js functions that already existed before, so this patch is completely independent from the other two). But it does require a clean_workspaces.

Currently, there are some cpp problems for which I need help though.

Last edited 11 years ago by sanderd17 (previous) (diff)

by sanderd17, 11 years ago

Attachment: auras_templates.diff added

comment:20 by sanderd17, 11 years ago

Description: modified (diff)
Keywords: review added

comment:21 by sanderd17, 11 years ago

Description: modified (diff)

comment:22 by historic_bruno, 11 years ago

Keywords: patch, review → patch review
Milestone: BacklogAlpha 15
Owner: set to sanderd17

comment:23 by sanderd17, 11 years ago

Description: modified (diff)

comment:24 by sanderd17, 11 years ago

New js files, cleaned up code.

by sanderd17, 11 years ago

Attachment: auras_js.diff added

comment:25 by sanderd17, 11 years ago

Updated to svn

comment:26 by sanderd17, 11 years ago

Added a json version. This is the kind of data it expects now:

{
	"type":"Range",
	"range":50,
	"affects":["Spear Infantry"],
	"affectedPlayers":["Player"],
	"modifications":[{"value":"Attack/Melee/Hack","add":2}]
}

Quite similar to the technology template. It doesn't allow technology modifications of auras though. But it should be possible in the future.

by sanderd17, 11 years ago

Attachment: auras_json.diff added

by alpha123, 11 years ago

Attachment: auras_json_2.diff added

WIP; fixes most bugs and enables greater reuse of aura files

comment:27 by sanderd17, 11 years ago

Things to fix:

  • send player id -1 on bonus remove + the both TODO's should explain on how to fix it
  • Get the endgamemangager rewrite out of the patch (a different patch)
  • delete the unneeded brackets from GarrisonHolder

by alpha123, 11 years ago

Attachment: auras_json_2.2.diff added

WIP; fixes most bugs and enables greater reuse of aura files

by sanderd17, 11 years ago

Attachment: auras_json_2.3.diff added

comment:28 by sanderd17, 11 years ago

Fixes the stuff mentioned above. Includes a single heal aura as test (and works).

by sanderd17, 11 years ago

Attachment: auras_json_2.4.diff added

comment:29 by sanderd17, 11 years ago

Small cleanup

comment:30 by sanderd17, 11 years ago

In 13998:

Implement the js side of auras. Refs #2048. Patch with the help of Alpha123. Only the temple aura is added as example, all other aura components are removed from the templates to be created from scratch again.

comment:31 by sanderd17, 11 years ago

Description: modified (diff)

comment:32 by alpha123, 11 years ago

Keywords: review removed

comment:33 by sanderd17, 11 years ago

Resolution: fixed
Status: newclosed

Fixed renaming messages and C++ components in r14001.

Last edited 11 years ago by sanderd17 (previous) (diff)
Note: See TracTickets for help on using tickets.