Добавлен Гуванч
ребята привет, слушайте не могли вы бы проверить мой код и дать пару советов по использованию vJass'a может есть какие то фишки или какие то собственные функции без которых вы не пишете код
library Chidory initializer Init
globals
private integer SpellID = 'A001'// Код способности
endglobals
private struct SpellStruct
unit Caster
unit Target
real Damage
real Speed
real Angle
method Destroy takes nothing returns nothing
set this.Caster = null
set this.Target = null
call this.destroy()
endmethod
endstruct
private function Distance takes unit A, unit B returns real
return SquareRoot((GetUnitX(B) - GetUnitX(A)) * (GetUnitX(B) - GetUnitX(A)) + (GetUnitY(B) - GetUnitY(A)) * (GetUnitY(B) - GetUnitY(A)))
endfunction
private function Chidory_Action takes nothing returns nothing
local timer Timer = GetExpiredTimer()
local SpellStruct s = LoadInteger(Hash,GetHandleId(Timer),StringHash("Struct"))
local real x
local real y
if Distance(s.Caster,s.Target) > 165 and GetWidgetLife(s.Caster) > 0.405 and GetWidgetLife(s.Target) > 0.405 then
set x = GetUnitX(s.Caster)
set y = GetUnitY(s.Caster)
set s.Angle = bj_RADTODEG * Atan2(GetUnitY(s.Target) - y, GetUnitX(s.Target) - x)
call SetUnitX(s.Caster,x + s.Speed * Cos(s.Angle * bj_DEGTORAD))
call SetUnitY(s.Caster,y + s.Speed * Sin(s.Angle * bj_DEGTORAD))
else
call PauseTimer(Timer)
call SetUnitAnimation(s.Caster,"spell channel one")
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",GetUnitX(s.Target),GetUnitY(s.Target)))
call UnitDamageTarget(s.Caster,s.Target,s.Damage,false,false,AT_Chaos,DT_Magic,null)
call FlushChildHashtable(Hash,GetHandleId(Timer))
call DestroyTimer(Timer)
call s.Destroy()
endif
set Timer = null
endfunction
private function Chidory_Variable takes nothing returns nothing
local timer Timer = CreateTimer()
local SpellStruct s = SpellStruct.create()
set s.Caster = GetTriggerUnit()
set s.Target = GetSpellTargetUnit()
set s.Speed = 35.0
set s.Damage = (70 * GetUnitAbilityLevel(s.Caster,SpellID)) + (GetHeroAgi(s.Caster,true) * 1.2)
call SaveInteger(Hash,GetHandleId(Timer),StringHash("Struct"),s)
call TriggerSleepAction(0.5)
call DestroyEffect(AddSpecialEffect("wind.mdx",GetUnitX(s.Caster),GetUnitY(s.Caster)))
call TimerStart(Timer,0.01,true,function Chidory_Action)
set Timer = null
endfunction
private function Chidory_Condition takes nothing returns boolean
return GetSpellAbilityId() == SpellID
endfunction
private function Init takes nothing returns nothing
local trigger Chidory = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Chidory, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( Chidory, Condition( function Chidory_Condition ) )
call TriggerAddAction( Chidory, function Chidory_Variable )
set Chidory = null
endfunction
endlibrary
Принятый ответ
Здесь вы переводите из радианов в градусы, а потом при использовании данной переменной снова переводите её в радианы:
set s.Angle = bj_RADTODEG * Atan2(GetUnitY(s.Target) - y, GetUnitX(s.Target) - x)
call SetUnitX(s.Caster,x + s.Speed * Cos(s.Angle * bj_DEGTORAD))
call SetUnitY(s.Caster,y + s.Speed * Sin(s.Angle * bj_DEGTORAD))
Лучше заменить на :
set s.Angle = Atan2(GetUnitY(s.Target) - y, GetUnitX(s.Target) - x)
call SetUnitX(s.Caster,x + s.Speed * Cos(s.Angle))
call SetUnitY(s.Caster,y + s.Speed * Sin(s.Angle))
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Ред. scopterectus