| 02-23-2008, 10:15 PM | #1 |
I've been working on this code for some time and I have no idea whats wrong. Its treating structs like they are normal variables and says something like "v cannot have a ." Please help! TY in advance, will rep. JASS:library VectorLib globals Vector GRAVITYVECTOR endglobals struct Vector real x //This detirmines where the vector 'is' real y //This detirmines where the vector 'is' real z //This detirmines where the vector 'is' real Fx //These values are counterintuitive from what you might think real Fy //These are based on planes, rather than force, a negative is backwards, thats why there is no directional value real Fz //This way, it requires less math and is easier and less taxing if many events are happening at once //the force values should be speed/sec. method SetX takes real x returns nothing set this.x = x endmethod method SetY takes real y returns nothing set this.y = y endmethod method SetZ takes real z returns nothing set this.z = z endmethod method SetFx takes real m returns nothing set this.Fx = m endmethod method SetFy takes real m returns nothing set this.Fy = m endmethod method SetFz takes real m returns nothing set this.Fz = m endmethod static method create takes real X, real Y, real Z, real FX, real FY, real FZ returns Vector local Vector Vec = Vector.allocate() set Vec.x = X set Vec.y = Y set Vec.z = Z set Vec.Fz = FZ set Vec.Fy = FY set Vec.Fx = FX return Vec endmethod endstruct function VectorNull takes Vector A returns Vector local Vector v1 = Vector.create(A.x,A.y,A.z,0,0,0) return v1 endfunction function VectorNormal takes Vector A returns Vector local Vector v2 = Vector.create(A.x,A.y,A.z,1,1,1) return v2 endfunction function VectorAdd takes Vector A, Vector B returns Vector local Vector v3 = Vector.create(0,0,0,0,0,0) set v3.Fx = A.Fx + B.Fx set v3.Fy = A.Fy + B.Fy set v3.Fz = A.Fz + B.Fz return v3 endfunction function VectorSubtract takes Vector A, Vector B returns Vector local Vector v4 = Vector.create(0,0,0,0,0,0) set v4.Fx = A.Fx - B.Fx set v4.Fy = A.Fy - B.Fy set v4.Fz = A.Fz - B.Fz return v4 endfunction function VectorMultiply takes Vector A, Vector B returns Vector local Vector v5 = Vector.create(0,0,0,0,0,0) set v5.Fx = A.Fx * B.Fx set v5.Fy = A.Fy * B.Fy set v5.Fz = A.Fz * B.Fz return v5 endfunction function VectorDivide takes Vector A, Vector B returns Vector local Vector v6 = Vector.create(0,0,0,0,0,0) set v6.Fx = A.Fx / B.Fx set v6.Fy = A.Fy / B.Fy set v6.Fz = A.Fz / B.Fz return v6 endfunction function GRAVITYINIT takes nothing returns nothing //MUST BE CALLED ON INITIALIZATION, I CAN'T STRESS THIS ENOUGH. set GRAVITYVECTOR = Vector.create(0,0,0,0,0,-9.8) set GRAVITYVECTOR.x = 0 set GRAVITYVECTOR.y = 0 set GRAVITYVECTOR.z = 0 set GRAVITYVECTOR.Fx = 0 set GRAVITYVECTOR.Fy = 0 set GRAVITYVECTOR.Fz = -9.8 endfunction endlibrary struct Projectile 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 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 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 Ve = Vector.create(x,y,z,fx,fy,fz) set Ve.x = x set Ve.y = y set Ve.z = z set Ve.Fx = Fx set Ve.Fy = Fy set 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. set Ve.x = Ve.x + Ve.Zx * this.TimeStep set Ve.y = Ve.y + Ve.Zy * this.TimeStep if (this.FollowsTerrainHeight == TRUE) then call VectorAdd(v,GRAVITYVECTOR) set Ve.z = Ve.Fz + Ve.z else // ((z-grav*X)*TS) call VectorAdd(v,GRAVITYVECTOR) // set Ve.Fz = (TERRAINHEIGHT-this.BaseTerrainLevel) set Ve.z = Ve.Fz + Ve.z endif endmethod method MoveToXYZ takes nothing returns nothing call SetUnitPosition(this.ProjDummy,Ve.x,Ve.y) call UnitAddAbility(u,'Amrf') call SetUnitFlyHeight(u,v.z,0) call UnitRemoveAbility(u,'Amrf') endmethod method SmartMove takes nothing returns nothing // this pretty much combines MovetoXYZ and SetNewXYZ set Ve.x = Ve.x + Ve.Zx * this.TimeStep set Ve.y = Ve.y + Ve.Zy * this.TimeStep if (this.FollowsTerrainHeight == TRUE) then call VectorAdd(v,GRAVITYVECTOR) set Ve.z = Ve.Fz + Ve.z else // ((z-grav*X)*TS) call VectorAdd(v,GRAVITYVECTOR) // set Ve.Fz = (TERRAINHEIGHT-this.BaseTerrainLevel) set Ve.z = Ve.Fz + Ve.z endif call SetUnitPosition( this.ProjDummy , v.x , v.y ) call UnitAddAbility( u , 'Amrf' ) call SetUnitFlyHeight( u , v.z , 0 ) call UnitRemoveAbility( u , 'Amrf' ) endmethod endstruct |
| 02-23-2008, 10:23 PM | #2 |
where is v declared anyway? |
| 02-23-2008, 10:29 PM | #3 |
In struct projectile Vector Ve=0 |
| 02-23-2008, 10:32 PM | #4 | |
That's probably the problem, next time try including the line with the syntax error. Quote:
The compiler can't guess that when you say 'v' you actually mean 'Ve' . |
| 02-23-2008, 10:35 PM | #5 |
Code:
Line 144: Ve is not of a type that allows . syntax set Ve.x = x Previous line: set Ve = Vector.create(x,y,z,fx,fy,fz) |
| 02-23-2008, 10:38 PM | #6 |
AH, you meant set this.Ve.x= x
and set this.Ve = Vector.creat.... |
| 02-23-2008, 10:40 PM | #7 |
oh lol, thanks, weeks of torment because i forgot basic syntax... lol! I always forget basic syntax. I checked, it was the problem, thanks Vex! +rep yep, finally cleared VJASS parsing, besides a few missing variables and incomplete functions it's all working now! |
