HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Confusion help needed

12-21-2003, 06:47 AM#1
MaliceDR
In my upcoming map, one of my heroes has a spell called "Confusion." When cast upon a group of enemies, they will become confused and attack other units seemingly at random. This confused effect lasts only a few seconds.

In reality what's happening is that every unit within the effected area has a random integer between 0 and 2 picked for them. If the result is zero, nothing happens to them. If the result is 1, they are given to the hero's computer-controlled ally for a few seconds. And if the result is 2, they are temporarily handed over to Neutral Hostile. All this happens without colors being changed.

This effectively creates a state of mass confusion among the effected enemy units. My problem however is concocting the triggers for this event.
12-21-2003, 08:01 AM#2
GabeStah
Well, there's a few things that I'm not too clear on here as far as how you want things to work, but I have a similar spell in one of my maps, so I tried making up a quick trigger to do what you've requested.

Code:
trigConfusion Is Cast
    Events
        // This can be changed to starts casting an ability if you prefer to have it a long casting spell that requires the caster
        // to channel the spell for it's duration.  Up to you.
        Unit - A unit Finishes casting an ability
    Conditions
        // I based my Confusion spell on Starfall, but it's really your preference.  It should just be something that has no true spell effect
        // since you are doing everything via the spell via triggers.
        (Ability being cast) Equal to Confusion
        // Again, you can change these two as you see fit, I just assumed you'd want to make sure it was a Hero from Player 1 casting.
        ((Triggering unit) is A Hero) Equal to True
        ((Triggering unit) is in (Units owned by Player 1 (Red))) Equal to True
    Actions
        // Starts the timer to determine the duration of the spell effects, number can be altered or replaced with a variable integer
        Countdown Timer - Start var_timConfusionExpiration as a One-shot timer that will expire in 15.00 seconds
        // Range of 1000 was just picked as standard, again can be altered
        Unit Group - Pick every unit in (Units within 1000.00 of (Target point of ability being cast)) and do (Actions)
            Loop - Actions
                Set var_intRandomSelector = (Random integer number between 0 and 2)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    // This If statement is simply to make sure the casting Hero is not affected 
                    // (unless you want them to be affected, in which case remove this statement altogether.)
                    If - Conditions
                        (Picked unit) Equal to (Casting unit)
                    Then - Actions
                        Do nothing
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        var_intRandomSelector Equal to 0
                    Then - Actions
                        Do nothing
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    // Adds the unit to Player 2's team and adds the unit to our specified Unit Group Variable
                    // and adds a special effect for flare and indication to the event
                    // NOTE: The line from "Special Effect" until "Caster.mdl" is all one line
                    If - Conditions
                        var_intRandomSelector Equal to 1
                    Then - Actions
                        Special Effect - Create a special effect at (Position of (Picked unit)) using 
Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                        Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Retain color
                        Unit Group - Add (Picked unit) to var_ugConfusionAffectedUnits
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    // Adds the unit to Neutral Hostile team and adds the unit to our specified Unit Group Variable
                    // and adds a special effect for flare and indication to the event
                    // NOTE: The line from "Special Effect" until "Caster.mdl" is all one line
                    If - Conditions
                        var_intRandomSelector Equal to 2
                    Then - Actions
                        Special Effect - Create a special effect at (Position of (Picked unit)) using 
Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                        Unit - Change ownership of (Picked unit) to Neutral Hostile and Retain color
                        Unit Group - Add (Picked unit) to var_ugConfusionAffectedUnits
                    Else - Actions
                        Do nothing

Code:
// This trigger simply watches for the expiration of the var_timConfusionExpiration timer
// and when it expires (I.E. Your spell has gone through it's duration length)
// it changes all the previously changed units back to Player 1's control.
trigConfusion Timer
    Events
        Time - var_timConfusionExpiration expires
    Conditions
    Actions
        Unit Group - Pick every unit in var_ugConfusionAffectedUnits and do (Actions)
            Loop - Actions
                Unit - Change ownership of (Picked unit) to Player 1 (Red) and Retain color

Hope that helps or somewhat answers your question(s). If there's anything else I can do to help, let me know and I'll do my best.

-GabeStah-