Добавлен scopterectus
Решил написать небольшую библиотеку по созданию своих триггерных иллюзий.
раскрыть
library IllusionSystem initializer onInit requires Table
globals
private unit summoner = null
private unit illusion = null
private unit tempUnit = null
private unit lastCreatedIllusion = null
private group illusions = null
private table damage = table( 0 )
private table defense = table( 0 )
endglobals
constant function GetLastCreatedIllusion takes nothing returns unit
return lastCreatedIllusion
endfunction
function CreateIllusion takes player whichPlayer, integer unitId, real x, real y, real face, integer percentDamage, integer percentArmor, real duration returns unit
set tempUnit = CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), unitId, x, y, face )
if ( summoner == null ) then
call BJDebugMsg( "CreateIllusion( ) : summoner ещё не создан." )
elseif ( not IssueTargetOrderById( summoner, 852274, tempUnit ) ) then
call BJDebugMsg( "CreateIllusion( ) : не удалось создать иллюзию." )
endif
call RemoveUnit( tempUnit )
set illusion = GetLastCreatedIllusion( )
set damage [ GetHandleId( illusion ) ] = percentDamage
set defense[ GetHandleId( illusion ) ] = percentArmor
call SetUnitOwner ( illusion, whichPlayer, true )
call SetUnitX ( illusion, x )
call SetUnitX ( illusion, y )
call SetUnitFacing ( illusion, face )
// call UnitApplyTimedLife( illusion, 'BOmi', duration )
call GroupAddUnit ( illusions, illusion )
return illusion
endfunction
private function onUnitDamaged takes nothing returns nothing
local unit victim = GetTriggerUnit( )
local unit damager = GetEventDamageSource( )
set victim = null
set damager = null
endfunction
function onIllusionSummon takes nothing returns nothing
set lastCreatedIllusion = GetSummoningUnit( )
endfunction
public function onInit takes nothing returns nothing
local trigger trig = CreateTrigger( )
set illusions = CreateGroup( )
set damage = table.create( )
set defense = table.create( )
set summoner = CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), DUMMY_UNIT_ID, HIDDEN_X, HIDDEN_Y, bj_UNIT_FACING )
call UnitAddAbility ( summoner, 'Aloc' )
call SetUnitInvulnerable( summoner, true )
call UnitAddAbility ( summoner, 'A00A' )
call SetUnitPathing ( summoner, false )
call UnitRemoveAbility ( summoner, 'Amov' )
call TriggerRegisterUnitEvent( trig, summoner, EVENT_UNIT_SUMMON )
call TriggerAddAction ( trig, function onIllusionSummon )
set trig = null
endfunction
endlibrary
Но по неизвестной мне причине система работает через раз. А при первом вызове функции CreateIllusion( ) иллюзия не создаётся или же создается за нейтрального игрока.
Вот карта.
Принятый ответ
Всё время выдает один и тот же хендл. Думаю ошибка здесь
function onIllusionSummon takes nothing returns nothing
call BJDebugMsg(I2S(GetHandleId(GetSummoningUnit( ))))
set lastCreatedIllusion = GetSummoningUnit( )
endfunction
Короче, поменяй GetSummoningUnit( ) на GetSummonedUnit( )
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
quq_CCCP: Это да, но в карте открыта видимость, так что проблема была не в этом.