• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] System doesnt work

Status
Not open for further replies.
For those who read this
I have a problem:
[trigger=]Timed Lightning Init
Events
Map initialization
Conditions
Actions
Custom script: set udg_TL_Hash = InitHashtable()
-------- ----------------------------------- --------
-------- Lightning Codes --------
-------- ----------------------------------- --------
-------- Chain Lightning - Primary --------
Set TL_LightningType[1] = CLPB
-------- Chain Lightning - Secondary --------
Set TL_LightningType[2] = CLSB
-------- Healing Wave - Primary --------
Set TL_LightningType[3] = HWPB
-------- Healing Wave - Secondary --------
Set TL_LightningType[4] = HWSB
-------- Finger of Death --------
Set TL_LightningType[5] = AFOD
-------- Magic Leash/Aerial Shackles --------
Set TL_LightningType[6] = LEAS
-------- Drain Mana --------
Set TL_LightningType[7] = DRAM
-------- Drain Life --------
Set TL_LightningType[8] = DRAL
-------- Forked Lightning --------
Set TL_LightningType[9] = FORK
-------- Mana Burn --------
Set TL_LightningType[10] = MBUR
-------- Chimera Attack --------
Set TL_LightningType[11] = CHIM
-------- Mana Flare --------
Set TL_LightningType[12] = MFPB
-------- Spirit Link --------
Set TL_LightningType[13] = SPLK
-------- ----------------------------------- --------
-------- Configuration here --------
-------- ----------------------------------- --------
Custom script: set udg_TL_Abil = 'AHtb'
Set TL_LCode = TL_LightningType[9]
Set TL_MaxTime = 5.00
-------- ----------------------------------- --------
-------- Color from 0.00 to 1.00 only --------
-------- ----------------------------------- --------
Set TL_Red = 1.00
Set TL_Green = 0.00
Set TL_Blue = 1.00
Trigger - Run Timed Lightning Save <gen> (ignoring conditions)
-------- ----------------------------------- --------
-------- End of Configuration --------
-------- ----------------------------------- --------
[/trigger]
[trigger=]Timed Lightning Save
Events
Conditions
Actions
Hashtable - Save TL_LCode as (Key L Model) of TL_Abil in TL_Hash
Hashtable - Save TL_MaxTime as (Key Max) of TL_Abil in TL_Hash
Hashtable - Save TL_Blue as (Key Blue) of TL_Abil in TL_Hash
Hashtable - Save TL_Green as (Key Green) of TL_Abil in TL_Hash
Hashtable - Save TL_Red as (Key Red) of TL_Abil in TL_Hash
[/trigger]
[trigger=]Timed Lightning Setup
Events
Map initialization
Conditions
Actions
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function destroys any kind of lightning,of course,depending on time or if a unit is dead --------
-------- call DestroyTimedLightning() as a key to destroy it. --------
-------- ----------------------------------- --------
Custom script: function DestroyTimedLightning takes nothing returns nothing
Lightning - Destroy TL_Lightning
Hashtable - Clear all child hashtables of child TL_Key in TL_Hash
Unit Group - Remove TL_TempSource from TL_LoopGroup
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function checks if the time is ending --------
-------- ----------------------------------- --------
Custom script: function TimeIsExpiring takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TL_CurrentTime Greater than TL_TempMaxTime
Then - Actions
Custom script: call DestroyTimedLightning()
Else - Actions
Custom script: return false
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function checks if the source unit is alive --------
-------- ----------------------------------- --------
Custom script: function SourceUnitIsAlive takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(TL_TempSource is alive) Equal to True
Then - Actions
Custom script: return false
Else - Actions
Custom script: call DestroyTimedLightning()
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function checks if the target unit is alive --------
-------- ----------------------------------- --------
Custom script: function TargetUnitIsAlive takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(TL_TempTarget is alive) Equal to True
Then - Actions
Custom script: return false
Else - Actions
Custom script: call DestroyTimedLightning()
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function creates the timed lightning --------
-------- Use call CreateTimedLightning --------
-------- ----------------------------------- --------
Custom script: function CreateTimedLightning takes nothing returns nothing
-------- ----------------------------------- --------
-------- Coordinates X,Y,Z --------
-------- ----------------------------------- --------
-------- ----------------------------------- --------
-------- Checks if a source unit is a location(via boolean) --------
-------- ----------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TL_IsSourceLocation Equal to True
Then - Actions
Custom script: set udg_TL_SourceZ = GetUnitFlyHeight(udg_TL_Source)
Else - Actions
Custom script: set udg_TL_SourceZ = GetUnitFlyHeight(udg_TL_Source) + 75
-------- ----------------------------------- --------
-------- Checks if a target unit is a location(via boolean) --------
-------- ----------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TL_IsTargetLocation Equal to True
Then - Actions
Custom script: set udg_TL_TargetZ = GetUnitFlyHeight(udg_TL_Target)
Else - Actions
Custom script: set udg_TL_TargetZ = GetUnitFlyHeight(udg_TL_Target) + 75
-------- ----------------------------------- --------
-------- X,Y of source and target --------
-------- ----------------------------------- --------
Custom script: set udg_TL_SourceX = GetUnitX(udg_TL_Source)
Custom script: set udg_TL_SourceY = GetUnitX(udg_TL_Source)
Custom script: set udg_TL_TargetX = GetUnitX(udg_TL_Target)
Custom script: set udg_TL_TargetY = GetUnitX(udg_TL_Target)
-------- ----------------------------------- --------
-------- Creating Lightning --------
-------- ----------------------------------- --------
Custom script: set udg_TL_Lightning = AddLightningEx(udg_TL_LCode,true,udg_TL_SourceX,udg_TL_SourceY,udg_TL_SourceZ,udg_TL_TargetX,udg_TL_TargetY,udg_TL_TargetZ)
-------- ----------------------------------- --------
-------- Colors --------
-------- ----------------------------------- --------
Lightning - Change color of TL_Lightning to (TL_Red TL_Green TL_Blue) with 1.00 alpha
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function starts the loop of the timed lightning and saves all variables --------
-------- ----------------------------------- --------
Custom script: function StartTimedLightning takes nothing returns nothing
-------- ----------------------------------- --------
-------- Save --------
-------- ----------------------------------- --------
Hashtable - Save Handle OfTL_Lightning as (Key Lightning) of TL_CastKey in TL_Hash
Hashtable - Save TL_MaxTime as (Key TempMaxTime) of TL_CastKey in TL_Hash
Hashtable - Save TL_StartTime as (Key Current) of TL_CastKey in TL_Hash
Hashtable - Save Handle OfTL_Target as (Key Target) of TL_CastKey in TL_Hash
Hashtable - Save Handle OfTL_FakeSource as (Key FakeSource) of TL_CastKey in TL_Hash
Hashtable - Save TL_SourceZ as (Key SourceHeight) of TL_CastKey in TL_Hash
Hashtable - Save TL_TargetZ as (Key TargetHeight) of TL_CastKey in TL_Hash
Unit Group - Add TL_Source to TL_LoopGroup
Trigger - Turn on Timed Lightning Loop <gen>
Custom script: endfunction
-------- ----------------------------------- --------
-------- This function moves lightning periodicallly --------
-------- ----------------------------------- --------
Custom script: function MoveTimedLightning takes nothing returns nothing
-------- ----------------------------------- --------
-------- Check if time is not ending --------
-------- ----------------------------------- --------
Custom script: if TimeIsExpiring() then
Custom script: else
Custom script: if SourceUnitIsAlive() then
Custom script: if TargetUnitIsAlive() then
-------- ----------------------------------- --------
-------- Moving unit to the original caster(if not location) --------
-------- ----------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TL_TempFakeSource Not equal to No unit
Then - Actions
Set TL_Point = (Position of TL_TempFakeSource)
Unit - Move TL_TempSource instantly to TL_Point
Custom script: call RemoveLocation(udg_TL_Point)
Else - Actions
-------- ----------------------------------- --------
-------- Coordinates --------
-------- ----------------------------------- --------
Custom script: set udg_TL_TempSourceX = GetUnitX(udg_TL_TempSource)
Custom script: set udg_TL_TempSourceY = GetUnitY(udg_TL_TempSource)
Custom script: set udg_TL_TempTargetX = GetUnitX(udg_TL_TempTarget)
Custom script: set udg_TL_TempTargetY = GetUnitY(udg_TL_TempTarget)
Set TL_TempSourceZ = (Load (Key SourceHeight) of TL_Key from TL_Hash)
Set TL_TempTargetZ = (Load (Key TargetHeight) of TL_Key from TL_Hash)
-------- ----------------------------------- --------
-------- Move Lightning --------
-------- ----------------------------------- --------
Set TL_TempLightning = (Load (Key Lightning) of TL_Key in TL_Hash)
Custom script: call MoveLightningEx(udg_TL_TempLightning,true,udg_TL_TempSourceX,udg_TL_TempSourceY,udg_TL_TempSourceZ,udg_TL_TempTargetX,udg_TL_TempTargetY,udg_TL_TempTargetZ)
-------- ----------------------------------- --------
-------- Save --------
-------- ----------------------------------- --------
Hashtable - Save (TL_CurrentTime + 0.03) as (Key Current) of TL_Key in TL_Hash
Custom script: endif
Custom script: endif
Custom script: endif
[/trigger]
[trigger=]Timed Lightning Loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(TL_LoopGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in TL_LoopGroup and do (Actions)
Loop - Actions
Set TL_TempSource = (Picked unit)
Custom script: set udg_TL_Key = GetHandleId(udg_TL_TempSource)
-------- ----------------------------------- --------
-------- Load --------
-------- ----------------------------------- --------
Set TL_TempTarget = (Load (Key Target) of TL_Key in TL_Hash)
Set TL_TempFakeSource = (Load (Key FakeSource) of TL_Key in TL_Hash)
Set TL_CurrentTime = (Load (Key Current) of TL_Key from TL_Hash)
Set TL_TempMaxTime = (Load (Key TempMaxTime) of TL_Key from TL_Hash)
Custom script: call ExecuteFunc("MoveTimedLightning")
Else - Actions
Trigger - Turn on (This trigger)
[/trigger]
[trigger=]TL Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Storm Bolt
Actions
Set TL_Caster = (Triggering unit)
Set TL_Point = (Position of TL_Caster)
Set TL_Owner = (Triggering player)
Custom script: set udg_TL_Abil = GetSpellAbilityId()
Set TL_Target = (Target unit of ability being cast)
-------- ------------------------------------ --------
-------- Creating Source --------
-------- ------------------------------------ --------
Unit - Create 1 Dummy for TL_Owner at TL_Point facing Default building facing degrees
Set TL_Source = (Last created unit)
Custom script: set udg_TL_CastKey = GetHandleId(udg_TL_Source)
Set TL_IsSourceLocation = True
Set TL_IsTargetLocation = False
Custom script: call ExecuteFunc("CreateTimedLightning")
Set TL_FakeSource = TL_Caster
Set TL_StartTime = 0.00
Set TL_MaxTime = (Load (Key Max) of TL_Abil from TL_Hash)
Set TL_LCode = (Load (Key L Model) of TL_Abil from TL_Hash)
Set TL_Blue = (Load (Key Blue) of TL_Abil from TL_Hash)
Set TL_Green = (Load (Key Green) of TL_Abil from TL_Hash)
Set TL_Red = (Load (Key Red) of TL_Abil from TL_Hash)
Custom script: call ExecuteFunc("StartTimedLightning")
Custom script: call RemoveLocation(udg_TL_Point)
[/trigger]

My problem:
The Loop doesnt run,the other functions run as well.

View attachment Timed Lightning v1.0.w3x
 
Last edited:
As I thought, I got some compilation error when I try to save your map :
  • Custom script: function TargetUnitIsAlive takes nothing returns boolean
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (TL_TempTarget is alive) Equal to True
    • Then - Actions
      • Custom script: return false
    • Else - Actions
      • Custom script: call DestroyTimedLightning()
  • Custom script: endfunction
With this and the relatives, the last line of the function is not a return and hence is not correct. How you can test it if it has syntax errors?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
As I thought, I got some compilation error when I try to save your map :
  • Custom script: function TargetUnitIsAlive takes nothing returns boolean
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (TL_TempTarget is alive) Equal to True
    • Then - Actions
      • Custom script: return false
    • Else - Actions
      • Custom script: call DestroyTimedLightning()
  • Custom script: endfunction
With this and the relatives, the last line of the function is not a return and hence is not correct. How you can test it if it has syntax errors?

just a question, since i guess allways must be return a boolean, what will be the returned boolean value if your if isn't true?

not better this way?
  • Custom script: function TargetUnitIsAlive takes nothing returns boolean
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (TL_TempTarget is alive) Equal to False
    • Then - Actions
      • Custom script: call DestroyTimedLightning()
    • Else - Actions
  • Custom script: return GetWidgetLife(udg_TempTarget) > 0.4
  • Custom script: endfunction
 
Status
Not open for further replies.
Top