• 🏆 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!

whats wrong here?

Status
Not open for further replies.
Level 9
Joined
Aug 21, 2008
Messages
533
:con:I begann to make a systemw hich converts attacks from ranged units to missles are like the fireball from D2. So you can have you ranged unit behind your meele units and easily evade long ranged attacks.After i made some basic things i tried to test it but it the doesnt start like i had a syntax error,alltought the jasshelper did not find any


JASS:
function Trig_the_system_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_RANGED_ATTACKER) == true ) ) then
        return false
    endif
    return true
endfunction

function misslespeed takes unit u returns real
local real r
if  ( GetUnitTypeId(u) == 'hrif') then
    set r = 400.00
elseif ( GetUnitTypeId(u) == 'hsor') then
    set r = 600.00
endif
    return r
endfunction

function Trig_the_system_Actions takes nothing returns nothing
local unit uA = GetEventDamageSource()
local unit uD = GetTriggerUnit()
local location  lA = GetUnitLoc(uA)
local location lD = GetUnitLoc(uD)
local real d = GetEventDamage()
local real speed= misslespeed(uA)
endfunction
function Trig_addaction_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_the_system, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
endfunction

//===========================================================================
function InitTrig_the_system takes nothing returns nothing
    set gg_trg_the_system = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_the_system, Condition( function Trig_the_system_Conditions ) )
    call TriggerAddAction( gg_trg_the_system, function Trig_the_system_Actions )
    set gg_trg_addaction = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_addaction, GetPlayableMapRect() )
    call TriggerAddAction( gg_trg_addaction, function Trig_addaction_Actions )
endfunction

pls help me
 
Level 5
Joined
Dec 18, 2007
Messages
205
try making a local variable for the 2nd trigger:

JASS:
function Trig_addaction_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_the_system, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
endfunction

//===========================================================================
function InitTrig_the_system takes nothing returns nothing
    set gg_trg_the_system = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_the_system, Condition( function Trig_the_system_Conditions ) )
    call TriggerAddAction( gg_trg_the_system, function Trig_the_system_Actions )
    set gg_trg_addaction = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_addaction, GetPlayableMapRect() )
    call TriggerAddAction( gg_trg_addaction, function Trig_addaction_Actions )
endfunction

becomes

JASS:
function Trig_AddAction_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_the_system, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
endfunction

//===========================================================================
function InitTrig_the_system takes nothing returns nothing
    local trigger AddAction = CreateTrigger()
    set gg_trg_the_system = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_the_system, Condition( function Trig_the_system_Conditions ) )
    call TriggerAddAction( gg_trg_the_system, function Trig_the_system_Actions )
    call TriggerRegisterEnterRectSimple( AddAction, GetPlayableMapRect() )
    call TriggerAddAction( AddAction, function Trig_AddAction_Actions )
    set AddAction = null
endfunction

i did not test it, so tell me if you get any further errors.

greetings
 
Last edited:
Level 5
Joined
Dec 18, 2007
Messages
205
yeah, thats because the variable isnt declared as marcelo said.

those gg_trg_XYZ variables are just declared in the trigger editor if u create a trigger for them.
so a trigger named "the_system" will automatically create the global trigger "gg_trg_the_system" while "gg_trg_addaction" cannot exist because the trigger "addaction" does neither exist in the editor nor in a global declaration block.

greetings
 
Status
Not open for further replies.
Top