- Joined
- Jun 15, 2016
- Messages
- 472
Here is a test map including mission 4, divided into parts. I ran into some strange bug which I can't seem to fix entirely in part 1 of all parts.
The thing is, some coordinates are not a viable target point for shockwave (firing on cliffs doesn't work for example), this causes the shockwave not to fire, and has happened multiple times in part 2 and part 1 (see picture "part 2 - unresponsive coorinate (cliff)"). However, in part 1 firing in some directions simply does not work, for no apparent reason (see other 2 pictures). There is no cliff or anything at the target, so I have a hard time understanding what causes them not to fire, but I did notice it happens only when facing directly north/south/west/east (i.e. facing = 0°/90°/180°/270°). Any ideas why that happens?
P.S.: type "fite me" to spawn enemy units around the hero unit.
The thing is, some coordinates are not a viable target point for shockwave (firing on cliffs doesn't work for example), this causes the shockwave not to fire, and has happened multiple times in part 2 and part 1 (see picture "part 2 - unresponsive coorinate (cliff)"). However, in part 1 firing in some directions simply does not work, for no apparent reason (see other 2 pictures). There is no cliff or anything at the target, so I have a hard time understanding what causes them not to fire, but I did notice it happens only when facing directly north/south/west/east (i.e. facing = 0°/90°/180°/270°). Any ideas why that happens?
P.S.: type "fite me" to spawn enemy units around the hero unit.
JASS:
function Trig_Dummy_cast_part1_Actions takes nothing returns nothing
local real facing = GetUnitFacing(udg_Hero)
local real sx = GetUnitX(udg_Hero)
local real sy = GetUnitY(udg_Hero)
local unit dummy = CreateUnit(Player(0),'h000',sx,sy,facing)
local real tx = sx + 1000.0*Cos(facing*bj_DEGTORAD)
local real ty = sy + 1000.0*Sin(facing*bj_DEGTORAD)
// Because apparently if the offset isn't high enough nothing will be cast :<
call BJDebugMsg("X offset: " + R2S(1000.0*Cos(facing*bj_DEGTORAD)) + ", Y offset: " + R2S(1000.0*Sin(facing*bj_DEGTORAD)))
call IssuePointOrder(dummy,"shockwave",tx,ty)
call RemoveUnit(dummy)
set dummy = null
endfunction
//===========================================================================
function InitTrig_Dummy_cast_part1 takes nothing returns nothing
set gg_trg_Dummy_cast_part1 = CreateTrigger( )
call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
set udg_Hero = CreateUnit(Player(0),'Otch',0,0,GetRandomReal(0,360))
set udg_Hash = InitHashtable()
call TriggerRegisterPlayerEvent(gg_trg_Dummy_cast_part1,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction( gg_trg_Dummy_cast_part1, function Trig_Dummy_cast_part1_Actions )
endfunction
JASS:
function Trig_Dummy_cast_part2_Actions takes nothing returns nothing
local real facing = GetUnitFacing(udg_Hero)
local real sx = GetUnitX(udg_Hero)
local real sy = GetUnitY(udg_Hero)
local unit dummy = CreateUnit(Player(0),'h000',sx,sy,facing)
local real tx
local real ty
local integer shock_counter = 0
loop
exitwhen shock_counter >= 8
set facing = facing + shock_counter*45.0
set tx = sx + 1000.0*Cos(facing*bj_DEGTORAD)
set ty = sy + 1000.0*Sin(facing*bj_DEGTORAD)
call SetUnitFacing(dummy,facing)
call IssuePointOrder(dummy,"shockwave",tx,ty)
set shock_counter = shock_counter + 1
endloop
call RemoveUnit(dummy)
set dummy = null
endfunction
//===========================================================================
function InitTrig_Dummy_cast_part2 takes nothing returns nothing
set gg_trg_Dummy_cast_part2 = CreateTrigger( )
call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
set udg_Hero = CreateUnit(Player(0),'Otch',0,0,GetRandomReal(0,360))
set udg_Hash = InitHashtable()
call TriggerRegisterPlayerEvent(gg_trg_Dummy_cast_part2,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction( gg_trg_Dummy_cast_part2, function Trig_Dummy_cast_part2_Actions )
endfunction
JASS:
function DU3_DummyInDestination takes integer pk, integer uck returns boolean
local unit du = LoadUnitHandle(udg_Hash,pk,uck)
local real target_x = LoadReal(udg_Hash,pk,uck + 1)
local real target_y = LoadReal(udg_Hash,pk,uck + 2)
local real dummy_x = GetUnitX(du)
local real dummy_y = GetUnitY(du)
local real distance_x = target_x - dummy_x
local real distance_y = target_y - dummy_y
return (distance_x < 50.0 and distance_x > -50.0) and (distance_y < 50.0 and distance_y > -50.0)
endfunction
function DU3_DummyTimeout takes nothing returns nothing
local integer dth = GetHandleId(GetExpiredTimer())
local integer total_time = LoadInteger(udg_Hash,dth,30) + 1
local integer living_projectiles = LoadInteger(udg_Hash,dth,31)
local integer counter = 0
loop
exitwhen counter >= 8
if DU3_DummyInDestination(dth,counter*3) then
call BJDebugMsg("dummy number " + I2S(counter) + " reached the goal")
call RemoveUnit(LoadUnitHandle(udg_Hash,dth,counter*3))
set living_projectiles = living_projectiles - 1
endif
set counter = counter + 1
endloop
if living_projectiles <= 0 then
call DestroyTimer(GetExpiredTimer())
call FlushChildHashtable(udg_Hash,dth)
call BJDebugMsg("All projectiles destroyed, script done")
else
call BJDebugMsg(I2S(living_projectiles) + " projectiles remaining")
call SaveInteger(udg_Hash,dth,30,total_time)
call SaveInteger(udg_Hash,dth,31,living_projectiles)
endif
endfunction
function Trig_Dummy_cast_part3_Actions takes nothing returns nothing
local timer dt = CreateTimer()
local integer dth = GetHandleId(dt)
local real facing = GetUnitFacing(udg_Hero)
local real sx = GetUnitX(udg_Hero)
local real sy = GetUnitY(udg_Hero)
local player dp = GetOwningPlayer(udg_Hero)
local integer counter = 0
local unit dummy
local real tx
local real ty
loop
exitwhen counter >= 8
set dummy = CreateUnit(dp,'h001',sx,sy,facing)
set tx = sx + 1000.0*Cos(facing*bj_DEGTORAD)
set ty = sy + 1000.0*Sin(facing*bj_DEGTORAD)
call IssuePointOrder(dummy,"move",tx,ty)
call SaveUnitHandle(udg_Hash,dth,counter*3,dummy)
call SaveReal(udg_Hash,dth,(counter*3 + 1),tx)
call SaveReal(udg_Hash,dth,(counter*3 + 2),ty)
set counter = counter + 1
set facing = facing + 45.0
endloop
call SaveInteger(udg_Hash,dth,30,0) // store timer seconds
call SaveInteger(udg_Hash,dth,31,8) // store living projectiles
call TimerStart(dt,0.125,true,function DU3_DummyTimeout)
set dummy = null
set dt = null
set dp = null
endfunction
//===========================================================================
function InitTrig_Dummy_cast_part3 takes nothing returns nothing
set gg_trg_Dummy_cast_part3 = CreateTrigger( )
call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
set udg_Hero = CreateUnit(Player(0),'Otch',0,0,GetRandomReal(0,360))
set udg_Hash = InitHashtable()
call TriggerRegisterPlayerEvent(gg_trg_Dummy_cast_part3,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction( gg_trg_Dummy_cast_part3, function Trig_Dummy_cast_part3_Actions )
endfunction
JASS:
function DU4_TargetFilter takes unit filter_unit, player dummy_player returns boolean
if IsUnitEnemy(filter_unit,dummy_player) then
return UnitAlive(filter_unit) and not IsUnitType(filter_unit,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(filter_unit,UNIT_TYPE_FLYING)
else
return false
endif
endfunction
function DU4_DummyInDestination takes integer pk, integer uck returns boolean
local unit du = LoadUnitHandle(udg_Hash,pk,uck)
local real target_x = LoadReal(udg_Hash,pk,uck + 1)
local real target_y = LoadReal(udg_Hash,pk,uck + 2)
local real dummy_x = GetUnitX(du)
local real dummy_y = GetUnitY(du)
local real distance_x = target_x - dummy_x
local real distance_y = target_y - dummy_y
// Extra variables for damage targets
local group collisions
local unit u
local player dp = GetOwningPlayer(du)
local group targets
if (distance_x < 50.0 and distance_x > -50.0) and (distance_y < 50.0 and distance_y > -50.0) then
set collisions = null // need nulling uninitialized variables?
set targets = null // need nulling uninitialized variables?
set u = null // need nulling uninitialized variables?
set dp = null // need nulling uninitialized variables?
return true
else
set collisions = CreateGroup()
set targets = LoadGroupHandle(udg_Hash,pk,32)
call GroupEnumUnitsInRange(collisions,dummy_x,dummy_y,100.0,null)
set u = FirstOfGroup(collisions)
loop
exitwhen u == null
if DU4_TargetFilter(u,dp) then
call GroupAddUnit(targets,u)
endif
call GroupRemoveUnit(collisions,u)
set u = FirstOfGroup(collisions)
endloop
call DestroyGroup(collisions)
set collisions = null
set targets = null
set dp = null
return false
endif
endfunction
function DU4_DummyTimeout takes nothing returns nothing
local integer dth = GetHandleId(GetExpiredTimer())
local integer total_time = LoadInteger(udg_Hash,dth,30) + 1
local integer living_projectiles = LoadInteger(udg_Hash,dth,31)
local integer counter = 0
// Extra variables for damage event
local group targets = LoadGroupHandle(udg_Hash,dth,32)
local unit u
if total_time/8*8 == total_time then
set targets = LoadGroupHandle(udg_Hash,dth,32)
set u = FirstOfGroup(targets)
call BJDebugMsg("Run damage event for " + I2S(CountUnitsInGroup(targets)) + " units")
loop
exitwhen u == null
call UnitDamageTarget(udg_Hero,u,100.0,false,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_SONIC,WEAPON_TYPE_WHOKNOWS)
call GroupRemoveUnit(targets,u)
set u = FirstOfGroup(targets)
endloop
endif
loop
exitwhen counter >= 8
if DU4_DummyInDestination(dth,counter*3) then
// call BJDebugMsg("dummy number " + I2S(counter) + " reached the goal")
call RemoveUnit(LoadUnitHandle(udg_Hash,dth,counter*3))
set living_projectiles = living_projectiles - 1
endif
set counter = counter + 1
endloop
if living_projectiles <= 0 then
call DestroyTimer(GetExpiredTimer())
call FlushChildHashtable(udg_Hash,dth)
// call BJDebugMsg("All projectiles destroyed, script done")
else
// call BJDebugMsg(I2S(living_projectiles) + " projectiles remaining")
call SaveInteger(udg_Hash,dth,30,total_time)
call SaveInteger(udg_Hash,dth,31,living_projectiles)
endif
set targets = null
set u = null // need nulling uninitialized variables?
endfunction
function Trig_Dummy_cast_part4_Actions takes nothing returns nothing
local timer dt = CreateTimer()
local integer dth = GetHandleId(dt)
local real facing = GetUnitFacing(udg_Hero)
local real sx = GetUnitX(udg_Hero)
local real sy = GetUnitY(udg_Hero)
local player dp = GetOwningPlayer(udg_Hero)
local integer counter = 0
local unit dummy
local real tx
local real ty
loop
exitwhen counter >= 8
set dummy = CreateUnit(dp,'h001',sx,sy,facing)
set tx = sx + 1000.0*Cos(facing*bj_DEGTORAD)
set ty = sy + 1000.0*Sin(facing*bj_DEGTORAD)
call IssuePointOrder(dummy,"move",tx,ty)
call SaveUnitHandle(udg_Hash,dth,counter*3,dummy)
call SaveReal(udg_Hash,dth,(counter*3 + 1),tx)
call SaveReal(udg_Hash,dth,(counter*3 + 2),ty)
set counter = counter + 1
set facing = facing + 45.0
endloop
call SaveInteger(udg_Hash,dth,30,0) // store timer seconds
call SaveInteger(udg_Hash,dth,31,8) // store living projectiles
call SaveGroupHandle(udg_Hash,dth,32,CreateGroup()) // store targets group
call TimerStart(dt,0.125,true,function DU4_DummyTimeout)
set dummy = null
set dt = null
set dp = null
endfunction
//===========================================================================
function InitTrig_Dummy_cast_part4 takes nothing returns nothing
set gg_trg_Dummy_cast_part4 = CreateTrigger( )
call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
set udg_Hero = CreateUnit(Player(0),'Otch',0,0,GetRandomReal(0,360))
set udg_Hash = InitHashtable()
// Extra building targets
call CreateUnit(Player(1),'hbar',2820,-2380,bj_UNIT_FACING)
call CreateUnit(Player(1),'hpea',2620,-2380,bj_UNIT_FACING)
call CreateUnit(Player(1),'hpea',2620,-2380,bj_UNIT_FACING)
call CreateUnit(Player(1),'hpea',2620,-2380,bj_UNIT_FACING)
call TriggerRegisterPlayerEvent(gg_trg_Dummy_cast_part4,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction( gg_trg_Dummy_cast_part4, function Trig_Dummy_cast_part4_Actions )
endfunction