• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Getting an error on the call line

Status
Not open for further replies.
Level 5
Joined
Aug 8, 2008
Messages
113
  • Drain Level 1
    • Events
      • Unit - A unit owned by Player 1 (Red) Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Healing Ward (Level 1)
    • Actions
      • Set Caster = (Summoning unit)
      • Set Summon = (Summoned unit)
      • Wait 0.00 game-time seconds
      • Unit - Create 1 Phos Dummy for Player 3 (Teal) at (Position of Summon) facing (Position of Caster)
      • Wait 0.00 game-time seconds
      • Set Dummy = (Last created unit)
      • Wait 0.00 game-time seconds
      • Unit - Add Life Drain Damage to Dummy
      • Unit - Add Phos Banish to Dummy
      • Wait 0.00 game-time seconds
      • Unit - Set level of Life Drain Damage for Dummy to 1
      • Unit - Set level of Phos Banish for Dummy to 1
      • Wait 0.00 game-time seconds
      • Unit - Order Dummy to Human Blood Mage - Banish Caster
      • Unit - Order Dummy to Night Elf Warden - Shadow Strike Caster
      • Wait 0.01 game-time seconds
      • Unit - Add a 8.00 second Generic expiration timer to Dummy
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entire map) contains Dummy) Equal to True
        • Then - Actions
          • Set Unit_pres01 = 1
          • Custom script: call funcLoop_Life() // where i get the error Says its an undeclared function
        • Else - Actions
          • Set Unit_pres01 = 0
      • Custom script: endfunction
      • Custom script: function funcLoop_Life takes nothing returns boolean
      • Custom script: if udg_Unit_pres01>0 then
      • Custom script: loop
      • Custom script: exitwhen udg_Unit_present01<1
      • Custom script: if ( RectContainsUnit(GetPlayableMapRect(), udg_Dummy_4) == true ) then
      • Wait 0.00 game-time seconds
      • Unit - Add Life Drain Animation to Dummy_4
      • Wait 0.00 game-time seconds
      • Unit - Set level of Life Drain Animation for Dummy to 1
      • Wait 0.00 game-time seconds
      • Unit - Order Dummy_4 to Human Mountain King - Storm Bolt Dummy
      • Wait 0.23 game-time seconds
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: else
      • Custom script: endif
      • Custom script: if ( RectContainsUnit(GetPlayableMapRect(), udg_Dummy_4) == false ) then
      • Unit - Create 1 Phos Dummy for (Owner of Caster) at (Position of Caster) facing (Position of Dummy)
      • Set Dummy_4 = (Last created unit)
      • Custom script: else
      • Custom script: endif
      • Custom script: endloop
      • Custom script: endif
 
In JASS you only can call functions directly which are above in code. Your function is not, so it throws an error.

You start 2 "ifs" via custom script but you have 3x "endif".

Your function "funcLoop_Life" should return a boolean, but you don't return anything.

And waits only work properly in an ActionFunction. But you end it with using "endfunction" before. Anyway I don't see sense for the waits, I guess you just can remove them.

And why do you try to create a new function at all in the action function? :O
 
Level 5
Joined
Aug 8, 2008
Messages
113
In JASS you only can call functions directly which are above in code. Your function is not, so it throws an error.

You start 2 "ifs" via custom script but you have 3x "endif".

Your function "funcLoop_Life" should return a boolean, but you don't return anything.

And waits only work properly in an ActionFunction. But you end it with using "endfunction" before. Anyway I don't see sense for the waits, I guess you just can remove them.

And why do you try to create a new function at all in the action function? :O

didn't know that about waits...


I switched it to jass and I get the same error when I place the funcloop above the main function though this time for the udg_Unitpres01..... I split it into two functions because I thought it run smoother.

it just didn't work when i had it as one function
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Your function declaration indicates that it returns a boolean yet the implementation does not. You either need to make the function decleration state that it "returns nothing" or add a return of type boolean at the end of the function and anywhere appropriate.

Please post the errors you are getting, it makes finding the cause easier than looking through a mess of GUI JASS hybrid rubbish.
 
