Adding Functions To A Trigger?

T

Toto.

Guest
-IDK if title was said correctly..-

But anyway, Ive recently posted another thread on fixing my errors (Im pretty newbish at JASS atm), which I have gotten help in and fixed. But now, Im onto making the functions for my Grenade Spell work in-game, but they seem to not. :| I dont know if posting this here will get me help, because Id need someone familiar with the Particle System.. but then again, this might be very popular.

Anyway, heres my trigger:

JASS:
function Trig_ThrowGrenade_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'
endfunction

function Trig_ThrowGrenade_Actions takes nothing returns nothing
endfunction

function Trig_ThrowGrenade1_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u
endfunction

function Trig_ThrowGrenade2_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
endfunction

function Trig_ThrowGrenade3_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
call ParticleSetSpeed(u,GetLocationX(topos)-GetLocationX(casterpos),GetLocationY(topos)-GetLocationY(casterpos),1200)
endfunction

function Trig_ThrowGrenade3_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
call ParticleSetSpeed(u,GetLocationX(topos)-GetLocationX(casterpos),GetLocationY(topos)-GetLocationY(casterpos),1200)
endfunction

function Trig_ThrowGrenade4_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
call ParticleSetSpeed(u,GetLocationX(topos)-GetLocationX(casterpos),GetLocationY(topos)-GetLocationY(casterpos),1200)
call ParticleLinkConditionTrigger2Func(u, ParticleGroundHit(), "GroundHit_Bounce")
call ParticleLinkConditionTrigger2Func(u, ParticleDeath(), "Death_Remove")
call ParticleAddForce(u, G())
endfunction

function Death_RemoveBoom takes nothing returns nothing
  local location upos = GetUnitLoc(GetEnumUnit())
  local effect eff = AddSpecialEffectLocBJ(upos, "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl")  
  call DestroyEffect(eff)
  call RemoveParticle(GetEnumUnit(),true)
  call RemoveLocation(upos)
  set upos=null
endfunction

//===========================================================================
function InitTrig_ThrowGrenade takes nothing returns nothing
    set gg_trg_ThrowGrenade = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ThrowGrenade, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_ThrowGrenade, Condition( function Trig_ThrowGrenade_Conditions ) )
    call TriggerAddAction( gg_trg_ThrowGrenade, function Trig_ThrowGrenade_Actions )
endfunction


I have doubled checked on all of the ID's and they're all correct, but nothing happens at all in-game. I cast the Grenade spell and all my unit does is face the casting point. If anyone is familiar with the Particle System, or if they can just figure out my problem, then please help..


-NOTE: I have followed the directions and gotten the information for my Grenade Spell from this Tutorial -Here-
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
JASS:
call TriggerAddAction( gg_trg_ThrowGrenade, function Trig_ThrowGrenade_Actions

That means that the Trig_ThrowGrenade_Actions will be executed.
But your Trig_ThrowGrenade_Actions is completely empty.

Also you haven't nulled all the local variables. At the end of each function you should write
JASS:
set <variable> = null

for every local unit, location and effect and additionally
JASS:
call RemoveLocation( <variable> )

for every location before you null it

edit: oh, ok, you did remove some of them, but not all; and most nulling is missing.

edit2: Uhmm... I think you didn't get the concept of triggering. You copied every step of the tutorial, but in fact that was always the same function, but in different steps of development. Most of your functions are useless.

That is the complete trigger, which is displayed in your tutorial
JASS:
function Trig_ThrowGrenade_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_ThrowGrenade_Actions takes nothing returns nothing
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location topos = GetSpellTargetLoc()
local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
call ParticleSetSpeed(u,GetLocationX(topos)-GetLocationX(casterpos),GetLocationY(topos)-GetLocationY(casterpos),1200)
call ParticleLinkConditionTrigger2Func(u, ParticleGroundHit(), "GroundHit_Bounce")
call ParticleLinkConditionTrigger2Func(u, ParticleDeath(), "Death_Remove")
call ParticleAddForce(u, G())
call RemoveLocation(casterpos)
call RemoveLocation(topos)
set casterpos=null
set topos=null
set u = null
endfunction

//===========================================================================
function InitTrig_ThrowGrenade takes nothing returns nothing
    set gg_trg_ThrowGrenade = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ThrowGrenade, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_ThrowGrenade, Condition( function Trig_ThrowGrenade_Conditions ) )
    call TriggerAddAction( gg_trg_ThrowGrenade, function Trig_ThrowGrenade_Actions )
endfunction
 
T

Toto.

Guest
OOOOHHHHH

hahaha i feel like a complete idiot. Tyvm

xD sorry for my stupidity..
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top