| 09-13-2008, 03:54 PM | #1 |
Ok guys, This is a spell in the spell request thread. The goal was to make this without Pyrogasm's help, so if Pyro sees this thread, please try not to help ! xD I have a problem with a formula, the objective is to create any number of units in a direction perpendicular to the caster, thus forming a wall (think it like a T). Can some one help me find the formula, it is the only thing that's left =S JASS://Create the wall, I can't find a formula to complete the wall, I can //only create 1 unit, If I create more, they will mess up everything. //Can some one help me find a formula ? set i = 0 set wallPos = 0 loop exitwhen(i == WallNumber(data.level)) set wall = CreateUnit(owner, WallId(data.level), data.spellX + wallPos * Cos(angle), data.spellY + 75 * Sin(angle), angle) call GroupAddUnit(data.walls, wall) set wallPos = wallPos - WallSize(data.level) set i = i + 1 endloop |
| 09-13-2008, 04:17 PM | #2 |
I was actually making something like this a few days ago... JASS:
globals
private constant integer Dummy_Id = 'h000'
private constant integer MaxSegNum = 25
endglobals
struct WallStruct
integer segnum
unit array dummys [MaxSegNum]
effect array effects [MaxSegNum]
real array x [MaxSegNum]
real array y [MaxSegNum]
endstruct
//...
public function CreateWall takes player p, real x, real y, real rads, integer segments, real width, string fx, string fx2 returns integer
local real a = rads + 3.14159/2
local real tx = x - width/2 * Cos( a )
local real ty = y - width/2 * Sin( a )
local WallStruct WS = WallStruct.create()
local integer i = 1
set WS.segnum = IMaxBJ( segments, MaxSegNum )
loop
set WS.dummys[i] = CreateUnit( p, Dummy_Id, tx, ty, a * 180 / 3.14159 )
set WS.effects[i] = AddSpecialEffectTarget( fx, WS.dummys[i], "origin" )
call DestroyEffect( AddSpecialEffect( fx2, tx, ty ) )
set WS.x[i] = tx
set WS.y[i] = ty
set tx = tx + width/WS.segnum * Cos( a )
set ty = ty + width/WS.segnum * Sin( a )
set i = i + 1
exitwhen i > WS.segnum
endloop
return WS
endfunction |
| 09-13-2008, 05:49 PM | #3 |
Thx for help, but it still doesn't work ... can you help me ?? What am I doing wrong ? JASS://setting variables set data.caster = caster set data.level = level set data.catcher = NewTimer() set data.spellX = spellX set data.spellY = spellY set data.walls = CreateGroup() set angle = (180.0 / bj_PI) * Atan2(data.spellY - GetUnitY(data.caster), data.spellX - GetUnitX(data.caster)) set a = angle + bj_PI / 2 set owner = GetOwningPlayer(data.caster) //Create the wall, I can't find a formula to complete the wall, I can //only create 1 unit, If I create more, they will mess up everything. //Can some one help me find a formula ? set i = 0 set tx = spellX - WallSize(data.level)/2 * Cos(a) set ty = spellY - WallSize(data.level)/2 * Sin(a) loop exitwhen(i == WallNumber(data.level)) set wall = CreateUnit(owner, WallId(data.level), tx, ty, a* bj_RADTODEG) call GroupAddUnit(data.walls, wall) set tx = tx + WallSize(data.level)/WallNumber(data.level) * Cos(a) set ty = ty + WallSize(data.level)/WallNumber(data.level) * Sin(a) set i = i + 1 endloop |
| 09-14-2008, 02:24 AM | #4 |
get the number of units in that comprise the wall. offset the 1st unit to any end from the center of the wall (where it normal to the caster) then offset the differential between each unit in the wall to the other end of the wall. x = numb of units >>>>>>>>>>>>>>> <<<<<<<<<<<<<<<< differential offset between unit elements ' ' start - - - - - - - end (or: end - - - - - - - - start) ...............l ...............l <---normal line ...........caster |
| 09-14-2008, 03:31 AM | #5 |
Mine used radians.. Anyway, try this, you messed up the initial angle calculation on yours; JASS://setting variables set data.caster = caster set data.level = level set data.catcher = NewTimer() set data.spellX = spellX set data.spellY = spellY set data.walls = CreateGroup() set a = Atan2(data.spellY - GetUnitY(data.caster), data.spellX - GetUnitX(data.caster)) + bj_PI / 2 set owner = GetOwningPlayer(data.caster) //Create the wall, I can't find a formula to complete the wall, I can //only create 1 unit, If I create more, they will mess up everything. //Can some one help me find a formula ? set i = 0 set tx = spellX - WallSize(data.level)/2 * Cos(a) set ty = spellY - WallSize(data.level)/2 * Sin(a) loop exitwhen(i == WallNumber(data.level)) set wall = CreateUnit(owner, WallId(data.level), tx, ty, a* bj_RADTODEG) call GroupAddUnit(data.walls, wall) set tx = tx + WallSize(data.level)/WallNumber(data.level) * Cos(a) set ty = ty + WallSize(data.level)/WallNumber(data.level) * Sin(a) set i = i + 1 endloop |
| 09-14-2008, 04:36 PM | #6 |
Ok guys,thx for all help, I just have one last problem. The wall is not centered ... and I can't find the damn way of doing it ... JASS://setting variables set data.caster = caster set data.level = GetUnitAbilityLevel(caster, AID) set data.catcher = NewTimer() set data.walls = CreateGroup() set data.freezedUnits = CreateGroup() set a = Atan2(spellY - GetUnitY(data.caster), spellX - GetUnitX(caster)) + bj_PI / 2 set owner = GetOwningPlayer(caster) //creating the walls set i = 0 set tx = spellX - WallSize(data.level)/2 * Cos(a) set ty = spellY - WallSize(data.level)/2 * Sin(a) loop exitwhen(i == WallNumber(data.level)) set wall = CreateUnit(owner, WallId(data.level), tx, ty, a * bj_RADTODEG) call DestroyEffect(AddSpecialEffect(START_EFFECT, GetUnitX(wall), GetUnitY(wall))) call GroupAddUnit(data.walls, wall) set tx = tx + WallSize(data.level) * Cos(a) set ty = ty + WallSize(data.level) * Sin(a) set i = i + 1 endloop If I use JASS:WallSize(data.level)/WallNumber(data.level) |
