• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Something isn't working

Status
Not open for further replies.
Level 22
Joined
Feb 3, 2009
Messages
3,292
The spell basicaly does: When any unit targets the Paladin, which is set to the variable udg_DefCaster then a dummy is created, it gains the spell that was used, and casts it right back at the DefUser. Everything works exept for the part when it should cast the spell on the DefUser.

Don't mind all the BJs and stuff, i just need the trigger to work, i know the coding sucks with all the BJs, but it's nothing that i'll put on hive, it's for my map...

JASS:
function Trig_Attack_Deflection_Conditions takes nothing returns boolean
    if ( not ( GetSpellTargetUnit() == udg_DefCaster ) ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Deflection_Actions takes nothing returns nothing

    local unit DefUser = GetTriggerUnit()
    
    local integer DefSpell = GetSpellAbilityId()
    
    local unit DefDummy
    
    local unit DefCaster = udg_DefCaster
    
    set DefDummy = CreateUnitAtLoc( GetOwningPlayer(DefCaster), 'h004', GetUnitLoc(DefCaster), bj_UNIT_FACING )
    
    call UnitAddAbility(DefDummy, DefSpell)
    
    call SetUnitAbilityLevelSwapped(DefSpell, DefDummy, GetUnitAbilityLevelSwapped(DefSpell, DefUser) )
    
    call IssueTargetOrderById(DefDummy, DefSpell, DefUser)
    
    call UnitApplyTimedLifeBJ( 5.00, 'BTLF', DefDummy )
    
    
    
    set DefUser = null
    set DefDummy = null
    set DefCaster = null
endfunction

//===========================================================================
function InitTrig_Attack_Deflection takes nothing returns nothing
    local trigger gg_trg_Attack_Deflection = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Deflection, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Attack_Deflection, Condition( function Trig_Attack_Deflection_Conditions ) )
    call TriggerAddAction( gg_trg_Attack_Deflection, function Trig_Attack_Deflection_Actions )
endfunction

The spell works as it should exept for the part when the dummy should cast the spell on DefUser.
 
... Don't you see, there is no constant string, the ability is added that was used, no sense to check if it's never same lol...

I just request a fixed working trigger, I don't know how to fix myself, might learn after it works for further spells...

Oh sorry..... but doesn't GetSpellAbilityID() need a parameter?

EDIT: oh yeah, it doesn't

I guess you can get the orderstring of the ability casted upon you then use that same orderstring to cast the spell.

I saw this at one thread here..
  • Untitled Trigger 001 Copy
    • Events
    • Unit - A unit Is issued an order targeting an object
    • Unit - A unit Is issued an order targeting a point
    • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
    • Game - Display to (All players) the text: ((String((Issued order))) + (Name of (Ordered unit)))
he used the trigger to see the spell's order though I dont know if it worked. Cannot try it until I get home..
 
Level 7
Joined
Mar 8, 2009
Messages
360
GetSpellAbilityID() doesn't need paramaters.

i think the problem is that the dummy has the same owner as the paladin and that your spells can't be cast on allies.
I think this should work:
JASS:
set DefDummy = CreateUnitAtLoc( GetOwningPlayer(DefUser), 'h004', GetUnitLoc(DefCaster), bj_UNIT_FACING )
 
GetSpellAbilityID() doesn't need paramaters.

i think the problem is that the dummy has the same owner as the paladin and that your spells can't be cast on allies.
I think this should work:
JASS:
set DefDummy = CreateUnitAtLoc( GetOwningPlayer(DefUser), 'h004', GetUnitLoc(DefCaster), bj_UNIT_FACING )

Ithink defcaster is the paladin and defuser is the enemy who casted the spell, look at the condition....
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
There you go, unBJ'ed. I think the problem is the OrderById.

JASS:
function Trig_Attack_Deflection_Conditions takes nothing returns boolean
    return GetSpellTargetUnit() == udg_DefCaster
endfunction

