Once again i need help..

0zaru

Learning vJASS ;)
Reaction score
60
Ok here is my triggers:

JASS:
constant function NTDummyID takes nothing returns integer
return 'h001'
endfunction
constant function NTDummyAbID takes nothing returns integer
return 'A006'
endfunction
constant function NTAbID takes nothing returns integer
return 'A004'
endfunction
function GetDuration takes unit Hero returns real
local integer Level=GetUnitAbilityLevel(Hero,NTAbID())
if Level==1 then
return 20.00
elseif Level==2 then
return 30.00
elseif Level==3 then
return 40.00
elseif Level==4 then
return 50.00
endif
return 20.00
endfunction

function Trig_Natures_Shield_Conditions takes nothing returns boolean
return GetSpellAbilityId() == NTAbID()
endfunction

function NatureShieldDummyCast takes nothing returns nothing
local unit Target=GetTriggerUnit()
local unit Caster=GetHandleUnit(Target,"Caster")
local real x=GetUnitX(Target)
local real y=GetUnitY(Target)
local integer level=GetUnitAbilityLevel(Caster,NTAbID())
local integer Chances=5*level
if GetRandomInt(1,100)<=Chances then
call CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call SetUnitAbilityLevel(GetLastCreatedUnit(),NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(GetLastCreatedUnit(),"entanglingroots",GetAttacker())
endif
set Target=null
set Caster=null
endfunction

function Trig_Natures_Shield_Actions takes nothing returns nothing
local unit Caster=GetSpellAbilityUnit()
local unit Target=GetSpellTargetUnit()
local player Owner=GetOwningPlayer(Caster)
local trigger t=CreateTrigger()
call SetHandleHandle(Target,"Caster",Caster)
call TriggerRegisterUnitEvent(t,Target,EVENT_UNIT_ATTACKED)
call TriggerAddAction(t,function NatureShieldDummyCast)
call TriggerSleepAction(GetDuration(Caster))
call FlushHandleLocals(Target)
set Caster=null
set Target=null
set t=null
call DestroyTrigger(t)
endfunction

//===========================================================================
function InitTrig_Natures_Shield takes nothing returns nothing
    set gg_trg_Natures_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Natures_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Natures_Shield, Condition( function Trig_Natures_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Natures_Shield, function Trig_Natures_Shield_Actions )
endfunction


Well it seems that isn't working any idea why ?
(I am sure that are the local trigger things but it's the first time that i use them so i don't know if it is..)

I use Kattana Handle Vars. All Constant are fine....

hmm maybe target can't be used like a Handle ?.. And i have to add a condition that check if the unit has the buff but i deleted it for test the spell.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Edit: K I think I found it.

JASS:
call CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call SetUnitAbilityLevel(GetLastCreatedUnit(),NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(GetLastCreatedUnit(),"entanglingroots",GetAttacker())


You can't set the level of an ability that's not even on the Unit. You have to add the ability THEN set the level.

So you may want to use:

JASS:
call CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call UnitAddAbility(GetLastCreatedUnit(), NTDummyAbID())
call SetUnitAbilityLevel(GetLastCreatedUnit(),NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(GetLastCreatedUnit(),"entanglingroots",GetAttacker())
 

0zaru

Learning vJASS ;)
Reaction score
60
Actually i forgot to say this:

The unit has the ability actually. (The dummy ab)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232

substance

New Member
Reaction score
34
JASS:
if GetRandomInt(1,100)<=Chances then
call CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call SetUnitAbilityLevel(GetLastCreatedUnit(),NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(GetLastCreatedUnit(),"entanglingroots",GetAttacker())
endif


I believe this is the problem. As far as I know CreateUnit() doesn't return GetLastCreatedUnit... Try setting the created unit into a local and use it, see how it works.

ie:
JASS:
local unit dummy
.....
set dummy = CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call SetUnitAbilityLevel(dummy,NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(dummy,"entanglingroots",GetAttacker())
 

0zaru

Learning vJASS ;)
Reaction score
60
I Tried again but it doesn't work either.. :S

JASS:
 constant function NTDummyID takes nothing returns integer
return 'h001'
endfunction
constant function NTDummyAbID takes nothing returns integer
return 'A006'
endfunction
constant function NTAbID takes nothing returns integer
return 'A004'
endfunction
constant function NTBuff takes nothing returns integer
return 'B002'
endfunction
function GetDuration takes unit Hero returns real
local integer Level=GetUnitAbilityLevel(Hero,NTAbID())
if Level==1 then
return 20.00
elseif Level==2 then
return 30.00
elseif Level==3 then
return 40.00
elseif Level==4 then
return 50.00
endif
return 20.00
endfunction

function Trig_Natures_Shield_Conditions takes nothing returns boolean
return GetSpellAbilityId() == NTAbID()
endfunction
function NTShieldDummyCond takes nothing returns boolean
return (GetUnitAbilityLevel(GetTriggerUnit(), NTBuff()) > 0)
endfunction
function NatureShieldDummyCast takes nothing returns nothing
local unit Target=GetTriggerUnit()
local unit Caster=GetHandleUnit(Target,"Caster")
local unit dummy
local real x=GetUnitX(Target)
local real y=GetUnitY(Target)
local integer level=GetUnitAbilityLevel(Caster,NTAbID())
local integer Chances=5*level
if GetRandomInt(1,100)<=Chances then
set dummy=CreateUnit(GetOwningPlayer(Caster),NTDummyID(),x,y,bj_UNIT_FACING)
call SetUnitAbilityLevel(dummy,NTDummyAbID(),GetUnitAbilityLevel(Caster,NTAbID()))
call IssueTargetOrder(dummy,"entanglingroots",GetAttacker())
endif
set Target=null
set Caster=null
endfunction

function Trig_Natures_Shield_Actions takes nothing returns nothing
local unit Caster=GetSpellAbilityUnit()
local unit Target=GetSpellTargetUnit()
local player Owner=GetOwningPlayer(Caster)
local trigger t=CreateTrigger()
call SetHandleHandle(Target,"Caster",Caster)
call TriggerRegisterUnitEvent(t,Target,EVENT_UNIT_ATTACKED)
call TriggerAddCondition(t,Condition(function NTShieldDummyCond))
call TriggerAddAction(t,function NatureShieldDummyCast)
call TriggerSleepAction(GetDuration(Caster))
call FlushHandleLocals(Target)
set Caster=null
set Target=null
set t=null
call DestroyTrigger(t)
endfunction

//===========================================================================
function InitTrig_Natures_Shield takes nothing returns nothing
    set gg_trg_Natures_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Natures_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Natures_Shield, Condition( function Trig_Natures_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Natures_Shield, function Trig_Natures_Shield_Actions )
endfunction

This is how it seems now..

-> i.e
Already do the same :p
 

substance

New Member
Reaction score
34
K well if I'm gonna help I might as well help all the way....

First things first, get rid of those constant function calls and just declare globals so you can replace this:
JASS:
constant function NTDummyID takes nothing returns integer
return 'h001'
endfunction
constant function NTDummyAbID takes nothing returns integer
return 'A006'
endfunction
constant function NTAbID takes nothing returns integer
return 'A004'
endfunction
constant function NTBuff takes nothing returns integer
return 'B002'
endfunction
with this:
JASS:
globals
 constant integer NTDummyID = 'h001'
 constant integer NTDummyAbID = 'A006'
 etc..
endglobals
**This method requires vJass which can be found in the Jass NewGen Pack (you reference them the same way but just without the '()').

Now onto your main function:
JASS:
function Trig_Natures_Shield_Actions takes nothing returns nothing
local unit Caster=GetSpellAbilityUnit()
local unit Target=GetSpellTargetUnit()
local player Owner=GetOwningPlayer(Caster)
local trigger t=CreateTrigger()
call SetHandleHandle(Target,"Caster",Caster)
call TriggerRegisterUnitEvent(t,Target,EVENT_UNIT_ATTACKED)
call TriggerAddCondition(t,Condition(function NTShieldDummyCond))
call TriggerAddAction(t,function NatureShieldDummyCast)
call TriggerSleepAction(GetDuration(Caster))
call FlushHandleLocals(Target)
set Caster=null
set Target=null
set t=null
call DestroyTrigger(t)
endfunction
I dunno why you made 'GetDuration' an outside function when you could have just put it in this function(Trig_Natures_Shield_Actions). You can also simplify this:
JASS:
local integer Level=GetUnitAbilityLevel(Hero,NTAbID())
if Level==1 then
return 20.00
elseif Level==2 then
return 30.00
elseif Level==3 then
return 40.00
elseif Level==4 then
return 50.00
endif
return 20.00
with this:
JASS:
local integer Level = (GetUnitAbilityLevel(Hero,NTAbID) * 10) + 10
**BTW, you reference 'Hero' there and you never delacared 'Hero'**. You also destroy 't' after you set 't' to null, which won't work. To properly clean up trigger you should remove all actions, disable the trigger, destroy the trigger then null it. You should also work on spacing to make everything easier to read so your final result will look something more like this:
JASS:
function Trig_Natures_Shield_Actions takes nothing returns nothing
 local unit Caster = GetSpellAbilityUnit()
 local unit Target = GetSpellTargetUnit()
 local player Owner = GetOwningPlayer(Caster)
 local real duration = (GetUnitAbilityLevel(Caster,NTAbID) * 10) + 10
 local trigger t = CreateTrigger() 
 local triggeraction ta
 
    call SetHandleHandle(Target,"Caster",Caster)
    call TriggerRegisterUnitEvent(t,Target,EVENT_UNIT_ATTACKED)
    set ta = TriggerAddCondition(t,Condition(function NTShieldDummyCond))
    call TriggerAddAction(t,function NatureShieldDummyCast)
    
    call TriggerSleepAction(duration)
    
    call FlushHandleLocals(Target)
    call TriggerRemoveAction(t,ta)
    call DisableTrigger(t)     
    call DestroyTrigger(t)
    set t = null
    set ta = null      
    set Caster = null
    set Target = null          
endfunction
The last function wasn't bad, just a few clean ups:
JASS:
function NatureShieldDummyCast takes nothing returns nothing
 local unit Target = GetTriggerUnit()
 local unit Caster = GetHandleUnit(Target,"Caster")
 local unit dummy
 local real x = GetUnitX(Target)
 local real y = GetUnitY(Target)
 local integer level = GetUnitAbilityLevel(Caster,NTAbID)
 local integer Chances = 5*level
 
    if GetRandomInt(1,100) <= Chances then
       set dummy = CreateUnit(GetOwningPlayer(Caster),NTDummyID,x,y,270.0)
       call SetUnitAbilityLevel(dummy,NTDummyAbID,level)
       call IssueTargetOrder(dummy,"entanglingroots",GetAttacker())
    endif
    
    set Target = null
    set Caster = null
    set dummy = null
endfunction


That should keep you busy for a while >8]
 

0zaru

Learning vJASS ;)
Reaction score
60
Thanks!! It worked :D

Only a comment. It's not a trigger action that, It's a triggercondition :p
 

0zaru

Learning vJASS ;)
Reaction score
60
I am sorry to bump this again but once again it doesn't work i have this now:
JASS:
globals  
constant integer NTDummyID = 'h001'  
constant integer NTDummyAbID = 'A006'  
constant integer NTAbID = 'A004'
constant integer NTBuff = 'B002'
endglobals

