Добавлен
Что-то с кодом происходит, через какое-то время игра вылетает.
library MINIGUNqw1Lib
globals
    constant hashtable H = InitHashtable( )
    constant group TempGroup = CreateGroup( )
    constant location LFZ = Location( 0.00, 0.00 )
endglobals

native UnitAlive takes unit id returns boolean

function GetLocZ1 takes real x, real y returns real
    call MoveLocation( LFZ, x, y )
    return GetLocationZ( LFZ )
endfunction

struct vector6
    real x
    real y
    real z
    
    method normalize takes nothing returns nothing
        local real l = SquareRoot( x * x + y * y + z * z )
        
        if l == 0.00 then
            set l = 1.00
        endif
        
        set x = x * ( 1.00 / l )
        set y = y * ( 1.00 / l )
        set z = z * ( 1.00 / l )
    endmethod
    
    static method create takes real x, real y, real z returns thistype
        local thistype this = thistype.allocate( )
        
        set this.x = x
        set this.y = y
        set this.z = z
        
        call this.normalize( )
        
        return this
    endmethod
endstruct

struct bullet6
    unit caster
    unit dummy
    player p
    
    real x
    real y
    real z
    real s // speed
    real d // distance
    real r // radius
    
    vector6 v
endstruct

function Move 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 - GetLocZ1( 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, 45.00, false, false, null, null, null )
            call DestroyEffect( AddSpecialEffectTarget( "WeaponsandEffect/BloodDamage.mdx", u, "origin" ) )
            
        endif
    endloop
    
    if A.d <= 0.00 or A.z - GetLocZ1( A.x, A.y ) <= 20.00 then
        call PauseTimer( GetExpiredTimer( ) )
        call FlushChildHashtable( H, GetHandleId( GetExpiredTimer( ) ) )
        call DestroyTimer( GetExpiredTimer( ) )
        
        call KillUnit( A.dummy )
        
        set A.dummy = null
        set A.caster = null
        call A.v.destroy( )
        call A.destroy( )
    endif
endfunction

function Trig_Shoot2_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 = GetLocZ1( x, y ) + 50.00 
    local string WeaponEffect = "WeaponsandEffect/Konstrukt_MinigunEffectAttachment.MDX"
    local string WeaponEffect2 = "WeaponsandEffect/ImpulseRifle.mdx"
    set A.caster = GetTriggerUnit( )
    set A.p = GetOwningPlayer( A.caster )
    
    // for offset
    set A.x = GetUnitX( A.caster )
    set A.y = GetUnitY( A.caster )
    set A.z = GetUnitFlyHeight( A.caster ) + GetLocZ1( A.x, A.y ) + 50.00 
    
    set A.v = vector6.create( x - A.x, y - A.y, z - A.z )
    
    set A.x = A.x + 150.00 * A.v.x * Cos( A.v.z )
    set A.y = A.y + 150.00 * A.v.y * Cos( A.v.z )
    set A.z = GetUnitFlyHeight( A.caster ) + GetLocZ1( A.x, A.y ) + 50.00 
    
    // for move
        set A.v.x = x - A.x + GetRandomReal(-50.0, 50.0)
        set A.v.y = y - A.y + GetRandomReal(-50.0, 50.0)
        set A.v.z = z - A.z  

   
     call A.v.normalize( )
    
    set A.d = 4200.00
    set A.s = 1500.00 * 0.03125
    set A.r = 40.00
    
    call SetUnitAnimation( A.caster, "attack" )
    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 - GetLocZ1( A.x, A.y ), 0.00 )
    call BlzStartUnitAbilityCooldown( A.caster, 'A004', 0.02)
    call SaveInteger( H, GetHandleId( t ), 0, A )
    call TimerStart( t, 0.02, true, function Move )
    call DestroyEffect( AddSpecialEffectTarget( WeaponEffect, A.caster, "weapon" ) )
    call DestroyEffect( AddSpecialEffectTarget( WeaponEffect2, A.caster, "weapon" ) )
    call SetItemCharges( GetItemOfTypeFromUnitBJ(GetSpellAbilityUnit(), 'I003'), ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetSpellAbilityUnit(), 'I003')) - 1 ) )
    
    
    set t = null
    
endfunction

//===========================================================================
function Shoot2_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A004' ) ) then
        return false
    endif
    if ( not ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetSpellAbilityUnit(), 'I003')) != 0 ) ) then
        return false
    endif
    return true
endfunction

function InitTrig_Shoot2 takes nothing returns nothing
    set gg_trg_Shoot2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot2, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Shoot2, Condition( function Shoot2_Conditions ) )
    call TriggerAddAction( gg_trg_Shoot2, function Trig_Shoot2_Actions )
endfunction
endlibrary
`
ОЖИДАНИЕ РЕКЛАМЫ...
0
3
9 месяцев назад
Отредактирован NatriY
0
Как ты вообще код запустил, если у тебя в этих строчках несуществующая структура используется?
local bullet A = bullet.create( )
local bullet A = LoadInteger( H, GetHandleId( GetExpiredTimer( ) ), 0 )
0
8
9 месяцев назад
0
NatriY, то что он работает вообще странно, но ошибка нашлась к счастью.
0
14
8 месяцев назад
0
но ошибка нашлась к счастью
и это было:
Чтобы оставить комментарий, пожалуйста, войдите на сайт.