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

[JASS] Function Redeclared?

Status
Not open for further replies.
Level 8
Joined
Jul 28, 2008
Messages
211
When i try to save my map, it reports an error : Function Redeclared.
Here's my script:

JASS:
globals
      real rangeA
      unit casterA
      location locA
      real damageA
      player ownerA
      string missleA
      real angleA
endglobals

function Missle takes nothing returns nothing
    local unit caster = casterA
    local location loc = locA
    local real damage = damageA
    local real range = rangeA
    local player owner = ownerA
    local real angle = angleA
    local string missle = missleA
    call AddSpecialEffectLoc( missle, loc)
    call DamageUnits( loc, damage, range, owner, caster )
    set loc = PolarProjectionBJ(loc, 10, angle)
endfunction

function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'zxcv'
endfunction

function Trig_Wave_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit caster = GetSpellAbilityUnit()
    local location casterLoc = GetUnitLoc(caster)
    local real angle = GetUnitFacing(caster)
    local real radius = 50
    local real damage = 25
    local player owner = GetOwningPlayer(caster)
    local string missle = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
    local location place = GetUnitLoc( GetSpellAbilityUnit() )
    set casterA = caster
    set missleA = missle
    set angleA = angle
    set rangeA = radius
    set damageA = damage
    set ownerA = owner
    set locA = place
    call TimerStart( t, 0.04, true, function Missle)
    call TriggerSleepAction(3)
    call DestroyTimer(t)
    set t = null
    set caster = null
    set casterA = null
    set owner = null
    set ownerA = null
    set casterLoc = null
    set place = null
    set locA = null
endfunction

//===========================================================================
function InitTrig_Wave takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddCondition( t, Condition ( function Conditions ) )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Trig_Wave_Actions )
endfunction

I know its messy and noobish, and can be done in a much better way but i started jass not a long time ago, so im still learning.
It says that function Conditions is redeclared.

Can someone help me?
 
Level 11
Joined
Apr 6, 2008
Messages
760
scope it

like this
JASS:
scope NAME initializer init //(initializer is better then init_trig)

globals
      private real rangeA
      private  unit casterA
      private location locA
      private real damageA
      private player ownerA
      private string missleA
      private real angleA
endglobals

private function Missle takes nothing returns nothing
    local unit caster = casterA
    local location loc = locA
    local real damage = damageA
    local real range = rangeA
    local player owner = ownerA
    local real angle = angleA
    local string missle = missleA
    call AddSpecialEffectLoc( missle, loc)
    call DamageUnits( loc, damage, range, owner, caster )
    set loc = PolarProjectionBJ(loc, 10, angle)
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'zxcv'
endfunction

private function Trig_Wave_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit caster = GetSpellAbilityUnit()
    local location casterLoc = GetUnitLoc(caster)
    local real angle = GetUnitFacing(caster)
    local real radius = 50
    local real damage = 25
    local player owner = GetOwningPlayer(caster)
    local string missle = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
    local location place = GetUnitLoc( GetSpellAbilityUnit() )
    set casterA = caster
    set missleA = missle
    set angleA = angle
    set rangeA = radius
    set damageA = damage
    set ownerA = owner
    set locA = place
    call TimerStart( t, 0.04, true, function Missle)
    call TriggerSleepAction(3)
call DestroyTimer(t)
    set t = null
    set caster = null
    set casterA = null
    set owner = null
    set ownerA = null
    set casterLoc = null
    set place = null
    set locA = null
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger t = CreateTrigger( )
    call TriggerAddCondition( t, Condition ( function Conditions ) )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Trig_Wave_Actions )
endfunction

endscope

Using private members inside a scope/library will add the scopes/librarys name infront of the name of the member

eg.

private real REAL will be real _s_"SCOPE_NAME"_REAL and public real REAL will be real "SCOPE_NAME"_REAL
this means u dont have too worry about names outside the scope/library

also why dont you use structs? it can make any spell MUI easy
 
Status
Not open for further replies.
Top