- Joined
- Jul 1, 2008
- Messages
- 1,314
Hello guys,
i got a problem with polar offsets.
The Problem:
I want to create an artillery strike, and therefore create cross hairs around a bacon, which turn around, when the player presses right arrow or left arrow.
It works, but as you can see on the screenshots, the crosshairs dont move as a line, some of them even move without any event by the player.
I really have no idea, how this could be, so please help me
The Screens
1. Start:
2. Some of the crosshairs begin to move on their own
3. 20 Seconds passed, and this is what happens:
4. Here is a screen, how i would like them to move:
-> All the crosshairs in a line, and of course the first is in the middle and doesnt have to move!
i got a problem with polar offsets.
The Problem:
I want to create an artillery strike, and therefore create cross hairs around a bacon, which turn around, when the player presses right arrow or left arrow.
It works, but as you can see on the screenshots, the crosshairs dont move as a line, some of them even move without any event by the player.
I really have no idea, how this could be, so please help me
JASS:
function SheepArtillery_GetPlayerOrdersWaitForShoot takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit fadenkreuz1 = GetHandleUnit(t,"fadenkreuz1")
local player p = GetOwningPlayer(fadenkreuz1)
local unit fadenkreuz2
local unit fadenkreuz3
local unit fadenkreuz4
local unit fadenkreuz5
local real ANGLE = udg_SheepArtillery_Array[16] - udg_SheepArtillery_Array[15] // right = - ; left = +
local real LVL = udg_SheepArtillery_Array[2]
local real x1 = udg_SheepArtillery_Array[5] // posX of fadenkreuz1
local real y1 = udg_SheepArtillery_Array[6] // posY of fadenkreuz1
local real x2
local real y2
local real DIST = 0.00
// if Sheep Artillery fired ?
if udg_SheepArtillery_Array[1] > 1.00 or udg_SheepArtillery_Array[4] == 1.00 then
// destroy timer and reset fired, start reloading
call PauseTimer(t)
set udg_SheepArtillery_Array[1] = 0.00 // firing again possible
set udg_SheepArtillery_Array[4] = 0.00 // Esc reset
call RemoveUnit(fadenkreuz1)
if LVL > 0.00 then
set fadenkreuz2 = GetHandleUnit(t,"fadenkreuz2")
set fadenkreuz3 = GetHandleUnit(t,"fadenkreuz3")
call RemoveUnit(fadenkreuz2)
call RemoveUnit(fadenkreuz3)
if LVL > 1.00 then
set fadenkreuz4 = GetHandleUnit(t,"fadenkreuz4")
set fadenkreuz5 = GetHandleUnit(t,"fadenkreuz5")
call RemoveUnit(fadenkreuz4)
call RemoveUnit(fadenkreuz5)
endif
endif
call FlushHandleLocals(t)
call DestroyTimer(t)
else
// if upgraaded to lvl 2
if LVL > 0.00 then
set fadenkreuz2 = GetHandleUnit(t,"fadenkreuz2")
set fadenkreuz3 = GetHandleUnit(t,"fadenkreuz3")
// set the new angles, if player wants to change them
// fadenkreuz 2
set x2 = udg_SheepArtillery_Array[7]
set y2 = udg_SheepArtillery_Array[8]
set ANGLE = ANGLE + (bj_RADTODEG * Atan2(y2 - y1, x2 - x1))
set x2 = x1 + 200.00 * Cos(ANGLE * bj_DEGTORAD)
set y2 = y1 + 200.00 * Sin(ANGLE * bj_DEGTORAD)
set udg_SheepArtillery_Array[7] = x2
set udg_SheepArtillery_Array[8] = y2
call SetUnitPosition(fadenkreuz2,x2,y2)
// fadenkreuz 3
set x2 = udg_SheepArtillery_Array[9]
set y2 = udg_SheepArtillery_Array[10]
set ANGLE = ANGLE + (bj_RADTODEG * Atan2(y2 - y1, x2 - x1)+180.00)
set x2 = x1 + 200.00 * Cos((ANGLE) * bj_DEGTORAD)
set y2 = y1 + 200.00 * Sin((ANGLE) * bj_DEGTORAD)
set udg_SheepArtillery_Array[9] = x2
set udg_SheepArtillery_Array[10] = y2
call SetUnitPosition(fadenkreuz3,x2,y2)
// if upgraaded to lvl 3
if LVL > 1.00 then
set fadenkreuz4 = GetHandleUnit(t,"fadenkreuz4")
set fadenkreuz5 = GetHandleUnit(t,"fadenkreuz5")
// set the new angles, if player wants to change them
// fadenkreuz 4
set x2 = udg_SheepArtillery_Array[11]
set y2 = udg_SheepArtillery_Array[12]
set ANGLE = ANGLE + (bj_RADTODEG * Atan2(y2 - y1, x2 - x1))
set x2 = x1 + 400.00 * Cos(ANGLE * bj_DEGTORAD)
set y2 = y1 + 400.00 * Sin(ANGLE * bj_DEGTORAD)
set udg_SheepArtillery_Array[10] = x2
set udg_SheepArtillery_Array[11] = y2
call SetUnitPosition(fadenkreuz4,x2,y2)
// fadenkreuz 5
set x2 = udg_SheepArtillery_Array[13]
set y2 = udg_SheepArtillery_Array[14]
set ANGLE = ANGLE + (bj_RADTODEG * Atan2(y2 - y1, x2 - x1)+180.00)
set x2 = x1 + 400.00 * Cos((ANGLE) * bj_DEGTORAD)
set y2 = y1 + 400.00 * Sin((ANGLE) * bj_DEGTORAD)
set udg_SheepArtillery_Array[13] = x2
set udg_SheepArtillery_Array[14] = y2
call SetUnitPosition(fadenkreuz5,x2,y2)
endif
endif
endif
// reset
set fadenkreuz1 = null
set fadenkreuz2 = null
set fadenkreuz3 = null
set fadenkreuz4 = null
set fadenkreuz5 = null
set t = null
set p = null
endfunction
function Trig_Sheep_Artillery_set_Point_Actions takes nothing returns nothing
// udg_SheepArtillery_Array [REAL]
local unit art = gg_unit_o004_0096
local player p = GetOwningPlayer(art)
local real x = GetOrderPointX()
local real y = GetOrderPointY()
local timer t
// is player owning player? ( still a little bug chance )
if IsUnitSelected(art,Player(R2I(udg_SheepArtillery_Array[17]))) == true then
// init sheep strike if possible
if udg_SheepArtillery_Array[1] == 0.00 then
// create fadenkreuze
set t = CreateTimer()
set bj_lastCreatedUnit = CreateUnit(p,'h00F',x,y,270.00)
call SetHandleHandle(t,"fadenkreuz1",bj_lastCreatedUnit)
set udg_SheepArtillery_Array[5] = x
set udg_SheepArtillery_Array[6] = y
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"-[|c00ff0000Warning|r]- Artillery-Bacon set to ("+I2S(R2I(x))+"/"+I2S(R2I(y))+")")
// upgrade to Lvl 2 "fadenkreuze" already purchased?
if udg_SheepArtillery_Array[2] > 0.00 then
set y = y + 200.00
set udg_SheepArtillery_Array[7] = x
set udg_SheepArtillery_Array[8] = y
set bj_lastCreatedUnit = CreateUnit(p,'h00F',x,y,270.00)
call SetHandleHandle(t,"fadenkreuz2",bj_lastCreatedUnit)
set y = y - 400.00
set bj_lastCreatedUnit = CreateUnit(p,'h00F',x,y,270.00)
call SetHandleHandle(t,"fadenkreuz3",bj_lastCreatedUnit)
set udg_SheepArtillery_Array[9] = x
set udg_SheepArtillery_Array[10] = y
endif
// upgrade to Lvl 3 "fadenkreuze" already purchased?
if udg_SheepArtillery_Array[2] > 1.00 then
set y = y + 600.00
set udg_SheepArtillery_Array[11] = x
set udg_SheepArtillery_Array[12] = y
set bj_lastCreatedUnit = CreateUnit(p,'h00F',x,y,270.00)
call SetHandleHandle(t,"fadenkreuz4",bj_lastCreatedUnit)
set y = y - 800.00
set bj_lastCreatedUnit = CreateUnit(p,'h00F',x,y,270.00)
call SetHandleHandle(t,"fadenkreuz5",bj_lastCreatedUnit)
set udg_SheepArtillery_Array[13] = x
set udg_SheepArtillery_Array[14] = y
endif
set udg_SheepArtillery_Array[1] = 1.00 // set unit firing step 1
call TimerStart(t,0.50,true,function SheepArtillery_GetPlayerOrdersWaitForShoot)
endif
endif
set t = null
set p = null
set art = null
endfunction
//===========================================================================
function InitTrig_Sheep_Artillery_set_Point takes nothing returns nothing
set gg_trg_Sheep_Artillery_set_Point = CreateTrigger( )
call TriggerRegisterUnitEvent( gg_trg_Sheep_Artillery_set_Point, gg_unit_o004_0096, EVENT_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_Sheep_Artillery_set_Point, function Trig_Sheep_Artillery_set_Point_Actions )
endfunction
The Screens
1. Start:
2. Some of the crosshairs begin to move on their own
3. 20 Seconds passed, and this is what happens:
4. Here is a screen, how i would like them to move:
-> All the crosshairs in a line, and of course the first is in the middle and doesnt have to move!