• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Variable not declared

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
JASS:
scope spawnHellHounds
//initializer OnInit

//globals

//endglobals





function checker takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A046' ) ) then
        return false
    endif
    return true
endfunction


function spawnHell takes nothing returns nothing
    if ( checker() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'n008', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc() )
        call AddSpecialEffectTargetUnitBJ( "head", GetLastCreatedUnit(), "Environment\\LargeBuildingFire\\LargeBuildingFire2.mdl" )
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", GetSpellTargetLoc() )
        set udg_TempPoint = GetSpellTargetLoc()
        call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
        call SelectUnitAddForPlayer( GetLastCreatedUnit(), GetOwningPlayer(GetTriggerUnit()) )
        call RemoveLocation(udg_TempPoint)
    else
    endif
endfunction



function activate takes nothing returns nothing
    set spawner = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(spawner, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddAction(spawner, function spawnHell)
endfunction






endscope


When I compile this it says 'spawner' was not declared properly. What am I doing something wrong here?
 
Level 12
Joined
Dec 2, 2016
Messages
733
Where do you declare spawner? (defining what type of variable it should be)



I'm trying to convert this to code.


  • Spawn Fel Beasts
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Hell Hound Ability
        • Then - Actions
          • Unit - Create 1 Hell Hound for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Target point of ability being cast)
          • Special Effect - Create a special effect attached to the head of (Last created unit) using Environment\LargeBuildingFire\LargeBuildingFire2.mdl
          • Unit - Order (Last created unit) to Move To (Target point of ability being cast)
          • Set TempPoint = (Target point of ability being cast)
          • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
          • Selection - Add (Last created unit) to selection for (Owner of (Triggering unit))
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions


^ this works and spawns a unit


JASS:
scope spawnHellHounds
//initializer OnInit

globals

public trigger spawner
endglobals





function checker takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A046' ) ) then
        return false
    endif
    return true
endfunction


function spawnHell takes nothing returns nothing
    if ( checker() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'n008', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc() )
        call AddSpecialEffectTargetUnitBJ( "head", GetLastCreatedUnit(), "Environment\\LargeBuildingFire\\LargeBuildingFire2.mdl" )
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", GetSpellTargetLoc() )
        set udg_TempPoint = GetSpellTargetLoc()
        call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
        call SelectUnitAddForPlayer( GetLastCreatedUnit(), GetOwningPlayer(GetTriggerUnit()) )
        call RemoveLocation(udg_TempPoint)
    else
    endif
endfunction




function activate takes nothing returns nothing
    set spawner = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(spawner, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddAction(spawner, function spawnHell)
endfunction






endscope

^ this isn't working, I defined 'spawner' but the ability doesn't spawn a unit. Any idea what I'm doing wrong here?
I need to make this into a script because I've got another script that includes the current game minute, which I'll need to set this spawned units damage to 1000* current minute. I figured would be easier to alter in code.
 
JASS:
scope spawnHellHounds
//initializer OnInit
^here you can define a function that should run on initialization. In current case, no function will run. So change it to:
JASS:
scope spawnHellHounds initializer activate

If still nothing works you can print debug messages to find it out. Also, ensure the rawcodes 'n008' and 'A046' are correct.
 
Level 41
Joined
Feb 27, 2007
Messages
5,184
Bo is correct, thats the only thing causing the trigger not to run. In regular JASS each trigger has an initTrig function that the game knows to call on map initialization (it's the one created at the very bottom after you click "convert to custom text"). vJASS removes these so if you want something to run on init (like a trigger declaration) you have to write the initializer in.

Also in general you should use EVENT_PLAYER_UNIT_SPELL_EFFECT instead of ...SPELL_CHANNEL.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Bo is correct, thats the only thing causing the trigger not to run. In regular JASS each trigger has an initTrig function that the game knows to call on map initialization (it's the one created at the very bottom after you click "convert to custom text"). vJASS removes these so if you want something to run on init (like a trigger declaration) you have to write the initializer in.

Also in general you should use EVENT_PLAYER_UNIT_SPELL_EFFECT instead of ...SPELL_CHANNEL.
Okay thanks!
 
Status
Not open for further replies.
Top