Level 5
Joined
Aug 8, 2008
Messages
113
The issue is that the animation wouldnt start I figured out why though its because I didn't declare a dummy_4 but I changed the script to be much simpler and now it almost works perfectly.
The only issues are that

  • one it doesn't deal poison damage to the caster. The poison skill is based off of poison attack.
  • two it doesn't teleport the dummy. the animation stays static and when you move the caster it looks like the life drain is coming from mid air. I'll post my update script in a seccond



  • Drain lvl 1
    • Events
      • Unit - A unit owned by Player 1 (Red) Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Healing Ward (Level 1)
    • Actions
      • Set Caster = (Summoning unit)
      • Set Summon = (Summoned unit)
      • Wait 0.00 game-time seconds
      • Unit - Create 1 Phos Dummy for Player 3 (Teal) at (Position of Summon) facing (Position of Caster)
      • Wait 0.00 game-time seconds
      • Set Dummy = (Last created unit)
      • Wait 0.00 game-time seconds
      • Unit - Add Life Drain Damage to Dummy
      • Wait 0.00 game-time seconds
      • Unit - Set level of Life Drain Damage for Dummy to 1
      • Wait 0.00 game-time seconds
      • Unit - Order Dummy to Neutral - Poison Arrows Caster
      • Wait 0.01 game-time seconds
      • Unit - Add a 8.00 second Generic expiration timer to Dummy
      • Unit - Create 1 Dummy Attack Animation for (Owner of Caster) at (Position of Caster) facing (Position of Dummy)
      • Set Dummy_4 = (Last created unit)
      • Unit - Add a 8.00 second Generic expiration timer to (Last created unit)
      • Trigger - Run Drain Visual Animation <gen> (checking conditions)
      • Trigger - Run Drain Visual Move <gen> (checking conditions)




  • Drain Visual Animation
    • Events
    • Conditions
    • Actions
      • Unit - Order Dummy_4 to Attack Dummy


  • Drain Visual Move
    • Events
    • Conditions
    • Actions
      • Unit - Move Dummy_4 instantly to (Position of Caster)
 
Last edited:
Level 5
Joined
Aug 8, 2008
Messages
113
The expiration timer interrupts everything. Orders, move, ability adding. Put it right after you create the dummy.

so I changed it to JASS see if i could get it to work better

JASS:
function UnitDeadCheck takes unit loc_unit01 returns boolean
  return GetUnitTypeId(udg_Caster)<1 or IsUnitType(loc_unit01,UNIT_TYPE_DEAD)==true
endfunction

function PeriodicEventAction takes nothing returns boolean
  local trigger this_trigger=GetTriggeringTrigger()
  local integer trigger_id=GetHandleId(this_trigger)
  call SaveInteger(udg_hashtable001,(GetHandleId(((LoadUnitHandle(udg_hashtable001,(trigger_id),(14)))))),(((LoadInteger(udg_hashtable001,(trigger_id),(33))))),(2))
  call FlushChildHashtable(udg_hashtable001,(trigger_id))
  call DisableTrigger(this_trigger)
  set this_trigger=null
  return false
endfunction

function CreatePeriodicEvent takes group heal_units,integer number,real duration returns nothing
  local trigger periodic_trigger=CreateTrigger()
  call TriggerAddCondition(periodic_trigger,Condition(function PeriodicEventAction))
  call TriggerRegisterTimerEvent(periodic_trigger,duration,true)

    call SaveInteger(udg_hashtable001,(GetHandleId(heal_units)),(number),(1))
  call SaveInteger(udg_hashtable001,(GetHandleId(periodic_trigger)),(33),(number))
  set periodic_trigger=null
endfunction

function funcdrain_setup takes nothing returns boolean
    set udg_Heal_amount[0] = 0 // was wondering if  i can set this to null
    set udg_Heal_amount[1] = 19.00
    set udg_Heal_amount[2] = 30.00
    set udg_Heal_amount[3] = 41.00
    set udg_Heal_amount[4] = 52.00
    return true
endfunction

