Archive/Glest Advanced Engine

From MegaGlest
Revision as of 06:03, 23 February 2008 by 70.242.125.158 (talk) (→‎Upgrades: removed other tags that are now optional)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Effects & Upgrades is a tentative name for a code patch that extends upon the existing framework for upgrades and adds the the ability to cause temporary effects on a unit. The code is currently in pre-alpha state.

Upgrades

The upgrade xml format is extended while retaining legacy support for existing upgrades. This is in the file <tech-tree>/factions/<faction-name>/upgrades/<upgrade-name>/<upgrade-name>.xml. The new format cleans up the xml file somewhat by not requiring you to have nodes present for attributes your upgrade does not effect, while extending upon the number of attributes you can modify with an upgrade. In addition, attributes can be modified using a multiplier as well as a static value, allowing you to scale the effect across units of varying power.

The following is a sample upgrade.xml file which does the exact same thing as the existing "Energy Sharpening" upgrade.

<?xml version="1.0" standalone="no"?>
<upgrade>
    <image path="images/energy_sharpening.bmp"/>
    <image-cancel path="../ancient_summoning/images/magic_upgrade_cancel.bmp"/>
    

Note that nodes under <static-modifiers> and <multipliers> are optional and default to 0 and 1.0, respectively. If you wanted to increase the attack strength by 30% instead, you could use the following code for the static-modifiers and multipliers tags.

    <static-modifiers>
        <attack-range value="1"/>
    </static-modifiers>
    <multipliers>
        <attack-strength value="1.3"/>
    </multipliers>

Common Attribute List

The following is a complete list of attributes that can be modified by either a static amount or a multiplier in either the upgrade or effects XML structures and each should have a "value" attribute. Static values take a positive or negative number and default to zero (no modification). Multipliers take a floating point number, the default to 1.0 (multiply by one, or no modification). Note that this is not notated as a percentage. If you enter 100.0 for a multiplier, it means that the value increases 100 times. These are also covered in the reference section.

<max-hp>
<hp-regen>
<max-ep>
<ep-regen>
<sight>
<armor>
<attack-strength>
<attack-range>
<attack-speed>     <-- increases or decreases rate of attack -->
<move-speed>
<production-speed>
<repair-speed>
<harvest-speed>

Effects

Intro with examples

Effects are embedded in the <skill> tag of the <unit>. At this time, only attack skills are supported, but a new skill type will be later added to allow effects to be put on friendly units as in casting a spell. The below is an example of an extended attack of the archer adding a poison to the arrows which causes blindness and 50 damage per second for 8 seconds. Note that the only part of this snippet that is modified from the original is the addition of the <effects> tag.

Example Skill With Effects

<skill>
    <type value="attack"/>
    <name value="attack_skill"/>
    <ep-cost value="0"/>
    <speed value="50"/>
    <anim-speed value="50"/>
    <animation path="models/archer_attacking.g3d"/>
    <sound enabled="true" start-time="0.5">
        <sound-file path="sounds/archer_attack1.wav"/>
        <sound-file path="sounds/archer_attack2.wav"/>
        <sound-file path="sounds/archer_attack3.wav"/>
        <sound-file path="sounds/archer_attack4.wav"/>
    </sound>
    <attack-strenght value="100"/>
    <attack-var value="50"/>
    <attack-range value="10"/>
    <attack-type value="piercing"/>
    <attack-start-time value="0.5"/>
    <attack-fields>
        <field value="land"/>
        <field value="air"/>
    </attack-fields>
    <projectile value="true">
        <particle value="true" path="particle_proj.xml"/>
        <sound enabled="true">
            <sound-file path="sounds/arrow_hit1.wav"/>
            <sound-file path="sounds/arrow_hit2.wav"/>
            <sound-file path="sounds/arrow_hit3.wav"/>
            <sound-file path="sounds/arrow_hit4.wav"/>
            <sound-file path="sounds/arrow_hit5.wav"/>
        </sound>
    </projectile>
    <splash value="false"/>
    <effects>
        <effect name="blinding_poison"
                bias="detrimental"
                stacking="overwrite"
                target="any"
                chance="100.0"
                duration="8"
                image="../../../../placeholders/icon.bmp">
            <static-modifiers>
                <hp-regeneration value="-50"/>
            </static-modifiers>
            <multipliers>
                <sight value="0.2"/>
            </multipliers>
            <flags/>
            <fields-added/>
            <fields-removed/>
            <light enabled="false"/>
            <sound enabled="false"/>
            <particle value="false"/>
            <recourse-effects/>
        </effect>
    </effects>
