Author Topic: Code mod: Temporary Effects  (Read 1704 times)

daniel.santos

  • Guest
Code mod: Temporary Effects
« on: 21 January 2008, 09:15:05 »
While working on a magitech tech extension that adds necromancers, monks and the like, wciow and I discussed how cool it would be if units could cast spells on other units that would have a temporary effect like adding extra regeneration, slowing them down, blinding them, making them attack faster or draining away their life.  The Glest code nicely accommodates such alterations, so I took it upon myself to give it a try.

I hadn't used STL in years, so after eventually rediscovering that you iterate through a vector with for(iterator i = v.begin(); i != v.end(); i)) rather than "i < v.end()" (which pissed me off to no end until I caught it), I got a nicely working modification.

The basics work as follows.  You just add an <effects> section to each skill.  Although it only effects attack skills, your attack skill can have one or more effects on it.  If another skill type for "cast spell" or similar is implemented, then arbitrary effects can be applied to friendlies.  An effect could also be applied to the repair skill, but I can't think of any particular reason to do so.

Code: [Select]
<effects>
<effect name="burning_bastard" bias="detrimental">
<image path="images/burning_bastard.bmp"/>
<duration value="5.0"/>
<max-hp value="0" regeneration="-75"/>
<max-ep value="0" regeneration="0"/>
<armor value="0"/>
<sight value="0"/>
<movement-speed value="1.5"/>
<attack-speed value="1.0"/>
<attack-damage value="0"/>
<fields-added/>
<fields-removed/>
<light enabled="false"/>
<sound enabled="false" start-time="0.0" loop="false" path="sounds/burning_bastard.wav"/>
<particle value="false" path="burning_bastard_particle.xml"/>
</effect>
</effects>


Currently, there is no icon or even description that shows that an effect is active in the unit description, and attack-damage, adding/removing fields (for levitation, swimming, etc), sound, light and particles are not implemented, but the rest appears to be working.  Additionally, there is probably a need for effect stacking management of some sort.  The above effect lasts for 5 seconds and causes the recipient to take 75 damage per second (in addition to whatever the initial attack did), and allows him or her to traverse at 150% of his original walk speed while they slowly sizzle.

The idea of the sound, light and particles is to have a visual and/or auditory indication that something is different like a sizzling sound, red glow, sparks flying off of him, etc.  The effects should continue after they die (until they are undertaken) but still remove when the effect wears off (even if that's after they die).  I also got it updating kills appropriately as well as faction kills when the target dies from the effect.

Anyway, I hope I can convince Martiño to consider it for eventually being merged :) )

Daniel
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

wciow

  • Behemoth
  • *******
  • Posts: 968
    • View Profile
(No subject)
« Reply #1 on: 21 January 2008, 20:40:21 »
Excellent work  :D I'm gonna download the patch and try it out when you find a host!
« Last Edit: 1 January 1970, 00:00:00 by wciow »
Check out my new Goblin faction - https://forum.megaglest.org/index.php?topic=9658.0

daniel.santos

  • Guest
(No subject)
« Reply #2 on: 27 January 2008, 11:38:25 »
I have documented this mod here: http://http://glest.wikia.com/wiki/Effects_&_upgrades.  I modified the upgrade code as well, extending it to effect more unit attributes as well as using either static modifiers (as is current) or multipliers, which we needed in the Four Path Magitech mod.  Mostly though, I use the UpgradeTypeBase now as the base class for EffectType, keeping the code cleaner by reusing a common base class.  I moved all of the xml processing to the UpgradeTypeBase class as well, so it's nice and clean.  With all of the new options, the XML structures were getting pretty big, so I redid them so that you only have to specify the attributes you are modifying.

It's currently broken because of the number of changes, but I should have it working again by the end of the weekend (hopefully :) ).
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

 

anything