Archive/Glest Advanced Engine

From MegaGlest
Revision as of 12:09, 27 January 2008 by Daniel Santos (talk) (Effects: 1st part of Effects section)
Jump to: navigation, 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. 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"/>
    
    <unit-requirements/>
    <upgrade-requirements/>
    <resource-requirements>
        <resource name="gold" amount="250"/>
                <resource name="wood" amount="200"/>
                <resource name="stone" amount="150"/>
    </resource-requirements>
    <effects>
        <unit name="battlemage"/>
        <unit name="summoner"/>
        <unit name="archmage"/>
    </effects>
    <static-modifiers>
        <attack-strength value="50"/>
        <attack-range value="1"/>
    </static-modifiers>
    <multipliers/>
</upgrade>

You will nodes under <static-modifiers> and <multipliers> are optional. If you wanted to increase the attack strength by 30% instead, you would 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>

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.0"/>
            </multipliers>
            <flags/>
            <fields-added/>
            <fields-removed/>
            <light enabled="false"/>
            <sound enabled="false"/>
            <particle value="false"/>
            <recourse-effects/>
        </effect>
    </effects>
</skill>

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 <> section of the effect, this behavior can be overridden, causing the strength of the effect to scale same manner that splash damage is scaled back, the further from the center of the attack. 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>

Attribute List

The following is a complete list of all attributes that can be modified by either a static amount or a multiplier. 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.

<max-hp>
<max-ep>
<hp-regen>
<ep-regen>
<sight>
<armor>
<attack-strength>
<attack-range>
<move-speed>
<attack-speed>     &lt!-- increases of decreases rate of attack --%gt
<production-speed>