function Trig_Attack_Deflection_Actions takes nothing returns nothing 
    local unit DefUser = GetTriggerUnit()          
    local integer DefSpell = GetSpellAbilityId()    
    local unit DefDummy           
    local unit DefCaster = udg_DefCaster

    set DefDummy = CreateUnit(GetOwningPlayer(DefCaster), 'h004', GetUnitX(DefCaster), GetUnitY(DefCaster), bj_UNIT_FACING)
    call UnitAddAbility(DefDummy, DefSpell) 
    call SetUnitAbilityLevel(DefDummy, DefSpell, GetUnitAbilityLevel(DefUser, DefSpell)) 
    call IssueTargetOrderById(DefDummy, DefSpell, DefUser)
    call UnitApplyTimedLife(DefDummy, 'BTLF', 5.00)
    
    set DefUser = null
    set DefDummy = null
    set DefCaster = null
endfunction

//===========================================================================
function InitTrig_Attack_Deflection takes nothing returns nothing
    local trigger lt_Attack_Deflection = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(lt_Attack_Deflection, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(lt_Attack_Deflection, Condition(function Trig_Attack_Deflection_Conditions))
    call TriggerAddAction(lt_Attack_Deflection, function Trig_Attack_Deflection_Actions)
endfunction
 
The only (and feasible) way I see to do so is creating a hashtable (or two arrays, but hashtables would be much faster I guess) and link the ability id with its order id manually:

JASS:
call SaveString( Hashtable, 0, 'Aslo', "slow" )
call SaveString( Hashtable, 0, 'Awst', "warstomp" )
call SaveString( Hashtable, 0, 'A000', "channel" )

// -- Then, in your trigger --
local string Order = LoadString( Hashtable, 0, GetSpellAbilityId() )
call IssueTargetOrder( DefDummy, Order, DefUser )
 
Create a global hashtable variable (don't know if you use JNGP, I'll assume you don't). I'll call it udg_Hashtable.

JASS:
// -- This can be put in the map header (the very first thing in the triggers list) --
function InitOrderStrings takes nothing returns nothing
    call SaveString( udg_Hashtable, 0, 'Aslo', "slow" )
    call SaveString( udg_Hashtable, 0, 'Awst', "warstomp" )
    call SaveString( udg_Hashtable, 0, 'A000', "channel" )
// -- Repeat for every spell that can be "copied" by DefUser --
endfunction

In a trigger with Map Initialization event, call the above function:
  • Custom script: call InitOrderStrings()
Then, your spell should look like this (updated by Reaper2008):
JASS:
function Trig_Attack_Deflection_Conditions takes nothing returns boolean
    return GetSpellTargetUnit() == udg_DefCaster
endfunction

function Trig_Attack_Deflection_Actions takes nothing returns nothing
    local unit DefUser = GetTriggerUnit()
    local integer DefSpell = GetSpellAbilityId()
    local unit DefDummy
    local unit DefCaster = udg_DefCaster
    local string Order = LoadString( udg_Hashtable, 0, DefSpell )

set DefDummy = CreateUnit(GetOwningPlayer(DefCaster), 'h004', GetUnitX(DefCaster), GetUnitY(DefCaster), bj_UNIT_FACING)
    call UnitAddAbility(DefDummy, DefSpell)
    call SetUnitAbilityLevel(DefDummy, DefSpell, GetUnitAbilityLevel(DefUser, DefSpell))
    call IssueTargetOrder(DefDummy, Order, DefUser)
    call UnitApplyTimedLife(DefDummy, 'BTLF', 5.00)

    set DefUser = null
    set DefDummy = null
    set DefCaster = null
endfunction

//===========================================================================
function InitTrig_Attack_Deflection takes nothing returns nothing
    local trigger lt_Attack_Deflection = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(lt_Attack_Deflection, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(lt_Attack_Deflection, Condition(function Trig_Attack_Deflection_Conditions))
    call TriggerAddAction(lt_Attack_Deflection, function Trig_Attack_Deflection_Actions)
endfunction

The hashtable will "link" the ability to its order. So, with the ability id, you can get its corresponding order string and order your dummy to cast the spell.
 
Status
Not open for further replies.
Top