Starting jass

rexpim

Member
Reaction score
8
So i got this but got one problem, no tree is showing up

JASS:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//              -Made By REX  helped by members of <a href="http://www.thehelper.net/" class="link link--internal">http://www.thehelper.net/</a>
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//===========================================================================
scope NatureStrike

globals
    private constant integer NATURESTRIKE = &#039;A01U&#039;   // Nature Strike RAW CODE
    private constant integer TREE = &#039;BTtw&#039;               // Tree RAW CODE
    private constant integer VAR = 2                     // Tree variation
    private constant real SCALE = 2.00                 // Tree scale size
    private constant real LIFE = 20.00                 // Tree life time
endglobals
//===========================================================================
//===========================================================================
private struct data

    private timer t
    private destructable FSTREE

static method kill takes nothing returns nothing
    local thistype this=GetTimerData(GetExpiredTimer())
    call RemoveDestructable(.FSTREE)
    call ReleaseTimer(GetExpiredTimer())
    set .FSTREE=null
    set .t=null
endmethod

static method create takes nothing returns thistype
    local thistype this=.allocate()
    set .t=NewTimer()
    set .FSTREE = CreateDestructable(TREE, GetSpellTargetX(), GetSpellTargetY(), GetRandomReal(1.,360.),SCALE,VAR) // use of coordinates instead of locations
    call SetTimerData(.t,this)
    call TimerStart(t,LIFE,false,function thistype.kill)
    return this
endmethod

endstruct

private function Trig_NatureStrike_Actions takes nothing returns nothing
    local data t=data.create()
endfunction
//===========================================================================
pprivate function InitTrig_NatureStrike takes nothing returns nothing
    call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),NATURESTRIKE),function Trig_NatureStrike_Actions)
endfunction

endscope


added
JASS:
private function InitTrig_NatureStrike takes nothing returns nothing
    call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),NATURESTRIKE),function Trig_NatureStrike_Actions)
endfunction
GTrigger
 

Zeth

Member
Reaction score
3
Updated
I got a question, i saw in some spells this
JASS:
   local trigger t = CreateTrigger(  )
    
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( t, function Actions )
    call TriggerAddCondition(t,Condition(function Conditions))

So why create a local trigger?
Can i create the same local trigger for various trigger?

???

When you create a trigger, it's unique. Then you can use it for detect an event, add conditions and actions,etc... You can't use "the same local trigger for various triggers" because the local triggers only can be used in the function they are declared (init function)...

And remember:

JASS:
set t=null
 

Laiev

Hey Listen!!
Reaction score
188
pprivate?

also it don't work because theres no Spell Target X/Y inside the struct data
 

Zeth

Member
Reaction score
3
I tried with a global function ...

JASS:
function InitTrig_NatureStrike takes nothing returns nothing
    call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),NATURESTRIKE),function Trig_NatureStrike_Actions)
endfunction


And it works... but i don't know why xD

Also you can use:

JASS:
function InitTrig_NatureStrike takes nothing returns nothing
    call GT_AddStartsEffectAction(function Trig_NatureStrike_Actions, NATURESTRIKE)
endfunction


--------------
Anyone know why not work with a private function?
 

rexpim

Member
Reaction score
8
???

When you create a trigger, it's unique. Then you can use it for detect an event, add conditions and actions,etc... You can't use "the same local trigger for various triggers" because the local triggers only can be used in the function they are declared (init function)...

And remember:

JASS:
set t=null
ty for the help
pprivate?

also it don't work because theres no Spell Target X/Y inside the struct data
JASS:
set .FSTREE = CreateDestructable(TREE, GetSpellTargetX(), GetSpellTargetY(), GetRandomReal(1.,360.),SCALE,VAR)

the pprivate is correct in my trigger but the GetSpellTargetX(), GetSpellTargetY(), appears in black not in purple
 

Zeth

Member
Reaction score
3
^ Te correct keyword is private.

GetSpellTargetX() and GetSpellTargetY() are natives that are recently added by blizzard. NewGen don't higlight them... But they work!

Sorry for my sucker english xD
 

Laiev

Hey Listen!!
Reaction score
188
don't work with private because you need an initializer


scope <name of scope> initializer <name of function which will be initialized>

in this example:

scope NatureStrike initializer InitTrig_NatureStrike
 

Jesus4Lyf

Good Idea™
Reaction score
397
Also you can use:

JASS:
function InitTrig_NatureStrike takes nothing returns nothing
    call GT_AddStartsEffectAction(function Trig_NatureStrike_Actions, NATURESTRIKE)
endfunction
You really need to read the documentation before suggesting that:
JASS:
//	Alternative interface (not recommended):
//		If you aren&#039;t familiar with how this works, you shouldn&#039;t use it.
//		All funcs must return false. (That is the only reason it isn&#039;t recommended.)
//...
//		   // Ability Events
//		 - GT_AddStartsEffectAction(func, abilityid)
It is for condition style actions, which this is not. The actions must return false as a boolean, or it may have unpredictable results such as desynchs. The original method used is the recommended one for these things, for that reason..
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top