HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

vJass problem, Compiler fault?

05-05-2007, 05:14 PM#1
MaD[Lion]
Im having problem trying to compile something, but it doesnt seem to work, and the compiler seems to misunderstands, but not sure.

First here is the structs that it's trying to compile:
Hidden information:
Collapse JASS:
struct BallType
    integer UnitType
    integer ItemType
    ConditionalFunction FunctionM
    ConditionalFunction FunctionC
    
    static method Create takes integer uid, integer iid, ConditionalFunction M, ConditionalFunction C returns BallType
        local BallType BT = BallType.create()
        set BT.ItemType = iid
        set BT.UnitType = uid
        set BT.FunctionM = M
        set BT.FunctionC = C
        return BT
    endmethod
    
    private method onDestroy takes nothing returns nothing
        set this.UnitType = 0
        set this.ItemType = 0
        set this.FunctionM = -1
        set this.FunctionC = -1
    endmethod
endstruct

struct Ball
    motion M
    collision C
    
    static method Create takes BallType BT, player pl, real X, real Y, real Z returns Ball
        local Ball B = Ball.create()
        local particle p
        set p = particle.Create(BT.UnitType,pl,X,Y,Z)
        call UnitAddAbility(p.Unit,'Aloc')
        set B.M = motion.Create(p)
        set B.C = collision.Create(B.M,20,30,0.8)
        set B.M.Scalar1 = 0
        set B.M.Scalar2 = Ball2Real(B)
        set B.M.Scalar3 = 0
        return B
    endmethod
    
    private method onDestroy takes nothing returns nothing
        call this.C.destroy()
        call this.M.destroy()
        set this.C = -1
        set this.M= -1
    endmethod
endstruct


and the attached image is the error i get when saving.
And yes B is desclared to be local Ball B
Attached Images
File type: jpgvjass compiler error.jpg (406.0 KB)
05-05-2007, 05:34 PM#2
Vexorian
I find it amusing that you did not post the relevant code where is the PolledWait(0.001) call?

Also, how about overriding create instead of making a Create one?
05-05-2007, 05:39 PM#3
MaD[Lion]
if you want the whole function then here it is:
Collapse JASS:
function Trig_Trow_Actions takes nothing returns nothing
    local real Acceleration = -2.5
    local real ZOffset = 80
    local real Speed = 40
    local Ball B
    local unit TrowingUnit = GetSpellAbilityUnit()
    local integer Mi = GetUnitUserData(TrowingUnit)
    local motion M2 = motion(Mi)
    local location locA = GetUnitLoc(TrowingUnit)
    local location locB = GetSpellTargetLoc()
    local real x = GetLocationX(locB) - GetLocationX(locA)
    local real y = GetLocationY(locB) - GetLocationY(locA)
    local real z = 0
    local vector V
    local player pl = GetOwningPlayer(TrowingUnit)
    local real TerrainHeight = GetLocationZ(locA)
    local real S = SquareRoot((x*x)+(y*y))*0.03
    local real t = S/Speed
    local real SpeedZ = -(0.5*Acceleration*t)/0.03
    set y = y/(SquareRoot(x*x))
    set x = x/(SquareRoot(x*x))
    set V = vector.Create(x,y,z)
    call V.SetLength(Speed)
    set x = V.x
    set y = V.y
    call V.destroy()
    call RemoveLocation(locA)
    call RemoveLocation(locB)
    set locA=null
    set locB=null
    
    call IssueImmediateOrderBJ( TrowingUnit, "stop" )
    call PauseUnit(TrowingUnit, true)
    call PolledWait(0.001)
    call SetUnitAnimation( TrowingUnit, "Attack" )
    call QueueUnitAnimationBJ( TrowingUnit, "stand" )
    call PolledWait(0.001)
    if (M2.Scalar1==0) then
        set udg_Trows[GetConvertedPlayerId(pl)] = udg_Trows[GetConvertedPlayerId(pl)]+1
        call PauseUnit(TrowingUnit, false)
        call RemoveItem( GetItemOfTypeFromUnitBJ(TrowingUnit, 'I000') )
        set B = Ball.Create(BallTypes[0],pl,GetUnitX(TrowingUnit),GetUnitY(TrowingUnit),TerrainHeight+ZOffset)
        call B.M.SetSpeed(x,y,SpeedZ)
        call B.M.SetAcseleration(0,0,Acceleration)
        set B.M.Bouncy = 0.80
        set B.M.Friction = 0.70
        call GroupAddUnit(udg_TheBalls,B.M.Particle.Unit)
    endif
    
    set pl = null
    set TrowingUnit = null
endfunction
I fixed the bug by using lowercase on struct names, seems like if i use struct name Ball instead of ball, the compiler mix around with other structs
05-05-2007, 05:47 PM#4
Vexorian
do you happen to have a collision variable called "Ball" somewhere?
05-05-2007, 07:21 PM#5
MaD[Lion]
nope i dont :)
All collision variables are called C, C1,C2... ect
05-06-2007, 03:29 AM#6
Vexorian
well, I'll need originals, either just the map script or the map.
05-06-2007, 04:51 AM#7
MaD[Lion]
well the map is my dodge ball map... Everything works in it now since i use lowercase, but try change it to Ball then it will bug.

Link to newest version submission:
http://www.wc3campaigns.net/showthre...309#post934309
05-06-2007, 01:07 PM#8
Vexorian
do you notice that map is optimized?
05-06-2007, 06:35 PM#9
MaD[Lion]
oh shit... forgot... i will send u the not optimized one
05-06-2007, 07:41 PM#10
Vexorian
You got plenty of Ball named variables, You even got local collision Ball
Because of that if you did Ball.something , even if there was an struct called Ball , it will assume you are trying to use the Ball variable, you can call static members from variables so there you go.

It is not good to have variables named the same as custom types, it would just cause conflicts I am gonna make sure to prevent them by popping out errors in those cases.
05-06-2007, 10:44 PM#11
MaD[Lion]
oh where did i have collision Ball :P