Возможно, вопрос баян, но нету времени искать.
У моего героя есть способность, при использовании которой, в течение некоторого времени он перемещается в случайную точку в радиусе 600 от начальной позиции. Вроде я все сделал правильно, но при использовании способности герой всегда перемещается в определенную точку на карте, а уже вокруг нее передвигается в случайные точки. Я использовал для выбора региона вот эту функцию:
local rect surect = GetRandomLocInRect(RectFromCenterSizeBJ(suloc, 600.00, 600.00))
Ну а затем выбираю случайную точку
local location random = GetRandomLocInRect(surect)
Я понимаю, что проблема в первой функции. На какую другую функцию следует заменить ее? И что тогда делает эта функция? Ведь герой перемещается даже не в центр карты, а со смещением влево. Что за бред, я не понимаю.
Вот весь код, если кому то надо
Код
function Trig_SlayerUlt_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00V'
endfunction
function Ultaction takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle(udg_Hash, sid, 0)
if IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy( GetEnumUnit(), GetOwningPlayer(su)) == true then
call UnitDamageTargetBJ( su, GetEnumUnit(), 210.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
set su = null
endfunction
function UltimateRun takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle(udg_Hash, sid, 0)
local integer suid = GetHandleId(su)
local location suloc = LoadLocationHandle(udg_Hash, sid, 1)
local effect sueff = LoadEffectHandle(udg_Hash, sid, 2)
local real x = GetLocationX( suloc )
local real y = GetLocationY( suloc )
local rect surect = Rect( x - 600.00*0.5, y - 600.00*0.5, x + 600.00*0.5, y + 600.00*0.5 )
local location random = Location(GetRandomReal(GetRectMinX(surect), GetRectMaxX(surect)), GetRandomReal(GetRectMinY(surect), GetRectMaxY(surect)))
local integer sc = LoadInteger(udg_Hash, sid, 1)
call SetUnitPositionLoc( su, random )
call SetUnitAnimation( su, "attack" )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call ForGroupBJ( GetUnitsInRangeOfLocAll(250.00, suloc), function Ultaction )
set bj_wantDestroyGroup=true
call SaveInteger(udg_Hash,sid,1,sc + 1)
if sc >= 10 then
call SetUnitPositionLoc( su, suloc )
call DestroyEffectBJ( sueff )
call SetUnitPathing( su, true )
call SetUnitInvulnerable( su, false )
call PauseUnitBJ( false, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 0.00 )
call PauseTimer(st)
call DestroyTimer(st)
call FlushChildHashtable(udg_Hash, sid)
endif
set suloc = null
set random = null
set st = null
set su = null
set sueff = null
endfunction
function Trig_SlayerUlt_Actions takes nothing returns nothing
local timer st = CreateTimer()
local integer sid = GetHandleId(st)
local unit su = GetTriggerUnit()
local integer suid = GetHandleId(su)
local location suloc = GetUnitLoc(su)
local effect sueff
call AddSpecialEffectTargetUnitBJ( "hand right", su, "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl" )
set sueff = GetLastCreatedEffectBJ()
call SetUnitPathing( su, false )
call SetUnitInvulnerable( su, true )
call PauseUnitBJ( true, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 50.00 )
call SaveAgentHandle(udg_Hash, sid, 0, su)
call SaveAgentHandle(udg_Hash, sid, 1, suloc)
call SaveAgentHandle(udg_Hash, sid, 2, sueff)
call SaveAgentHandle(udg_Hash, suid, 0, st)
call SaveInteger (udg_Hash, sid, 1, 1)
call TimerStart( st, .3, true, function UltimateRun )
call RemoveLocation(suloc)
set suloc = null
set st = null
set su = null
set sueff = null
endfunction
function InitTrig_SlayerUlt takes nothing returns nothing
set gg_trg_SlayerUlt = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SlayerUlt, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_SlayerUlt, Condition( function Trig_SlayerUlt_Conditions ) )
call TriggerAddAction( gg_trg_SlayerUlt, function Trig_SlayerUlt_Actions )
endfunction
Может найдете какие-нибудь ошибки:). Не обращайте внимания на bj функции, я их оптимизирую в конце.

Принятый ответ

