HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

More VJASS problems :(

03-05-2008, 11:27 PM#1
TheSecretArts
When I cast the spell 'A001' (Specialty Shockwave), It says the variable CascadingCatacylsm (i spelled it wrong on purpose) is undeclared. I'm sure that it is declared... help is appreciated.
I know there are some bj's, bear with me.
Map Script:
Collapse JASS:
globals
    Projectile CascadingCatacylsm
endglobals
struct Projectile
    real TimeLife
    private real BaseTerrainLevel // This is used when FollowsTerrainHeight is FALSE, this stands as the base terrain level
//    real Cd //This is the drag coefficient, this effects how air drag effects the projectile
//    real RA //This is the reference area, this is used in calculating drag
    real ObjectCollisionSize //Say the unit has a proximity effect, this would allow control over that proximity size
//    real Mass // To make a projectile that doesnt fall, set mass to zero
    location TargetPoint
    unit Target //More or less for homing projectiles
    unit ProjDummy
    real Damage
    real Size
    real TimeStep
//    boolean EffectedByWind //At the moment this does not effect the unit, but when wind is implemented, spells that create wind or natural wind will not effect the projectile, for most objects this should probably be used.
//    boolean HitsCliffs //this could be toggled false so that it floats through cliffs
    boolean HitsUnits
//    boolean ExplodesOnGround                                                         
//    boolean FollowsTerrainHeight //This is a big one, this determines wether the unit's z is based off terrain height, or a base level (the base level is intially based of terrain height, but then becomes independed of terrain height)
//    boolean HitsCaster //If the spell rebounds back by some means, can it hit the caster
//    boolean HitsAllies
//    string CasterCollision //Function name to run on caster collision
//    string AllyCollision //Function name to run on allied collision
    string UnitCollision //Function name to run on unit collision, will check if you hit allies and if this unit can hit allies.
//    string GroundCollision //Function name to run on Ground collision
//    string CliffCollision //Function name to run on cliff collision
    Vector Ve=0
    method Initialization takes real x, real y, real z, real Fx, real Fy, real Fz returns nothing
        set this.Ve = Vector.create(x,y,z,Fx,Fy,Fz)
        set this.Ve.x = x
        set this.Ve.y = y
        set this.Ve.z = z
        set this.Ve.Fx = Fx
        set this.Ve.Fy = Fy
        set this.Ve.Fz = Fz
    endmethod 
    method DetectCliffCollision takes nothing returns nothing
        // Placeholder
    endmethod
    method DetectUnitCollision takes nothing returns nothing
        // Placeholder 
    endmethod
    method SetFacingAngleToTargetedPoint takes nothing returns nothing
        call SetUnitFacing(this.ProjDummy,3.14159/180.0 * Atan2(GetLocationY(this.TargetPoint) - GetLocationY(GetUnitLoc(this.ProjDummy)), GetLocationX(this.TargetPoint) - GetLocationX(GetUnitLoc(this.ProjDummy))))
    endmethod
    method SetFacingAngleToTargetedUnit takes nothing returns nothing // This allows a 'homing' projectile
        call SetUnitFacing(this.ProjDummy,3.14159/180.0 * Atan2(GetLocationY(GetUnitLoc(this.Target)) - GetLocationY(GetUnitLoc(this.ProjDummy)), GetLocationX(GetUnitLoc(this.Target)) - GetLocationX(GetUnitLoc(this.ProjDummy))))
    endmethod
//    method GetGravForce takes nothing returns real
//        return (this.Mass * GLOBALMASS) //Placeholder for actual grav formula
//    endmethod
    method SetNewXYZ takes nothing returns nothing //Doesnt move unit, just sets the values to prepare movement.  Has a use for debugging
        set this.Ve.x = this.Ve.x + (this.Ve.Fx * this.TimeStep)
        set this.Ve.y = this.Ve.y + (this.Ve.Fy * this.TimeStep)
  //      if (this.FollowsTerrainHeight == TRUE) then
            call VectorAdd(this.Ve,GRAVITYVECTOR)
   //         set this.Ve.z = this.Ve.Fz + this.Ve.z
  //      else
            // ((z-grav*X)*TS)
 //           call VectorAdd(v,GRAVITYVECTOR)
//            set this.Ve.Fz = (TERRAINHEIGHT-this.BaseTerrainLevel)
            set this.Ve.z = this.Ve.Fz + this.Ve.z
 
  //     endif
    endmethod
    method MoveToXYZ takes nothing returns nothing
        call SetUnitPosition(this.ProjDummy,this.Ve.x,this.Ve.y)
        call UnitAddAbility(this.ProjDummy,'Amrf')
        call SetUnitFlyHeight(this.ProjDummy,this.Ve.z,0)
        call UnitRemoveAbility(this.ProjDummy,'Amrf')
    endmethod
    method SmartMove takes nothing returns nothing // this pretty much combines MovetoXYZ and SetNewXYZ
        set this.Ve.x = this.Ve.x + (this.Ve.Fx * this.TimeStep)
        set this.Ve.y = this.Ve.y + (this.Ve.Fy * this.TimeStep)
 //       if (this.FollowsTerrainHeight == TRUE) then
        call VectorAdd(this.Ve,GRAVITYVECTOR)
 //       set this.Ve.z = this.Ve.Fz + this.Ve.z
 //       else
            // ((z-grav*X)*TS)
 //           call VectorAdd(this.Ve,GRAVITYVECTOR)
//            set this.Ve.Fz = (TERRAINHEIGHT-this.BaseTerrainLevel)
            set this.Ve.z = this.Ve.Fz + this.Ve.z
  //      endif
        call SetUnitPosition( this.ProjDummy , this.Ve.x , this.Ve.y )
        call UnitAddAbility( this.ProjDummy , 'Amrf' )
        call SetUnitFlyHeight( this.ProjDummy , this.Ve.z , 0 )
        call UnitRemoveAbility( this.ProjDummy , 'Amrf' )
    endmethod      
    method DetectCollision takes nothing returns nothing  //gets called to check if it is colliding with anything.
        local boolean TFBool = this.CheckCollision()
        if (TFBool==TRUE) then
            call ExecuteFunc(this.UnitCollision)
        endif
    endmethod
    method CheckCollision takes nothing returns boolean
        local group g = GetUnitsInRangeOfLocAll(this.ObjectCollisionSize,GetUnitLoc(this.ProjDummy))
        if (CountUnitsInGroup(g)>0) then
            return TRUE
        else
            return FALSE
        endif
    endmethod
endstruct
endlibrary
OnCast Trigger:
Collapse JASS:
function Trig_OnCast_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction
function CalculateForceX takes unit u returns real
    local location p = PolarProjectionBJ(GetUnitLoc(u), 500.00, GetUnitFacing(u))
    local real XMX //X minus X to find total X change
    local real XC //X over (distance/speed) 
    set XMX = GetLocationX(p)-GetLocationX(GetUnitLoc(u))
    set XC = (XMX/5)
    return XC
endfunction
function CalculateForceY takes unit u returns real
    local location p = PolarProjectionBJ(GetUnitLoc(u), 500.00, GetUnitFacing(u))
    local real YMY //Y minus Y
    local real YC //Y over (distance/speed)
    set YMY = GetLocationY(p)-GetLocationY(GetUnitLoc(u))
    set YC = (YMY/5)
    return YC
endfunction
function Trig_OnCast_Actions takes nothing returns nothing
    local unit U 
    call CreateNUnitsAtLocFacingLocBJ( 1, 'u000', Player(0), GetUnitLoc(GetTriggerUnit()), OffsetLocation(GetSpellTargetLoc(), 0, 0) )
    set U = GetLastCreatedUnit()
    call CascadingCatacylsm.create()
    call CascadingCatacylsm.Initialization(GetUnitX(U),GetUnitY(U),200,CalculateForceX(U),CalculateForceY(U),0)
    set CascadingCatacylsm.ObjectCollisionSize =50
    set CascadingCatacylsm.Size = .5
    set CascadingCatacylsm.Damage = 50
    set CascadingCatacylsm.ProjDummy = U
    set CascadingCatacylsm.TimeStep = .1
    set CascadingCatacylsm.HitsUnits = TRUE
    set CascadingCatacylsm.UnitCollision = "OnUnitCollision"
    set CascadingCatacylsm.TargetPoint = PolarProjectionBJ(GetUnitLoc(U), 500.00, GetUnitFacing(U))
    call StartTimerBJ( udg_CascCataTimer, false, CascadingCatacylsm.TimeLife )
endfunction

//===========================================================================
function InitTrig_OnCast takes nothing returns nothing
    set gg_trg_OnCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_OnCast, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddCondition( gg_trg_OnCast, Condition( function Trig_OnCast_Conditions ) )
    call TriggerAddAction( gg_trg_OnCast, function Trig_OnCast_Actions )
endfunction

03-06-2008, 01:33 AM#2
Joker
There no need to declare a struct into a global unless you want a struct array (which doesn't really serve a purpose anymore, i think)

Try changing all the CascadingCatacylsm to Projectile.
03-06-2008, 01:45 AM#3
TaintedReality
You never initialized the CascadingCatacylsm variable.
03-06-2008, 09:41 AM#4
Anitarf
create is a static method. The proper syntax would be set CascadingCatacylsm = Projectile.create() and not call CascadingCatacylsm.create()
03-06-2008, 08:38 PM#5
TheSecretArts
oh ok, thanks. I spaced there...