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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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