вопервых ты в 1 и ту же ячейку пытаешся записать 2 значения (location и integer)
во вторых ты создаёш область по кординатам а следующей строчкой находиш эти же кординаты с помощью функций
в 3 ты сохранял точку в хэш и сразу же удалял её
и в 4 ты не инициализировал хэш
function Trig_SlayerUlt_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00V'
endfunction
function Ultaction takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle (udg_Hash, sid, 0)
if IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy( GetEnumUnit(), GetOwningPlayer(su)) == true then
call UnitDamageTargetBJ( su, GetEnumUnit(), 210.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
set su = null
endfunction
function UltimateRun takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle (udg_Hash, sid, 0)
local integer suid = GetHandleId(su)
local location suloc = LoadLocationHandle(udg_Hash, sid, 1)
local effect sueff = LoadEffectHandle (udg_Hash, sid, 2)
local real x = GetLocationX( suloc )
local real y = GetLocationY( suloc )
local rect surect = Rect( x - 600.00*0.5, y - 600.00*0.5, x + 600.00*0.5, y + 600.00*0.5 )
local location random = Location (GetRandomReal(x-600*.5,x+600*.5), GetRandomReal (y-600*.5, y+600*.5))
local integer sc = LoadInteger (udg_Hash, sid, 10)
call SetUnitPositionLoc( su, random )
call SetUnitAnimation( su, "attack" )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Human\\Thunderclap \\ThunderClapCaster.mdl" )
call DestroyEffectBJ ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl" )
call DestroyEffectBJ ( GetLastCreatedEffectBJ() )
call ForGroupBJ ( GetUnitsInRangeOfLocAll(250.00, suloc), function Ultaction )
set bj_wantDestroyGroup=true
call SaveInteger(udg_Hash,sid,10,sc + 1)
if sc >= 10 then
call SetUnitPositionLoc( su, suloc )
call DestroyEffectBJ( sueff )
call SetUnitPathing( su, true )
call SetUnitInvulnerable( su, false )
call PauseUnitBJ( false, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 0.00 )
call PauseTimer(st)
call DestroyTimer(st)
call FlushChildHashtable(udg_Hash, sid)
endif
set suloc = null
set random = null
set st = null
set su = null
set sueff = null
endfunction
function Trig_SlayerUlt_Actions takes nothing returns nothing
local timer st = CreateTimer()
local integer sid = GetHandleId(st)
local unit su = GetTriggerUnit()
local integer suid = GetHandleId(su)
local location suloc = GetUnitLoc(su)
local effect sueff
local real x=GetUnitX(su)
local real y=GetUnitY(su)
call AddSpecialEffectTargetUnitBJ ( "hand right", su, "Abilities\\Weapons \\PhoenixMissile\\Phoenix_Missile.mdl" )
set sueff = GetLastCreatedEffectBJ()
call SetUnitPathing( su, false )
call SetUnitInvulnerable( su, true )
call PauseUnitBJ( true, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 50.00 )
call SaveUnitHandle(udg_Hash, sid, 0, su)
call SaveAgentHandle(udg_Hash, sid, 1, suloc)
call SaveAgentHandle(udg_Hash, sid, 2, sueff)
call SaveAgentHandle(udg_Hash, suid, 0, st)
call SaveInteger (udg_Hash, sid, 10, 1)
call TimerStart( st, .3, true, function UltimateRun )
set suloc = null
set st = null
set su = null
set sueff = null
endfunction
===========================================================================
function InitTrig_SlayerUlt takes nothing returns nothing
set gg_trg_SlayerUlt = CreateTrigger ( )
set udg_Hash=InitHashtable()
call TriggerRegisterAnyUnitEventBJ ( gg_trg_SlayerUlt, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition ( gg_trg_SlayerUlt, Condition( function Trig_SlayerUlt_Conditions ) )
call TriggerAddAction ( gg_trg_SlayerUlt, function Trig_SlayerUlt_Actions )
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
1
28
11 лет назад
1
вопервых ты в 1 и ту же ячейку пытаешся записать 2 значения (location и integer)
во вторых ты создаёш область по кординатам а следующей строчкой находиш эти же кординаты с помощью функций
в 3 ты сохранял точку в хэш и сразу же удалял её
и в 4 ты не инициализировал хэш
function Trig_SlayerUlt_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00V'
endfunction
function Ultaction takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle (udg_Hash, sid, 0)
if IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy( GetEnumUnit(), GetOwningPlayer(su)) == true then
call UnitDamageTargetBJ( su, GetEnumUnit(), 210.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
set su = null
endfunction
function UltimateRun takes nothing returns nothing
local timer st = GetExpiredTimer()
local integer sid = GetHandleId(st)
local unit su = LoadUnitHandle (udg_Hash, sid, 0)
local integer suid = GetHandleId(su)
local location suloc = LoadLocationHandle(udg_Hash, sid, 1)
local effect sueff = LoadEffectHandle (udg_Hash, sid, 2)
local real x = GetLocationX( suloc )
local real y = GetLocationY( suloc )
local rect surect = Rect( x - 600.00*0.5, y - 600.00*0.5, x + 600.00*0.5, y + 600.00*0.5 )
local location random = Location (GetRandomReal(x-600*.5,x+600*.5), GetRandomReal (y-600*.5, y+600*.5))
local integer sc = LoadInteger (udg_Hash, sid, 10)
call SetUnitPositionLoc( su, random )
call SetUnitAnimation( su, "attack" )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Human\\Thunderclap \\ThunderClapCaster.mdl" )
call DestroyEffectBJ ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( random, "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl" )
call DestroyEffectBJ ( GetLastCreatedEffectBJ() )
call ForGroupBJ ( GetUnitsInRangeOfLocAll(250.00, suloc), function Ultaction )
set bj_wantDestroyGroup=true
call SaveInteger(udg_Hash,sid,10,sc + 1)
if sc >= 10 then
call SetUnitPositionLoc( su, suloc )
call DestroyEffectBJ( sueff )
call SetUnitPathing( su, true )
call SetUnitInvulnerable( su, false )
call PauseUnitBJ( false, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 0.00 )
call PauseTimer(st)
call DestroyTimer(st)
call FlushChildHashtable(udg_Hash, sid)
endif
set suloc = null
set random = null
set st = null
set su = null
set sueff = null
endfunction
function Trig_SlayerUlt_Actions takes nothing returns nothing
local timer st = CreateTimer()
local integer sid = GetHandleId(st)
local unit su = GetTriggerUnit()
local integer suid = GetHandleId(su)
local location suloc = GetUnitLoc(su)
local effect sueff
local real x=GetUnitX(su)
local real y=GetUnitY(su)
call AddSpecialEffectTargetUnitBJ ( "hand right", su, "Abilities\\Weapons \\PhoenixMissile\\Phoenix_Missile.mdl" )
set sueff = GetLastCreatedEffectBJ()
call SetUnitPathing( su, false )
call SetUnitInvulnerable( su, true )
call PauseUnitBJ( true, su )
call SetUnitVertexColorBJ( su, 100, 100, 100, 50.00 )
call SaveUnitHandle(udg_Hash, sid, 0, su)
call SaveAgentHandle(udg_Hash, sid, 1, suloc)
call SaveAgentHandle(udg_Hash, sid, 2, sueff)
call SaveAgentHandle(udg_Hash, suid, 0, st)
call SaveInteger (udg_Hash, sid, 10, 1)
call TimerStart( st, .3, true, function UltimateRun )
set suloc = null
set st = null
set su = null
set sueff = null
endfunction
===========================================================================
function InitTrig_SlayerUlt takes nothing returns nothing
set gg_trg_SlayerUlt = CreateTrigger ( )
set udg_Hash=InitHashtable()
call TriggerRegisterAnyUnitEventBJ ( gg_trg_SlayerUlt, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition ( gg_trg_SlayerUlt, Condition( function Trig_SlayerUlt_Conditions ) )
call TriggerAddAction ( gg_trg_SlayerUlt, function Trig_SlayerUlt_Actions )
endfunction
Принятый ответ
0
22
11 лет назад
0
Хэщ инициализируется в начале игры.
nvc123:
вопервых ты в 1 и ту же ячейку пытаешся записать 2 значения (location и integer)
О, действительно
nvc123:
в 3 ты сохранял точку в хэш и сразу же удалял её
Спасибо огромное, проблема в этом оказалось, как то не приметил.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.