| 03-03-2009, 10:59 AM | #1 |
Well, I have a nice little dash spell. With the whole fading dummy behind the caster as he's dashing deal. Now, everything works absolutely perfectly... except that the dummy is slightly offset from the caster. Here are some stats about my dummy:
JASS:scope Dash initializer Init //Requires TimerUtils! globals private constant integer Dash = 'A003' //Raw code. private constant real Speed = 20 //Dashing speed. private constant integer DummyId = 'h003' //Raw code of your dummy. endglobals private struct Data unit Caster real DX real DY real Angle integer ExecCount static method create takes nothing returns Data local Data d = Data.allocate() local location l = GetSpellTargetLoc() set d.DX = GetLocationX(l) set d.DY = GetLocationY(l) set d.Caster = GetTriggerUnit() set d.Angle = Atan2(d.DY - GetUnitY(d.Caster), d.DX - GetUnitX(d.Caster)) call RemoveLocation(l) set l = null return d endmethod endstruct private struct Data2 unit Dummy integer ExecCount static method create takes unit u returns Data2 local Data2 d = Data2.allocate() set d.Dummy = u set d.ExecCount = 0 call SetUnitVertexColor(u, 255, 255, 255, 200) return d endmethod endstruct private function Callback2 takes nothing returns nothing local timer t = GetExpiredTimer() local Data2 d = GetTimerData(t) call SetUnitVertexColor(d.Dummy, 100, 100, 100, 200 - d.ExecCount) set d.ExecCount = d.ExecCount + 5 if d.ExecCount == 200 then call ReleaseTimer(t) call RemoveUnit(d.Dummy) call d.destroy() endif set t = null endfunction private function Callback takes nothing returns nothing local timer t = GetExpiredTimer() local Data d = GetTimerData(t) local timer t2 = NewTimer() local real cx = GetUnitX(d.Caster) local real cy = GetUnitY(d.Caster) local Data2 d2 local real x local real y local real dx local real dy local unit u = CreateUnit(GetOwningPlayer(d.Caster), DummyId, 0, 0, bj_RADTODEG * d.Angle) call SetUnitX(u, cx) call SetUnitY(u, cy) set d2 = Data2.create(u) call SetTimerData(t2, d2) call TimerStart(t2, 0.02, true, function Callback2) call SetUnitX(d.Caster, cx + Speed * Cos(d.Angle)) call SetUnitY(d.Caster, cy + Speed * Sin(d.Angle)) set x = GetUnitX(d.Caster) set y = GetUnitY(d.Caster) set dx = d.DX - x set dy = d.DY - y if SquareRoot(dx * dx + dy * dy) <= Speed + 1 or GetWidgetLife(d.Caster) <= .407 then call ReleaseTimer(t) call PauseUnit(d.Caster, false) call d.destroy() endif set t = null set t2 = null endfunction private function Actions takes nothing returns boolean local Data d local timer t local location l = GetSpellTargetLoc() if GetSpellAbilityId() == Dash and not IsTerrainPathable(GetLocationX(l), GetLocationY(l), PATHING_TYPE_BUILDABILITY) then set d = Data.create() set t = NewTimer() call SetTimerData(t, d) call IssueImmediateOrder(d.Caster, "stop") call PauseUnit(d.Caster, true) call TimerStart(t, 0.04, true, function Callback) endif call RemoveLocation(l) set l = null set t = null return false endfunction private function Init takes nothing returns nothing local trigger t = CreateTrigger() local integer i = 0 loop exitwhen i == 6 call TriggerRegisterPlayerUnitEvent(t, Playar[i], EVENT_PLAYER_UNIT_SPELL_EFFECT, True) set i = i + 1 endloop call TriggerAddCondition(t, Condition(function Actions)) endfunction endscope |
| 03-03-2009, 12:53 PM | #2 |
Units with no movement type can be moved fine by triggers, but the model won't move. |
| 03-03-2009, 06:28 PM | #3 |
| 03-03-2009, 11:49 PM | #4 |
This is not problem of dummy unit. All units with collusion not equal to 32 or 0 have missmach in model and real position. Missmach equal to collusion size or 32, there is some wierd way to calculate i dont remember. This can be corrected by two functions. 1) Detect collusion size 2) Ajust effect position you can to it self or wait for solution, first way is much more effective. |
| 03-04-2009, 12:02 AM | #5 |
Try turning the unit's collision off? |
| 03-04-2009, 03:14 AM | #6 |
Hmm. DioD is on the right track. I just had to change the dummy unit's pathing to its original value of 16. That did that trick. Rep for all. ![]() |
