public static void CalculateRegenTick(LivingObject lobj) { if (lobj.ObjectType == OBJECTTYPE.PLAYER) { PlayerObject pobj = (PlayerObject)lobj; float ticktime = 3.0f; float baseregenpower = 0.1f; float baseregenhealth = 0.1f; float powerregen = pobj.BaseSpirit * baseregenpower * ticktime; float healthregen = pobj.BaseSpirit * baseregenhealth * ticktime; if (pobj.StandState != UNITSTANDSTATE.SITTING) { healthregen = healthregen / 3; powerregen = powerregen / 3; } pobj.Health += (int)healthregen; if (pobj.Health > pobj.MaxHealth) { pobj.Health = pobj.MaxHealth; } pobj.Power += (int)powerregen; if (pobj.Power > pobj.MaxPower) { pobj.Power = pobj.MaxPower; } } else { UnitBase uobj = (UnitBase)lobj; float ticktime = 3.0f; float baseregenhealth = 0.1f; float healthregen = (20.0f + ((float)uobj.Level / 3.0f)) * baseregenhealth * ticktime; if (uobj.Attacking) { healthregen = healthregen / 3; } uobj.Health += (int)healthregen; if (uobj.Health > uobj.MaxHealth) { uobj.Health = uobj.MaxHealth; } } }
void WalkToVector(Vector v, int time, UnitBase unit) { ServerPacket pkg = new ServerPacket(SMSG.MONSTER_MOVE); pkg.Write(unit.GUID); pkg.WriteVector(unit.Position); pkg.Write(unit.Facing); pkg.Write((byte)0); pkg.Write(0x000); pkg.Write(time); pkg.Write(1); pkg.WriteVector(v); pkg.Finish(); unit.MapTile.SendSurrounding(pkg); }
public static int CalculateExp(UnitBase uobj, PlayerObject player) { double exp = (200 * uobj.Level); // TODO: Have to modify this so its on each person that hits the mob not just the killer. /*double mod = 1f; * if (Math.Abs(uobj.Level - player.Level) < 5) * mod = (5-(player.Level-uobj.Level))*0.2; * else if (uobj.Level > player.Level) * mod = 2; * else * mod = 0; * exp *= mod;*/ return((int)exp); }
void AddNode(Vector position, UnitBase unit) { if (unit.RoamingNodes == null) { unit.RoamingNodes = new ArrayList(10); } for (int i = 0; i < unit.RoamingNodes.Count; i++) { Vector v = (Vector)(unit.RoamingNodes[i]); if (v.X == position.X && v.Y == position.Y && v.Z == position.Z) { return; } } unit.RoamingNodes.Add(new Vector(position.X, position.Y, position.Z)); }
public override void FireEvent() { try { if (aclient.Player == null) { this.Kill(); return; } attacker = aclient.Player; attacker.InRound = false; target = (LivingObject)ObjectManager.GetWorldObjectByGUID(aclient.Player.Target); if (attacker.Dead) { this.Kill(); return; } if ((!attacker.Attacking) || target.Dead) { this.Kill(); return; } //Console.WriteLine("Fire combat event attacker: " + attacker.Name + " -> " + target.Name); float angle = (float)(aclient.Player.Position.Angle(target.Position) * 180 / Math.PI); float facing = (float)(aclient.Player.Facing * 180 / Math.PI) % 360; if (angle < 0) { angle += 360; } // Try to normalize so that foc (field of combat) // is between 30 and -30 deg float dif = (angle - facing) % 360; if (dif > 180) { dif = 360 - dif; } if (Math.Abs(dif) > 35) { //Console.WriteLine("Look where you are fighting: " + attacker.Name + " -> " + target.Name); } else { uint hitflag; uint victimstate; int damage; int blocked; StatManager.CalculateMeleeDamage(attacker, target, out hitflag, out victimstate, out damage, out blocked); if (aclient.Player.Position.Distance(target.Position) + aclient.Player.Position.Distance(aclient.Player.LastPosition) <= 2.5) //So they dont get free hits from 20 feet away { attacker.InRound = true; ServerPacket pkg2 = new ServerPacket(SMSG.ATTACKERSTATEUPDATE); pkg2.Write((uint)hitflag); pkg2.Write(attacker.GUID); pkg2.Write(target.GUID); pkg2.Write((int)damage); pkg2.Write((byte)1); pkg2.Write((uint)0); pkg2.Write((float)damage); pkg2.Write((int)damage); pkg2.Write((int)0); pkg2.Write((uint)victimstate); pkg2.Write((uint)0); pkg2.Write((uint)0); pkg2.Write((uint)0); pkg2.Write((int)blocked); pkg2.Finish(); attacker.MapTile.Map.Send(pkg2, attacker.Position, 25.0f); if (target.ObjectType == OBJECTTYPE.UNIT) { UnitBase uobj = (UnitBase)target; uobj.DealDamage(attacker, damage); if (uobj.Dead) { attacker.StopCombat(); } } } else { //Console.WriteLine("Your are to far away to hit mob: " + attacker.Name + " -> " + target.Name); } } aclient.Player.LastPosition = aclient.Player.Position; int nextEvent = (attacker.InRound?attacker.BaseAttackTime:1000); eventTime = DateTime.Now.Add(TimeSpan.FromMilliseconds(nextEvent)); EventManager.AddEvent(this); return; } catch (Exception e) { this.Kill(); Console.WriteLine("This exception happened in Combat Event. Probably, someone just disconnected while in combat. It won't crash server though!"); Console.WriteLine(e); return; } }
public RandomWalkEvent(UnitBase unit, PlayerObject player) : base(TimeSpan.FromSeconds(1)) { m_unit = unit; m_player = player; }
void GetWalkNode(UnitBase unit, PlayerObject player) { AddNode(player.Position, unit); }
public AgroManagementEvent(UnitBase mob) : base(TimeSpan.FromSeconds(2)) { m_mob = mob; }
public ChasingEvent(UnitBase mob) : base(TimeSpan.FromMilliseconds(0)) { this.mob = mob; currenttarget = 0; }
public MobsRegenEvent(UnitBase mobs) : base(TimeSpan.FromSeconds(3)) { m_mobs = mobs; }
public MobsRespawnEvent(UnitBase mobs) : base(TimeSpan.FromSeconds(mobs.RespawnTime)) { m_mobs = mobs; }
public CorpseDespawnEvent(UnitBase corpse) : base(TimeSpan.FromSeconds(30)) { m_corpse = corpse; }
public CombatEvent(UnitBase monster) : base(TimeSpan.FromMilliseconds(1)) { attacker = monster; aclient = (WorldClient)WorldServer.GetClientByCharacterID((uint)attacker.Target); //Console.WriteLine("New combat event attacker: " + attacker.Name + " -> " + aclient.Player.Name); }
public static void CalculateNewStats(LivingObject lobj) { if (lobj.ObjectType == OBJECTTYPE.PLAYER) { PlayerObject pobj = (PlayerObject)lobj; BaseStats stats = BaseStats.GetBaseStats(pobj); pobj.MaxHealth = stats.Health; pobj.MaxPower = stats.Power; pobj.BaseStrength = stats.Strength; pobj.BaseStamina = stats.Stamina; pobj.BaseAgility = stats.Agility; pobj.BaseIntellect = stats.Intellect; pobj.BaseSpirit = stats.Spirit; CalculateInvStats(pobj); } else if (lobj.ObjectType == OBJECTTYPE.UNIT) { UnitBase uobj = (UnitBase)lobj; int basehealth = 60; int basestamina = Convert.ToInt32(((float)lobj.Level * ((float)lobj.Level * 0.2f)) - 1); if (basestamina < (uobj.Level - 1)) { basestamina = uobj.Level - 1; } int health = basehealth + (basestamina * 10); if (uobj.Level < 10) { switch (uobj.Level) { case 1: uobj.BaseAttackTime = 2000; uobj.MinDamage = (float)2.0; uobj.MaxDamage = (float)4.0; break; case 2: uobj.BaseAttackTime = 2600; uobj.MinDamage = (float)3.0; uobj.MaxDamage = (float)6.0; break; case 3: uobj.BaseAttackTime = 2200; uobj.MinDamage = (float)3.0; uobj.MaxDamage = (float)6.0; break; case 4: uobj.BaseAttackTime = 2000; uobj.MinDamage = (float)3.0; uobj.MaxDamage = (float)6.0; break; case 5: uobj.BaseAttackTime = 1800; uobj.MinDamage = (float)3.0; uobj.MaxDamage = (float)6.0; break; case 6: uobj.BaseAttackTime = 2100; uobj.MinDamage = (float)4.0; uobj.MaxDamage = (float)8.0; break; case 7: uobj.BaseAttackTime = 1950; uobj.MinDamage = (float)4.0; uobj.MaxDamage = (float)8.0; break; case 8: uobj.BaseAttackTime = 1800; uobj.MinDamage = (float)4.0; uobj.MaxDamage = (float)8.0; break; case 9: uobj.BaseAttackTime = 2200; uobj.MinDamage = (float)5.0; uobj.MaxDamage = (float)10.0; break; } } else { uobj.BaseAttackTime = 2000; uobj.MinDamage = (float)uobj.Level / (float)2.0; uobj.MaxDamage = (float)uobj.Level; } uobj.MaxHealth = health; uobj.MaxPower = 0; } }
public static void GenerateMobLoot(UnitBase uobj) { uobj.Money = m_lootrandom.Next((int)1 + uobj.Level, (int)10 + uobj.Level * 3); }