HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Replacing a GUI order with an appropriate variable in Jass.

11-19-2003, 01:43 AM#1
Panto
Greetings.

I'm trying to figure out the exact triggers that are need to make a multi-level AoE buff spell centered on the casting unit (similar to Howl of Terror).

I've made a five-level dummy hero spell (based off of Thunderclap) and five unit spells that correspond to each level of the dummy spell.

I made a trigger that keeps track of the level of the dummy spell by incrementing an integer whenever the spell is learned.

The trick is, I've never actually seen a trigger, GUI or otherwise, which does the rest of this process, so I flew by the seat of my pants for a bit and ended up with this trigger: (variables have been named intuitively)
Code:
AoE Inner Fire Copy
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Inner Fire (Lord dummy)
    Actions
        Unit - Create 1 Caster for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
        Set unitArrayCaster[(Player number of (Owner of (Casting unit)))] = (Last created unit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 1
            Then - Actions
                Set abilityArrayCaster[(Player number of (Owner of (Casting unit)))] = Inner Fire (Caster 1)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 2
            Then - Actions
                Set abilityArrayCaster[(Player number of (Owner of (Casting unit)))] = Inner Fire (Caster 2)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 3
            Then - Actions
                Set abilityArrayCaster[(Player number of (Owner of (Casting unit)))] = Inner Fire (Caster 3)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 4
            Then - Actions
                Set abilityArrayCaster[(Player number of (Owner of (Casting unit)))] = Inner Fire (Caster 4)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 5
            Then - Actions
                Set abilityArrayCaster[(Player number of (Owner of (Casting unit)))] = Inner Fire (Caster 5)
            Else - Actions
        Unit Group - Pick every unit in (Units within 350.00 of (Position of (Casting unit)) matching (((Matching unit) belongs to an ally of (Owner of (Casting unit))) Equal to True)) and do (Actions)
            Loop - Actions
                Unit - Order unitArrayCaster[(Player number of (Owner of (Casting unit)))] to Human Blood Mage - Banish (Picked unit)
        Unit - Explode unitArrayCaster[(Player number of (Owner of (Casting unit)))]
Unfortunately, the GUI triggers don't let you define a spell to be cast if it's not on their pre-made list, and of course my five levels of unit spells are not on the list. For the time being, I picked the "Human Bloodmage - Banish" as a placeholder.

I think the remaining step here is to figure out how to change the reference to the "Human Bloodmage - Banish" (just "banish" in Jass) to refer to the variable "abilityArrayCaster[(Player number of (Owner of (Casting unit)))]" once the trigger is converted to Jass. So, I'd change this:
Code:
function Trig_AoE_Inner_Fire_Func010A takes nothing returns nothing
    call IssueTargetOrderBJ( udg_unitArrayCaster[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], "banish", GetEnumUnit() )
endfunction
to this:
Code:
function Trig_AoE_Inner_Fire_Func010A takes nothing returns nothing
    call IssueTargetOrderBJ( udg_unitArrayCaster[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], udg_abilityCaster[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], GetEnumUnit() )
endfunction
Sorry about the formatting here. vBulletin evidently inserts line breaks in long strings of characters even when they're inside a [code] tag. Mind you, this is just guesswork on my part; I don't know that much about programming in general. The trigger with the changes I showed does not compile without errors.

So, what's wrong?

And, as a bonus question, will this trigger do what I want it to, if this problem is resolved? Will it create a caster unit, have the caster unit cast Inner Fire on each allied unit within a radius of the hero that uses the dummy spell, and then eliminate the caster unit?
Do there need to be delays between spells, or something like that? Can the same unit be ordered to cast a 0 cooldown, 0 mana cost spell on every unit in a "Pick Every Unit" loop? Having never tried to implement this sort of trigger before, I don't know much about what will or won't work, and since I can't get this bit of the trigger to compile, I haven't been able to run any tests.

Any help is appreciated!
11-19-2003, 06:30 AM#2
KaTTaNa
First of all, all the dummy units should probably be issued the same order, so you might just as well enter it manually.

If you are using jass, use this function instead: IssueTargetOrderById
It is declared like this:
Code:
IssueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean
So your line should look like this:
Code:
call IssueTargetOrderById(  udg_unitArrayCaster[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))],  udg_abilityArrayCaster[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], GetEnumUnit() )
Note that I renamed abilityCaster to abilityArrayCaster since that's what you called it in the first trigger you posted.
11-19-2003, 06:35 AM#3
PitzerMike
Code:
udg_abilityCaster[GetConvertedPlayerId(GetOwningPl


it asks for the order string of the spell here (which was "banish" before).
As you can't define your own order strings for your spells you have to use the order string of the base ability here.
eg. if you used Death coil as base ability you'll put in "deathcoil" here and your custom ability will be cast. (it's the same for detecting if the ability has been cast)

Other than that you trigger looks pretty good, although I've not read the whole code entirely.

What you should do for the caster unit is give it no model so you can't see it, better make it flying with 50 height and turn off collision...
Maybe you'll have to create several casters.
11-20-2003, 05:05 PM#4
Panto
KaTTaNa, thanks, I forgot to change the name of the Trigger in Jass after I changed it in the variable window.

Will IssueTargetOrderById accept the Ability variable any differently than the function I used?

PitzerMike, I can use the base ability for the custom spell to order it? In other words, I could use the same spell code for all the Ifs, since all the custom spells are based off of the same one?

That would be indeed handy.

I think I know how to keep working with this now. Thanks guys. Let me know if I mis-conceived something or if you have any more information.
11-28-2003, 03:57 AM#5
LegolasArcher
From converting triggers to JASS I learned this.

In the ability editor Edit>View Raw Data.
Find your custom spell it should say "A###([Spellname])", starting with the ###s being 0's. Remember part not in quotations (IE "A000").

In JASS I do the follwing (converted to custom text value changed:
Code:
function Trig_spell_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_spell_Actions takes nothing returns nothing
    call DisplayTextToPlayer( Player(0), 0, 0, "TRIGSTR_014" )
endfunction

//===========================================================================
function InitTrig_spell takes nothing returns nothing
    set gg_trg_spell = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_spell, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_spell, Condition( function Trig_spell_Conditions ) )
    call TriggerAddAction( gg_trg_spell, function Trig_spell_Actions )
endfunction

Notice the "A000". I dunno if thats what your tring to do. My 2 cents
12-06-2003, 06:06 AM#6
Panto
Alas, I re-made the trigger with the emphasis on different casters instead of different abilities and with one caster for each unit, but it still doesn't seem to be working. I've looked over the pertinent triggers, but nothing seems to be the matter to me.

Would you care to have a look at the triggers I'm using now, and tell me what you think?
Code:
General Time Elapsed Zero
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Visibility - Create an initially Enabled visibility modifier for Neutral Passive emitting Visibility across (Playable map area)
Code:
function Trig_Inner_Fire_Caster_Conditions takes nothing returns boolean
    if ( not ( GetLearnedSkillBJ() == 'AOws' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Inner_Fire_Caster_Actions takes nothing returns nothing
    set udg_intArrayHeroSpecial[GetConvertedPlayerId(GetOwningPlayer(GetLearningUnit()))] = ( udg_intArrayHeroSpecial[GetConvertedPlayerId(GetOwningPlayer(GetLearningUnit()))] + 1 )
endfunction

//===========================================================================
function InitTrig_Inner_Fire_Caster takes nothing returns nothing
    set gg_trg_Inner_Fire_Caster = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Inner_Fire_Caster, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Inner_Fire_Caster, Condition( function Trig_Inner_Fire_Caster_Conditions ) )
    call TriggerAddAction( gg_trg_Inner_Fire_Caster, function Trig_Inner_Fire_Caster_Actions )
endfunction
Code:
AoE Inner Fire
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Inner Fire (Lord dummy)
    Actions
        Unit Group - Pick every unit in (Units within 350.00 of (Position of (Casting unit)) matching (((Matching unit) belongs to an ally of (Owner of (Casting unit))) Equal to True)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 1
                    Then - Actions
                        Unit - Create 1 Caster (1) for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
                        Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                        Unit Group - Add (Last created unit) to unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 2
                    Then - Actions
                        Unit - Create 1 Caster (2) for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
                        Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                        Unit Group - Add (Last created unit) to unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 3
                    Then - Actions
                        Unit - Create 1 Caster (3) for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
                        Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                        Unit Group - Add (Last created unit) to unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 4
                    Then - Actions
                        Unit - Create 1 Caster (4) for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
                        Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                        Unit Group - Add (Last created unit) to unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        intArrayHeroSpecial[(Player number of (Owner of (Casting unit)))] Equal to 5
                    Then - Actions
                        Unit - Create 1 Caster (5) for Neutral Passive at (Center of Caster Location <gen>) facing (Position of (Casting unit))
                        Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                        Unit Group - Add (Last created unit) to unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                    Else - Actions
        Unit Group - Pick every unit in unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))] and do (Actions)
            Loop - Actions
                Unit Group - Remove (Picked unit) from unitgroupArrayCaster[(Player number of (Owner of (Casting unit)))]
                Unit - Explode (Picked unit)
I mentioned it before, but any help you can give me with this is truly appreciated.