function NTShieldDummyCond takes nothing returns boolean
return GetUnitAbilityLevel(GetTriggerUnit(), NTBuff) > 0
endfunction

function Trig_Natures_Shield_Conditions takes nothing returns boolean
return GetSpellAbilityId() == NTAbID
endfunction

function NatureShieldDummyCast takes nothing returns nothing
local unit Target=GetTriggerUnit()
local unit Caster=GetHandleUnit(Target,"Caster")
local unit dummy
local real x=GetUnitX(Target)
local real y=GetUnitY(Target)
local integer level=GetUnitAbilityLevel(Caster,NTAbID)
local integer Chances=5*level
if GetRandomInt(1,100)<= Chances then
set dummy = CreateUnit(GetOwningPlayer(Caster),NTDummyID,x,y,270.0)
call SetUnitAbilityLevel(dummy,NTDummyAbID,level)
call IssueTargetOrder(dummy,"entanglingroots",GetAttacker())
endif
set Target=null
set Caster=null
set dummy=null
endfunction

function Trig_Natures_Shield_Actions takes nothing returns nothing
local unit Caster=GetSpellAbilityUnit()
local unit Target=GetSpellTargetUnit()
local trigger t=CreateTrigger()
local real duration = (GetUnitAbilityLevel(Caster,NTAbID) * 10) + 10
local triggercondition ta
call SetHandleHandle(Target,"Caster",Caster)
call TriggerRegisterUnitEvent(t,Target,EVENT_UNIT_ATTACKED)
set ta = TriggerAddCondition(t,Condition(function NTShieldDummyCond))
call TriggerAddAction(t,function NatureShieldDummyCast)
call PolledWait(duration)
call FlushHandleLocals(Target)
call TriggerRemoveCondition(t,ta)
call DisableTrigger(t)     
call DestroyTrigger(t)
set t = null
set ta = null      
set Caster = null
set Target = null   
endfunction