function Spirit_Drain_Con takes nothing returns boolean
    if ( GetUnitTypeId(GetSummonedUnit()) == 'o001') then // ward lvl 1
            set udg_Unit_pres01 = 1

    elseif ( GetUnitTypeId(GetSummonedUnit()) == 'o002' ) then // ward lvl 2
    set udg_Unit_pres01 = 2
		
    elseif ( GetUnitTypeId(GetSummonedUnit()) == 'o003' ) then // ward lvl 3
    set udg_Unit_pres01 = 3

    elseif ( GetUnitTypeId(GetSummonedUnit()) == 'o000' ) then // ward lvl 4

    set udg_Unit_pres01 = 4
	else
	set udg_Unit_pres01 = 0
    endif
    return false
endfunction


function funcally_drain takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_Caster)) == true ) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false ) and (UnitDeadCheck(GetFilterUnit())==false )//finds allies of caster
endfunction

function funcEnum_drain takes nothing returns nothing
local unit loun01x
 call GroupRemoveUnitSimple( udg_Caster, udg_heal_units ) // removes caster from unit group
 call GroupRemoveUnitSimple( udg_Summon, udg_heal_units )
 call CreateUnit(ForcePickRandomPlayer(GetPlayersEnemies(GetOwningPlayer(udg_Caster))),'u000',0,0,0)
 set loun01x = GetLastCreatedUnit()
  loop
    exitwhen RectContainsUnit(GetPlayableMapRect(), udg_Dummy_4) == false
	call SetUnitState(GetEnumUnit(),UNIT_STATE_LIFE,( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + udg_Heal_amount[udg_Unit_pres01] ))
	call SetUnitState(udg_Caster ,UNIT_STATE_LIFE,( GetUnitStateSwap(UNIT_STATE_LIFE, udg_Caster ) - udg_Heal_amount[udg_Unit_pres01] ))
    if GetUnitState(udg_Caster,UNIT_STATE_LIFE)<2 then
      call UnitRemoveBuffs (udg_Caster,true,true)
      call UnitDamageTargetBJ( loun01x, udg_Caster, 1000000000.00, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNKNOWN )
    endif  //deals magical damage
	call CreatePeriodicEvent(udg_heal_units,4258,8)
  endloop
endfunction

function spirit_drain_act takes nothing returns nothing
     local integer loc_integer01=1


     local unit summon=GetSummonedUnit()
     local group heal_units = CreateGroup()
	 
    set udg_Summon = GetSummonedUnit()

	 // beginning of code for animation
	 call CreateNUnitsAtLocFacingLocBJ( 1, 'H001', GetOwningPlayer(udg_Caster), GetUnitLoc(udg_Caster), GetUnitLoc(summon) )
    set udg_Dummy_4 = GetLastCreatedUnit()
	
	
    call ConditionalTriggerExecute( gg_trg_Drain_Visual_Animation ) // conjures the animation (in another script)
    call UnitApplyTimedLifeBJ( 8.00, 'BTLF', udg_Dummy_4 ) // kills the dummy unit
  call GroupEnumUnitsInRange(udg_heal_units,GetUnitX(summon),GetUnitY(summon),775,Condition(function funcally_drain))
	 call ForGroup( udg_heal_units, function funcEnum_drain )
	 

	


   call DestroyGroup(heal_units)
   set summon=null
   set heal_units=null

endfunction

 function InitTrig_Drain_lvl_1 takes nothing returns nothing
   set gg_trg_Drain_lvl_1 = CreateTrigger(  )
   set udg_Caster = GetSummoningUnit()
   call TriggerAddCondition( gg_trg_Drain_lvl_1, Condition( function Spirit_Drain_Con ) )
   call TriggerRegisterPlayerUnitEventSimple( gg_trg_Drain_lvl_1, GetOwningPlayer(udg_Caster), EVENT_PLAYER_UNIT_SUMMON ) 
   call funcdrain_setup()
   call TriggerRegisterTimerExpireEventBJ( gg_trg_Drain_lvl_1, udg_Duration01 )
	call TriggerAddAction( gg_trg_Drain_lvl_1, function spirit_drain_act )
endfunction

but now nothing works
 
Status
Not open for further replies.
Top