| 11-17-2009, 11:32 PM | #1 |
Hey I just started experimenting with VJASS, I used to use complete JASS and thought the change would be good. I thought it would be a good idea to create a spell to practice it. So the spell I currently created is sort of like the light reflection from Legend of Zelda: Ocarina of Time. When a footman uses defend (Just temporary spell name) and is in a light source the light should reflect off in the direction he is facing. Your allies then can step in his reflected light and use defend to reflect it in a different direction. I thought about just for now creating 5 light units. If your ally steps in unit 3, units 4 and 5 would be gone because he is blocking the light and it is reflecting in new position. Example: O = light X = ally U = You U O O O O O U O O X O O O O O All I'm asking for is for some ideas on how to do it, not someone to do it for me. I will show my structs and would really appreciate any criticism and help. JASS:struct AllBeams timer t = CreateTimer() private method GetDistance takes real x, real x2, real y, real y2 returns real //Anti bj local real dx = x2 - x local real dy = y2 - y return SquareRoot(dx * dx + dy * dy) endmethod private method StartBeamTimer takes nothing returns nothing //Start the Timer for checking distance endmethod private method DestroyBeamTimer takes nothing returns nothing //Destroy the Timer for checking distance endmethod private method CheckAllBeams takes nothing returns nothing //Run through each struct and check distance using ForGroup endmethod endstruct JASS:struct LightBeam integer numBeams = 5 integer owner = -1 boolean array hidden[5] unit array beams[5] private method Init takes integer owner returns nothing //Creates beams for player local integer i = 0 set this.owner = owner loop if(i == 0) then call this.CreateBeam(5, 5, 75, 90, i) else call this.CreateBeam(GetUnitX(this.beams[i]), GetUnitY(this.beams[i]), 75, 90, i) endif set i = i + 1 exitwhen i > this.numBeams - 1 endloop endmethod private method CreateBeam takes real x, real y, real dist, real angle, int i returns nothing set x = x + dist * Cos(angle * bj_DEGTORAD) set y = y + dist * Sin(angle * bj_DEGTORAD) set this.beams[i] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'hfoo', x, y, 270) endmethod private method DestroyBeams takes nothing returns nothing //Destroys beams for player local integer i = 1 loop call KillUnit(this.beams[i]) set this.beams[i] = null set i = i + 1 exitwhen i > this.numBeams endloop endmethod private method HideBeam takes integer i returns nothing //Hide the beam call ShowUnit(this.beams[i], false) endmethod private method ShowBeam takes integer i returns nothing //Shows the beam call ShowUnit(this.beams[i], false) endmethod private method CheckDistance takes nothing returns nothing //Checks distnace of beams local unit u = GetEnumUnit() if(this.GetDistance(GetUnitX(this.beams[0]), GetUnitX(u), GetUnitY(this.beams[0]), GetUnitY(u)) < 75) then if(this.hidden[0] == false) then set this.hidden[1] = true set this.hidden[2] = true set this.hidden[3] = true set this.hidden[4] = true call this.HideBeam(1) call this.HideBeam(2) call this.HideBeam(3) call this.HideBeam(4) endif elseif(this.GetDistance(GetUnitX(this.beams[1]), GetUnitX(u), GetUnitY(this.beams[1]), GetUnitY(u)) < 75) then if(this.hidden[0] == false and this.hidden[1] == false) then set this.hidden[2] = true set this.hidden[3] = true set this.hidden[4] = true call this.HideBeam(2) call this.HideBeam(3) call this.HideBeam(4) endif elseif(this.GetDistance(GetUnitX(this.beams[2]), GetUnitX(u), GetUnitY(this.beams[2]), GetUnitY(u)) < 75) then if(this.hidden[0] == false and this.hidden[1] == false and this.hidden[2] == false) then set this.hidden[3] = true set this.hidden[4] = true call this.HideBeam(3) call this.HideBeam(4) endif elseif(this.GetDistance(GetUnitX(this.beams[3]), GetUnitX(u), GetUnitY(this.beams[3]), GetUnitY(u)) < 75) then if(this.hidden[0] == false and this.hidden[1] == false and this.hidden[2] == false and this.hidden[3] == false) then set this.hidden[4] = true call this.HideBeam(4) endif elseif(this.GetDistance(GetUnitX(this.beams[4]), GetUnitX(u), GetUnitY(this.beams[4]), GetUnitY(u)) < 75) then if(this.hidden[0] == false and this.hidden[1] == false and this.hidden[2] == false and this.hidden[3] == false and this.hidden[4] == false) then endif endif endmethod endstruct |