//===========================================================================
function InitTrig_Natures_Shield takes nothing returns nothing
    set gg_trg_Natures_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Natures_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Natures_Shield, Condition( function Trig_Natures_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Natures_Shield, function Trig_Natures_Shield_Actions )
endfunction


Currently i don't know what's wrong 'cause i only added a condition.... But i check the condition and seems fine =/. I didn't want to create a new thread when there is one with the same problem that i created. All the RawCodes are fine.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Damn... Why does everyone create a local unit for a created unit?? It takes up two lines; the creation, and the nulling. When bj_lastCreatedUnit doesn't even take up one line! Just remove "local unit dummy" and "set dummy = null". Then change each dummy parameter including the setting to be "bj_lastCreatedUnit". It is good to take advantage of Blizzard's globals.

Lol... :p

Well, I can't see any problems with your code. Are you sure the condition is correct? Does the Buff exist? I can't really see any problems with your code right now. Maybe I'm just not looking hard enough. :p
 

0zaru

Learning vJASS ;)
Reaction score
60
I put that variable 'cause they tell me that bj_lastCreatedUnit does not work with CreateUnit.

The buffs is there. It exist.
 

0zaru

Learning vJASS ;)
Reaction score
60
Does not give me any errors it simply does not work =/ What more can i say? :S
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top