</skill>

By using the multiplier of 0.2 for sight, their sight is reduced to 20% of normal. Reducing it further may result in a sight of zero, which would make them incapable of attacking even targets directly adjacent to them, and that probably wouldn't be a very balanced attack, but it would be funny. :)

Effects can be used on attacks with a splash effect as well, this will cause all units in the splash radius to be effected. By default, all units are effected equally, even if they are on the very edge of the splash radius. However, by adding the flag <apply-splash-strength> to the <flags> section of the effect, this behavior can be overridden causing the strength of the effect to be weaker on units further from the point of impact. The strength of the effect isn't exposed through the XML interface, but it effects all attribute modifications (both positive and negative). Below is an example a theoretical effect added to the ice attack of an archmage. Presuming that the ice is cold, let's say that this will temporarily reduce the movement and attack speed of the target. However, the effect will be relative to where they in the splash radius.

    <effects>
        <effect name="icy_chill"
                bias="detrimental"
                stacking="stack"
                target="any"
                chance="100.0"
                duration="8"
                image="../../../../placeholders/icon.bmp">
            <static-modifiers>
                <attack-speed value="-25"/>
                <movement-speed value="-50"/>
            </static-modifiers>
            <multipliers>
                <sight value="0.0"/>
            </multipliers>
            <flags>
                <apply-splash-strength/>
            </flags>
            <fields-added/>
            <fields-removed/>
            <light enabled="false"/>
            <sound enabled="false"/>
            <particle value="false"/>
            <recourse-effects/>
        </effect>
    </effects>

You may have noticed that the "stacking" attribute of the effect tag was set to "stack" this time instead of "overwrite." This means that successive attacks which cause this effect will accumulate, increasing the total effect. Each instance of the effect has it's own timer, so they will wear off one at a time. When set to "overwrite", the previous effect is simply overwritten and the duration reset. This isn't recommended for use with apply-splash-strength however because a second effect may be weaker and overwrite a stronger one.

Now let's go overboard and improve the initiate's attack. This will cause their targets to take damage over time, encouraging them to run fast, set them on fire spewing out firey particles with a sizzling sound and causing them to glow red for the duration. In addition the initiate will get a recourse effect, which gives them some extra energy regeneration and movement speed (so he can follow his victim around and watch) for as long as the bastard is burning up.

        <effect name="burning_bastard"
                bias="detrimental"
                stacking="stack"
                target="any"
                chance="100.0"
                duration="8"
                image="../../../../placeholders/icon.bmp">
            <static-modifiers>
                <hp-regeneration value="-25"/>
            </static-modifiers>
            <multipliers>
                <movement-speed value="2.0"/>
            </multipliers>
            <flags/>
            <fields-added/>
            <fields-removed/>
            <light enabled="true" red="0.8" green="0.1" blue="0.1"/>
            <sound enabled="true" start-time="0.0" loop="true" path="sounds/sizzle.wav"/>
            <particle enabled="true" path="firey_particles.xml"/>
            <recourse-effects>
                <effect name="pyromania"
                        bias="benificial"
                        stacking="stack"
                        target="any"
                        chance="100.0"
                        duration="8"
                        image="../../../../placeholders/icon.bmp">
                    <static-modifiers>
                        <ep-regeneration value="25"/>
                    </static-modifiers>
                    <multipliers>
                        <movement-speed value="2.0"/>
                    </multipliers>
                    <flags/>
                    <fields-added/>
                    <fields-removed/>
                    <light enabled="false"/>
                    <sound enabled="true" start-time="1.0" loop="true" path="sounds/manic-giggling.wav"/>
                    <particle value="false"/>
                </effect>
           </recourse-effects>
        </effect>

