private void UpdateFollow(long tick) { if (IsMoving) { if (_unit.GetDistanceTo(FollowTarget) < _minFollowTolerance) { StopFollowMove(); return; } } if (MovementSpeed == 0 || _unit != null && _unit.IsDisabled || _unit != null && _unit.IsStaggered) { StopFollowMove(); return; } if (tick > _nextFollowUpdate) { // already within range int distTo = _unit.GetDistanceTo(FollowTarget); _followCatchupFactor = _pathThrough && distTo > _minFollowTolerance + 20 ? 20 : 0; if (distTo < _maxFollowTolerance) { _nextFollowUpdate = tick + FollowReacquisitionInterval; _unit.Heading = _unit.WorldPosition.GetHeading(FollowTarget.WorldPosition); return; } _nextFollowUpdate = tick + FOLLOW_PATH_UPDATE_INTERVAL; _destFollowPos.SetCoordsFrom(FollowTarget.WorldPosition); _toTarget.X = _unit.WorldPosition.X - _destFollowPos.X; _toTarget.Y = _unit.WorldPosition.Y - _destFollowPos.Y; _toTarget.Normalize(); if (!_pathThrough || !FollowTarget.IsMoving) { _destFollowPos.X += (int)(_toTarget.X * _minFollowTolerance * 12); _destFollowPos.Y += (int)(_toTarget.Y * _minFollowTolerance * 12); } else { _destFollowPos.X -= (int)(_toTarget.X * _minFollowTolerance * 12); _destFollowPos.Y -= (int)(_toTarget.Y * _minFollowTolerance * 12); } Move(_destFollowPos); } }
public virtual void Initialize(Unit caster, Unit target, ushort buffId, byte buffLevel, byte stackLevel, BuffInfo myBuffInfo, BuffInterface parentInterface) { Caster = caster; Target = target; _buffInfo = myBuffInfo; StackLevel = stackLevel; BuffLevel = buffLevel; BuffId = buffId; _buffInterface = parentInterface; uint leadMs = 0; // Fixed lead-in (Oil channel) if (_buffInfo.LeadInDelay < 0) { leadMs = (uint)-_buffInfo.LeadInDelay; } // Variable lead-in with range (Rapid Fire channel) else if (_buffInfo.LeadInDelay > 0) { leadMs = (uint)(_buffInfo.LeadInDelay * Caster.GetDistanceTo(Target) * 0.01f); } NextTickTime = TCPManager.GetTimeStampMS() + _buffInfo.Interval + leadMs; if (Duration > 0) { DurationMs = (uint)(_buffInfo.Duration * 1000 + leadMs); EndTime = TCPManager.GetTimeStampMS() + DurationMs; } }
private void CastAtPosition() { uint abRange = (uint)_caster.GetDistanceTo(AbInfo.TargetPosition); if (!AllowCastAtPos()) { return; } if (AbInfo.ConstantInfo.EffectDelay != 0) { ushort abEffectDelay; if (AbInfo.ConstantInfo.EffectDelay < 0) { abEffectDelay = (ushort)-AbInfo.ConstantInfo.EffectDelay; } else { abEffectDelay = AbInfo.ConstantInfo.GetDelayFor((ushort)abRange); } AbInfo.InvocationTimestamp = TCPManager.GetTimeStampMS() + abEffectDelay; } _abEffectInvoker.StartEffects(AbInfo); if (_itemCooldownGroup > 0) { _abInterface.SetItemGroupCooldown(_itemCooldownGroup, AbInfo.Cooldown); } else { _abInterface.SetCooldown(AbInfo.ConstantInfo.CooldownEntry != 0 ? AbInfo.ConstantInfo.CooldownEntry : AbInfo.Entry, AbInfo.Cooldown * 1000); } if (AbInfo.SpecialCost < 0) { Player plr = _caster as Player; if (plr != null) { plr.ResetMorale(); PacketOut Out = new PacketOut((byte)Opcodes.F_SET_ABILITY_TIMER, 12); Out.WriteUInt16(0); Out.WriteUInt16(0x200); Out.WriteUInt32(60000); Out.WriteUInt32(0); plr.SendPacket(Out); } } //SendProjectileSpeed(); SendCompleted(); if (AbInfo.ConstantInfo.Origin != AbilityOrigin.AO_ITEM) { _caster.BuffInterface.NotifyAbilityCasted(AbInfo); } Clear(); }