- Joined
- Aug 26, 2016
- Messages
- 139
Hello, I noticed this strange error when I quickly rotate cursor while shooting, the map crashes out.
Error found.
For some reason, a bullet that flies too far causes the game to crash.
Thank you brother)
JASS:
library MinigunLib
native UnitAlive takes unit id returns boolean
function GetLocZ takes real x, real y returns real
call MoveLocation( LFZ, x, y )
return GetLocationZ( LFZ )
endfunction
function MoveMG takes nothing returns nothing
local bullet A = LoadInteger( H, GetHandleId( GetExpiredTimer( ) ), 0 )
local unit u
set A.x = A.x + A.s * A.v.x * Cos( A.v.z )
set A.y = A.y + A.s * A.v.y * Cos( A.v.z )
set A.z = A.z + A.s * A.v.z
set A.d = A.d - A.s
call SetUnitX( A.dummy, A.x )
call SetUnitY( A.dummy, A.y )
call SetUnitFlyHeight( A.dummy, A.z - GetLocZ( A.x, A.y ), 0.00 )
call GroupEnumUnitsInRange( TempGroup, A.x, A.y, A.r, null )
loop
set u = FirstOfGroup( TempGroup )
exitwhen u == null
call GroupRemoveUnit( TempGroup, u )
if UnitAlive( u ) and IsUnitEnemy( u, A.p ) and RAbsBJ( GetUnitFlyHeight( u ) - GetUnitFlyHeight( A.dummy ) ) <= 100.00 then
call GroupClear( TempGroup )
call UnitDamageTarget( A.caster, u, 50.00, false, false, null, null, null )
call RemoveUnit( A.dummy )
call DestroyTimer( GetExpiredTimer( ) )
call FlushChildHashtable( H, GetHandleId( GetExpiredTimer( ) ) )
call DestroyTimer( GetExpiredTimer( ) )
set A.dummy = null
set A.caster = null
call A.v.destroy( )
call A.destroy( )
endif
endloop
if A.d <= 0.00 or A.z - GetLocZ( A.x, A.y ) <= 20.00 then
call PauseTimer( GetExpiredTimer( ) )
call FlushChildHashtable( H, GetHandleId( GetExpiredTimer( ) ) )
call DestroyTimer( GetExpiredTimer( ) )
call RemoveUnit( A.dummy )
set A.dummy = null
set A.caster = null
call A.v.destroy( )
call A.destroy( )
endif
endfunction
function Trig_Shoot2Ak47_Actions takes nothing returns nothing
local timer t = CreateTimer( )
local unit Target = udg_Camera[GetConvertedPlayerId(GetTriggerPlayer())]
local bullet A = bullet.create( )
local real x = GetUnitX(Target)
local real y = GetUnitY(Target)
local real z = GetLocZ( x, y ) + 90.00
local string WeaponEffect = "WeaponsandEffect/Konstrukt_MinigunEffectAttachment.MDX"
local string WeaponEffect2 = "WeaponsandEffect/ImpulseRifle.mdx"
set A.caster = udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())]
set A.p = GetOwningPlayer( A.caster )
call CameraSetTargetNoiseForPlayer( GetOwningPlayer(udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())]), 21.60, 3.10 )
// for offset
set A.x = GetUnitX( A.caster )
set A.y = GetUnitY( A.caster )
set A.z = GetUnitFlyHeight( A.caster ) + GetLocZ( A.x, A.y ) + 90.00
set A.v = vector.create( x - A.x, y - A.y, z - A.z )
set A.x = A.x + 100.00 * A.v.x * Cos( A.v.z )
set A.y = A.y + 100.00 * A.v.y * Cos( A.v.z )
set A.z = GetUnitFlyHeight( A.caster ) + GetLocZ( A.x, A.y ) + 90.00
// for move
set A.v.x = x - A.x + GetRandomReal(-90.0, 90.0)
set A.v.y = y - A.y + GetRandomReal(-90.0, 90.0)
set A.v.z = z - A.z
call A.v.normalize( )
set A.d = 8200.00
set A.s = 1500.00 * 0.03125
set A.r = 90.00
set A.dummy = CreateUnit( A.p, 'u000', A.x, A.y, Atan2( A.v.y, A.v.x ) * bj_RADTODEG )
call SetUnitPathing( A.dummy, false )
call UnitAddAbility( A.dummy, 'Arav' )
call SetUnitX( A.dummy, A.x )
call SetUnitY( A.dummy, A.y )
call SetUnitFlyHeight( A.dummy, A.z - GetLocZ( A.x, A.y ), 0.00 )
call SaveInteger( H, GetHandleId( t ), 0, A )
call TimerStart( t, 0.02, true, function MoveMG )
call DestroyEffect( AddSpecialEffectTarget( WeaponEffect, A.caster, "weapon" ) )
call DestroyEffect( AddSpecialEffectTarget( WeaponEffect2, A.caster, "chest" ) )
call SetItemCharges( GetItemOfTypeFromUnitBJ(udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())], 'I003'), ( GetItemCharges(GetItemOfTypeFromUnitBJ(udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())], 'I003')) - 1 ) )
call IssueImmediateOrderBJ( udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())], "stop" )
set t = null
set Target = null
call IssueImmediateOrderBJ( udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())], "stop" )
endfunction
//===========================================================================
function Shoot2_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00U' ) ) then
return false
endif
if ( not ( GetItemCharges(GetItemOfTypeFromUnitBJ(udg_UnitBody[GetConvertedPlayerId(GetTriggerPlayer())], 'I003')) != 0 ) ) then
return false
endif
return true
endfunction
function InitTrig_Shoot2Ak47 takes nothing returns nothing
local trigger t1 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t1, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( t1, Condition( function Shoot2_Conditions ) )
call TriggerAddAction( t1, function Trig_Shoot2Ak47_Actions )
set t1 = null
endfunction
endlibrary
Error found.
JASS:
set A.d = 8200.00
JASS:
set A.d = 1200.00
For some reason, a bullet that flies too far causes the game to crash.
Error found.
JASS:set A.d = 8200.00
JASS:set A.d = 1200.00
For some reason, a bullet that flies too far causes the game to crash.
Thank you brother)