private void CheckUnconsciousness() { if (!IsUnconscious || Environment.InAir) { return; } var cat = AniCatalog.Unconscious; var dropJob = _Uncon == Unconsciousness.Front ? cat.DropFront : cat.DropBack; if (dropJob == null) { return; } var aa = ModelInst.GetActiveAniFromLayer(1); if (aa != null) { var job = (ScriptAniJob)aa.AniJob.ScriptObject; if (job == dropJob || job == dropJob.NextAni) { return; } var standJob = _Uncon == Unconsciousness.Front ? cat.StandUpFront : cat.StandUpBack; if (standJob != null && standJob == job) { return; } } ModelInst.StartAniJob(dropJob); }
public void DropUnconscious(long duration = -1, bool toFront = true) { var cat = AniCatalog.Unconscious; ScriptAniJob job = toFront ? cat.DropFront : cat.DropBack; if (job != null) { ModelInst.StartAniJob(job); } _Uncon = toFront ? Unconsciousness.Front : Unconsciousness.Back; var strm = BaseInst.GetScriptVobStream(); strm.Write((byte)ScriptVobMessageIDs.Uncon); strm.Write((byte)_Uncon); BaseInst.SendScriptVobStream(strm); if (duration >= 0) { if (unconTimer == null) { unconTimer = new GUCTimer(LiftUnconsciousness); } unconTimer.SetInterval(duration); unconTimer.Start(); } OnUnconChange?.Invoke(this); }
/// <summary> /// Starts an uncontrolled jump animation, throws the npc with velocity. /// </summary> /// <param name="move"></param> /// <param name="velocity"></param> public void DoJump(JumpMoves move, Vec3f velocity) { ScriptAniJob job; switch (move) { case JumpMoves.Fwd: job = AniCatalog.Jumps.Fwd; break; case JumpMoves.Run: job = AniCatalog.Jumps.Run; break; case JumpMoves.Up: job = AniCatalog.Jumps.Up; break; default: Logger.Log("Not existing jump move: " + move); return; } if (job == null) { return; } ModelInst.StartAniJobUncontrolled(job); Throw(velocity); }
/// <summary> /// Plays the draw animation and activates fight mode /// </summary> public void DoDrawFists() { ScriptAniJob drawAniJob; if (Movement == NPCMovement.Stand && !Environment.InAir && Environment.WaterLevel < 0.4f) { drawAniJob = AniCatalog.DrawFists.Draw; } else { drawAniJob = AniCatalog.DrawFists.DrawWhileRunning; } if (drawAniJob == null) { return; } if (!ModelInst.TryGetAniFromJob(drawAniJob, out ScriptAni ani)) { return; } if (!ani.TryGetSpecialFrame(0, out float drawFrame)) { drawFrame = float.MaxValue; } ModelInst.StartAniJob(drawAniJob, new FrameActionPair(drawFrame, () => SetFightMode(true))); }
private void OpenCombo() { if (Movement != NPCMovement.Stand && FightAnimation != null) { // so the npc can instantly stop the attack and run into a direction ModelInst.StopAnimation(FightAnimation, false); } else { CanCombo = true; } }
public void DoUndrawWeapon(ItemInst item) { NPCCatalog.DrawWeaponAnis catalog; switch (item.ItemType) { default: case ItemTypes.Wep1H: catalog = AniCatalog.Draw1H; break; case ItemTypes.Wep2H: catalog = AniCatalog.Draw2H; break; case ItemTypes.WepBow: catalog = AniCatalog.DrawBow; break; case ItemTypes.WepXBow: catalog = AniCatalog.DrawXBow; break; case ItemTypes.Rune: case ItemTypes.Scroll: catalog = AniCatalog.DrawMagic; break; } if (GetDrawnWeapon() == null) { } else { ScriptAniJob job = Movement == NPCMovement.Stand && !Environment.InAir ? catalog.Undraw : catalog.UndrawWhileRunning; if (job == null || !ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) // no animation { UndrawWeapon(item); } else { if (!ani.TryGetSpecialFrame(SpecialFrame.Draw, out float drawFrame)) { drawFrame = 0; } ModelInst.StartAniJob(job, new FrameActionPair(drawFrame, () => UndrawWeapon(item))); } } }
public void DoUnaim() { var drawnWeapon = GetDrawnWeapon(); ScriptAniJob job = (drawnWeapon != null && drawnWeapon.ItemType == ItemTypes.WepXBow) ? AniCatalog.FightXBow.Unaim : AniCatalog.FightBow.Unaim; if (job == null || !ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { return; } else { this.ModelInst.StartAniJob(job); } }
public bool IsAiming() { var drawnWeapon = GetDrawnWeapon(); if (drawnWeapon != null && drawnWeapon.IsWepRanged) { var aa = ModelInst.GetActiveAniFromLayer(1); if (aa != null) { var scriptJob = aa.AniJob.ScriptObject; return(scriptJob == AniCatalog.FightBow.Aiming || scriptJob == AniCatalog.FightXBow.Aiming); } } return(false); }
public void DoTakeItem(ItemInst item) { ScriptAniJob job = AniCatalog?.ItemHandling.TakeItem; if (job != null && ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { if (!ani.TryGetSpecialFrame(SpecialFrame.ItemHandle, out float frame)) { frame = float.MaxValue; } var pair = new Animations.FrameActionPair(frame, () => this.TakeItem(item)); this.ModelInst.StartAniJob(job, 0.8f, 0, pair); return; } TakeItem(item); }
public void DoDropItem(ItemInst item, int amount, Vec3f position, Angles angles) { item = item.Split(amount); ScriptAniJob job = AniCatalog?.ItemHandling.DropItem; if (job != null && ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { if (!ani.TryGetSpecialFrame(SpecialFrame.ItemHandle, out float frame)) { frame = float.MaxValue; } var pair = new Animations.FrameActionPair(frame, () => this.DropItem(item, position, angles)); this.ModelInst.StartAniJob(job, 0.8f, 0, pair); return; } DropItem(item, position, angles); }
private void DoAttack(ScriptAniJob job, FightMoves move, int fwdCombo = 0) { if (job == null) { return; } if (!ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { return; } // combo window if (!ani.TryGetSpecialFrame(SpecialFrame.Combo, out float comboFrame)) { comboFrame = ani.EndFrame; } var comboPair = new FrameActionPair(comboFrame, () => OpenCombo()); // hit frame if (!ani.TryGetSpecialFrame(SpecialFrame.Hit, out float hitFrame)) { hitFrame = comboFrame; } if (hitFrame > comboFrame) { hitFrame = comboFrame; } var hitPair = new FrameActionPair(hitFrame, () => CalcHit()); // end of animation var endPair = FrameActionPair.OnEnd(() => EndFightAni()); // start ani first, because the OnEnd-Callback from the former attack resets the fight stance FightAnimation = ModelInst.StartAniJob(job, comboPair, hitPair, endPair); CurrentFightMove = move; CanCombo = false; ComboNum = fwdCombo; }
private void DoDodge(ScriptAniJob job) { if (job == null) { return; } if (!ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { return; } // end of animation var endPair = FrameActionPair.OnEnd(() => EndFightAni()); FightAnimation = ModelInst.StartAniJob(job, endPair); CurrentFightMove = FightMoves.Dodge; CanCombo = false; ComboNum = 0; }
void DoDodge(ScriptAniJob job) { if (job == null) { return; } if (!ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { return; } // end of animation var endPair = Animations.FrameActionPair.OnEnd(() => EndFightAni()); this.fightAni = this.ModelInst.StartAniJob(job, endPair); this.currentFightMove = FightMoves.Dodge; this.canCombo = false; this.comboNum = 0; }
public void DoShoot(Vec3f start, Vec3f end, ProjInst proj) { proj.Destination = end; proj.Shooter = this; Angles rotation = Angles.FromAtVector(end - start); var p = rotation.Pitch; // rotate arrow correctly rotation.Pitch = rotation.Roll; rotation.Yaw -= Angles.PI / 2; rotation.Roll = p; proj.Spawn(this.World, start, rotation); var drawnWeapon = GetDrawnWeapon(); ScriptAniJob job = (drawnWeapon != null && drawnWeapon.ItemType == ItemTypes.WepXBow) ? AniCatalog.FightXBow.Reload : AniCatalog.FightBow.Reload; if (job != null && ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { this.ModelInst.StartAniJob(job); } }
public void DoClimb(ClimbMoves move, NPC.ClimbingLedge ledge) { ScriptAniJob job; switch (move) { case ClimbMoves.High: job = AniCatalog.Climbs.High; break; case ClimbMoves.Mid: job = AniCatalog.Climbs.Mid; break; case ClimbMoves.Low: job = AniCatalog.Climbs.Low; break; default: Logger.Log("Not existing climb move: " + move); return; } if (job == null) { return; } var stream = BaseInst.GetScriptVobStream(); stream.Write((byte)ScriptVobMessageIDs.Climb); ledge.WriteStream(stream); BaseInst.SendScriptVobStream(stream); IsClimbing = true; ModelInst.StartAniJob(job, () => IsClimbing = false); }
public void LiftUnconsciousness() { if (!IsUnconscious) { return; } var cat = AniCatalog.Unconscious; ScriptAniJob job = _Uncon == Unconsciousness.Front ? cat.StandUpFront : cat.StandUpBack; if (job != null) { ModelInst.StartAniJob(job, DoLiftUncon); } else { DoLiftUncon(); } if (unconTimer != null && unconTimer.Started) { unconTimer.Stop(); } }
public void UseItem(ItemInst item) { if (item.ItemType != ItemTypes.Drinkable) { return; } ScriptAniJob job = AniCatalog?.ItemHandling.DrinkPotion; if (job != null && ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) { if (!ani.TryGetSpecialFrame(SpecialFrame.ItemHandle, out float frame)) { frame = float.MaxValue; } EquipItem(NPCSlots.RightHand, item); var pair = new FrameActionPair(frame, () => ChugPotion(item)); ModelInst.StartAniJob(job, pair); return; } ChugPotion(item); }
private void ChangePosDir(Vec3f oldPos, Angles oldAng, NPCMovement oldMovement) { Vec3f pos = GetPosition(); var env = Environment; if (env.InAir) { if (pos.Y > highestY) { highestY = pos.Y; } } else if (highestY != 0) { float dmg = 0.14f * (highestY - pos.Y) - 135; if (dmg > 0) { Logger.Log("Damage: " + dmg); //this.SetHealth(this.HP - (int)dmg); highestY = 0; } } if (lastRegPos.GetDistance(pos) > 30.0f) { LastHitMove = GameTime.Ticks; lastRegPos = pos; } if (FightAnimation != null && CanCombo && Movement != NPCMovement.Stand) { // so the npc can instantly stop the attack and run into a direction ModelInst.StopAnimation(FightAnimation, false); } if (env.WaterLevel > 0.7f) { if (IsPlayer) { //var client = ((Arena.ArenaClient)this.Client); //client.KillCharacter(); //if (Arena.GameModes.Horde.HordeMode.IsActive && this.TeamID >= 0) //{ // Arena.GameModes.Horde.HordeMode.ActiveMode.RespawnClient(client); //} } else { SetHealth(0); } } if (env.InAir && !IsClimbing) { var aa = ModelInst.GetActiveAniFromLayer(1); if (aa != null) { ModelInst.StopAnimation(aa, false); } } CheckUnconsciousness(); }
public void DoDrawWeapon(ItemInst item) { NPCCatalog.DrawWeaponAnis catalog; switch (item.ItemType) { default: case ItemTypes.Wep1H: catalog = AniCatalog.Draw1H; break; case ItemTypes.Wep2H: catalog = AniCatalog.Draw2H; break; case ItemTypes.WepBow: catalog = AniCatalog.DrawBow; break; case ItemTypes.WepXBow: catalog = AniCatalog.DrawXBow; break; case ItemTypes.Rune: case ItemTypes.Scroll: catalog = AniCatalog.DrawMagic; break; } if (IsInFightMode || GetDrawnWeapon() != null) { /*if (this.DrawnWeapon != null) * { * ItemInst weapon = this.DrawnWeapon; * catalog = GetDrawWeaponCatalog(weapon.ItemType); * // weapon draw while running or when standing * if (this.Movement == NPCMovement.Forward || this.Movement == NPCMovement.Left || this.Movement == NPCMovement.Right) * { * this.ModelInst.StartAniJob(catalog.UndrawWhileRunning, 0.1f, () => * { * this.UnequipItem(weapon); // take weapon from hand * this.EquipItem(weapon); // place weapon into parking slot * }); * } * else * { * this.ModelInst.StartAniJob(catalog.Undraw, 0.1f, () => * { * this.UnequipItem(weapon); // take weapon from hand * this.EquipItem(weapon); // place weapon into parking slot * }); * } * } * this.SetFightMode(false);*/ } else { ScriptAniJob job = Movement == NPCMovement.Stand && !Environment.InAir ? catalog.Draw : catalog.DrawWhileRunning; if (job == null || !ModelInst.TryGetAniFromJob(job, out ScriptAni ani)) // no animation { DrawWeapon(item); } else { if (!ani.TryGetSpecialFrame(SpecialFrame.Draw, out float drawFrame)) { drawFrame = 0; } ModelInst.StartAniJob(job, new FrameActionPair(drawFrame, () => DrawWeapon(item))); } } }
public bool IsObstructed() { return(IsSpawned && (IsDead || Movement != NPCMovement.Stand || ModelInst.IsInAnimation() || Environment.InAir || IsInFightMode || IsUnconscious)); }