Reference / Specification

Since there is no DTD, this section section will describe the expected XML format of newly added XML structures.

For the Pluralism column in the nested elements descriptions, the following is the legend for the notation:

Value Meaning
? zero or one
1 exactly one
* zero or more
+ one or more

<effects>

An <effects> node may be embedded in a unit skill node.

Attributes

none

Nested Elements

Element Pluralism Description
<effect> * the effects

<effect>

Attributes

Attribute Required? Description
name required Name of the effect
image optional Path to an image used to display the effect (image not yet displayed, but effect name is)
bias required Primarily used by AI and must be either detrimental, neutral or benificial.
stacking required Defines behavior when an additional effect of the same type hits the unit. Must be one of stack (the new effect is added in addition to the old one), extend (the duration of the original effect is extended), overwrite (the old effect is replaced with the new effect) or reject (the new effect is ignored).
target optional What units are effected by the effect. Must be one of ally, foe, pet or all. Default value is any.
chance optional The percent chance that the effect will be applied to the target. The default is 100%.
duration required The number of seconds the effect will last. Ignored if the flag "permanent" is specified.

Nested Elements

Element Pluralism Description
<static-modifiers> ? contains static, integral modifiers to a unit's attributes (e.g., +1)
<multipliers> ? uses multipliers to modify a unit's attributes (e.g., x 1.25)
<flags> ? special purpose flags that alter the effect, it's behavior or tells the AI how best to use a skill with this effect
<fields-added> ? fields of travel that are added by the effect
<fields-removed> ? fields of travel that are removed by the effect
<light> ? light generated by the effect, emanating from the unit and replacing any previous light value
<sound> ? a sound, optionally looping, caused by the effect
<particle> ? particles caused by the effect
<recourse-effects> ? secondary effects applied to the caster/attacker that caused the original effect

<static-modifiers> and <multipliers>

Attributes

none

Nested Elements

Each nested element requires a single attribute named "value". For static modifiers, the value should be an integer and for multipliers the value should be a floating point number. If an element doesn't appear, the default value for static modifiers is zero and the default value for multipliers is 1.0.

Element Pluralism Description
<max-hp> ? maxiumum hit points
<max-ep> ? maximum energy points
<hp-regeneration> ? rate of hit point regeneration
<ep-regeneration> ? rate of energy regeneration
<sight> ? sight distance
<armor> ? armor (protection from attacks)
<attack-strength> ? base damage value when attacking
<attack-range> ? maximum attack distance
<move-speed> ? how fast the unit moves
<attack-speed> ? the rate of attack (how often the unit attacks and how long each attack takes to execute)
<production-speed> ? how long the unit takes to be produced, to morph or to research an upgrade
<harvest-speed> ? how fast workers harvest/mine/chop wood

<flags>

Flags effect various aspects of the "effect". Most flags are for AI use and are not yet used, but are hints to tell the AI how best to use skills with the effect. Each nested element has no attributes or children.

Attributes

none

Nested Elements

Element Pluralism Description
<effects-ally> ? Will effect allies. This is also turned on when target="allies" or "both".
<effects-foes> ? Will effect allies. This is also turned on when target="foes" or "both".
<not-effects-normal-units> ? Will not effect normal units (i.e., not buildings). By default, normal units are effected and buildings aren't.
<effects-buildings> ? Will effect buildings. By default, buildings are not effected.
<pets-only> ? Will only effect the pets of the caster. This causes effects-ally, effects-foes, not-effects-normal-units and effects-buildings to be ignored.
<effects-non-living> ? Not currently used.
<apply-splash-strength> ? Scale the strength of the effect with the same formula used to determine splash damage, which is 1.0 ÷ (distance_from_target + 1) -- the further from the apex of the target, the weaker the effect will be. By default, all units within the splash radius of a skill with an effect are effected equally.
<ends-with-source> ? The effect will end if the unit who caused the effect dies.
<recourse-ends-with-target> ? Causes the recourse effect to end when the root (primary) effect ends, regardless the duration. Applies only to recourse effects.
<allow-negative-speed> ? Adding negative values to the static-modifiers for move-speed can cause a unit to travel away from their destination, although they are facing their destination. While this is probably undesirable, this flag will allow it to happen anyway. The default behavior brings the unit's effective speed to zero if it would otherwise become negative.
<tick-immediately> ? Causes Hp & Ep regeneration to take immediate effect as if tick() had been called. This can be used for effects that should immediately heal or damage units and is mostly useful for zero duration effects, causing it to take immediate effect and then terminate. Using this flag with a zero duration will render all other modifiers in the effect, other than Hp & Ep regeneration to become useless although sound and particle effects will still be played/rendered.
<permanent> ? The effect has an infinite duration.
<damaged> ? AI hint: use on damaged units.
<ranged> ? AI hint: use on ranged units
<melee> ? AI hint: use on short range (melee) units (perhaps range 2 or less)
<workers> ? AI hint: use on worker units
<building> ? AI hint: use on buildings
<heavy> ? AI hint: use on heavy units
<scout> ? AI hint: use on scouting units. This can be engaged as soon as the AI decides a unit should scout.
<combat-only> ? AI hint: use only in combat (applies to beneficials). This should mean any allied unit who has visual on an enemy unit and is using an attack skill, or one who is not using an attack skill, but is being attacked (i.e., holding position).
<use-sparingly> ? AI hint: use sparingly (i.e., save for when "big guns" are needed)
<use-liberally> ? AI hint: use liberally (i.e., milk this one dry)

<fields-added> and <fields-removed>

Specifies fields of travel that are added to or removed from the unit. This may be adding the ability for a unit to swim, or levitate or grounding an otherwise flying unit (forcing them to walk or become immobile). The only fields currently available are air and land. However, water, forest (i.e., travel through trees) and subterainian may be added in this mod.

Attributes

none

Nested Elements

Element Pluralism Description
<air> ?
<land> ?
<water> ?

<light>

Causes light to emanate from the unit or changes the light if one already exists.

Attributes

Attribute Required? Description
enabled required true or false
red required if enabled is true a value between 0.0 and 1.0
green required if enabled is true a value between 0.0 and 1.0
blue required if enabled is true a value between 0.0 and 1.0

Nested Elements

none

<sound>

Attributes

Attribute Required? Description
enabled required true or false
start-time required if enabled is true number of seconds (in floating point) before playing the sound
loop required if enabled is true true if the sound should loop, false otherwise.
path required if enabled is true the sound file to play

Nested Elements

none

<particle>

Attributes

Attribute Required? Description
enabled required true or false
path required if enabled is true the xml file defining the particle system

Nested Elements

none

<recourse-effects>

Attributes

none

Nested Elements

Element Pluralism Description
<effect> * The effect(s) which are applied to the originator (i.e., the unit attacking or casting a spell) as a recourse of the original or primary effect.

none

<emanations>

May be optionally nested directly within a <unit> node. Emanations are static condition that applies an effect to surrounding units every tick. In general, an emanation should use the overwrite stacking value. The attributes and nested elements in an <emanation> node is identical to an <effect> node with the addition of a radius attribute.

Attributes

none

Nested Elements

Element Pluralism Description
<emanation> * The emanation effect(s) which are applied to surrounding units each tick.

none

<emanation>

Attributes

Contains all attributes of <effect>, with the addition detailed below

Attribute Required? Description
radius required the radius (in tiles) the effect emanates from the source unit.

Nested Elements

See <effect>.