public void Manage(Mooege.Core.GS.Player.Player player, GameMessage gameMessage) { //Extract message information int snoPower; uint targetID; WorldPlace cursor; Actor target; int swingSide; //Target message if (gameMessage.Id == 80) { TargetMessage message = (TargetMessage)gameMessage; snoPower = message.PowerSNO; targetID = message.TargetID; cursor = message.Field2; target = player.World.GetActor(message.TargetID); swingSide = message.Field6 == null ? 0 : message.Field6.Field0; } //SecondaryAnimationPowerMessage else { SecondaryAnimationPowerMessage message = (SecondaryAnimationPowerMessage)gameMessage; snoPower = message.PowerSNO; targetID = 0; cursor = new WorldPlace(); target = player.World.GetActor(0); swingSide = 0; } if (snoPower == Skills.Skills.Barbarian.FuryGenerators.LeapAttack) // HACK: intercepted to use for spawning test mobs { //Spawn moonclan Monster monster = new Monster(player.World, 4282, new Vector3D(player.Position.X + 5f, player.Position.Y + 5f, player.Position.Z)); monster.Reveal(player); } else { // find and run a power implementation var implementation = PowerImplementation.ImplementationForId(snoPower); if (implementation != null) { // process channeled skill params bool userIsChanneling = false; bool throttledCast = false; if (_channelingActors.ContainsKey(player)) { userIsChanneling = true; if (DateTime.Now > _channelingActors[player].CastDelay) { _channelingActors[player].CastDelay = DateTime.Now.AddMilliseconds(_channelingActors[player].CastDelayAmount); } else { throttledCast = true; } } IEnumerable<int> powerExe = implementation.Run(new PowerParameters { User = player, Target = target, TargetPosition = cursor, UserIsChanneling = userIsChanneling, ThrottledCast = throttledCast, SwingSide = swingSide }, this); var powerEnum = powerExe.GetEnumerator(); // actual power will first run here, if it yielded a value process it in the waiting list if (powerEnum.MoveNext()) { AddWaitingPower(_waitingPowers, powerEnum, player); } } } }
/// <summary> /// Spawns a monster with given SNOId in given position. /// </summary> /// <param name="monsterSNOId">The SNOId of the monster.</param> /// <param name="position">The position to spawn it.</param> public void SpawnMonster(int monsterSNOId, Vector3D position) { var monster = new Monster(this, monsterSNOId, position, new Dictionary<int, Mooege.Common.MPQ.FileFormats.Types.TagMapEntry>()) { Scale = 1.35f }; this.Enter(monster); }
public void SpawnMob(Mooege.Core.GS.Player.Player player, int actorSNO, Vector3D position) { var monster = new Monster(player.World, actorSNO, position); this.Enter(monster); }
public bool UsePower(Actor user, int powerSNO, uint targetId = uint.MaxValue, Vector3D targetPosition = null, TargetMessage targetMessage = null) { Actor target; if (targetId == uint.MaxValue) { target = null; } else { target = user.World.GetActorByDynamicId(targetId); if (target == null) return false; targetPosition = target.Position; } #region Items and Monster spawn HACK // HACK: intercept hotbar skill 1 to always spawn test mobs. if (user is Player && powerSNO == (user as Player).SkillSet.HotBarSkills[4].SNOSkill) { // number of monsters to spawn int spawn_count = 10; // list of actorSNO values to pick from when spawning int[] actorSNO_values = { 4282, 3893, 6652, 5428, 5346, 6024, 5393, 5467 }; int actorSNO = actorSNO_values[RandomHelper.Next(actorSNO_values.Length - 1)]; Logger.Debug("10 monsters spawning with actor sno {0}", actorSNO); for (int n = 0; n < spawn_count; ++n) { Vector3D position; if (targetPosition.X == 0f) { position = new Vector3D(user.Position); if ((n % 2) == 0) { position.X += (float)(RandomHelper.NextDouble() * 20); position.Y += (float)(RandomHelper.NextDouble() * 20); } else { position.X -= (float)(RandomHelper.NextDouble() * 20); position.Y -= (float)(RandomHelper.NextDouble() * 20); } } else { position = new Vector3D(targetPosition); position.X += (float)(RandomHelper.NextDouble() - 0.5) * 20; position.Y += (float)(RandomHelper.NextDouble() - 0.5) * 20; position.Z = user.Position.Z; } Monster mon = new Monster(user.World, actorSNO, null); mon.Position = position; mon.Scale = 1.35f; mon.Attributes[GameAttribute.Hitpoints_Max_Total] = 5f; mon.Attributes[GameAttribute.Hitpoints_Max] = 5f; mon.Attributes[GameAttribute.Hitpoints_Total_From_Level] = 0f; mon.Attributes[GameAttribute.Hitpoints_Cur] = 5f; user.World.Enter(mon); } // spawn some useful items for testing at the ground of the player if (!_spawnedHelperItems) { _spawnedHelperItems = true; Items.ItemGenerator.Cook((Players.Player)user, "Sword_2H_205").EnterWorld(user.Position); Items.ItemGenerator.Cook((Players.Player)user, "Crossbow_102").EnterWorld(user.Position); for (int n = 0; n < 30; ++n) Items.ItemGenerator.Cook((Players.Player)user, "Runestone_Unattuned_07").EnterWorld(user.Position); } return true; } #endregion // find and run a power implementation var implementation = PowerLoader.CreateImplementationForPowerSNO(powerSNO); if (implementation != null) { implementation.PowerSNO = powerSNO; return UsePower(user, implementation, target, targetPosition, targetMessage); } else { return false; } }
public bool RunPower(Actor user, int powerSNO, uint targetId = uint.MaxValue, Vector3D targetPosition = null, TargetMessage targetMessage = null) { Actor target; if (targetId == uint.MaxValue) { target = null; } else { target = user.World.GetActorByDynamicId(targetId); if (target == null) return false; targetPosition = target.Position; } #region Items and Monster spawn HACK // HACK: intercept hotbar skill 1 to always spawn test mobs. if (user is Player && powerSNO == (user as Player).SkillSet.HotBarSkills[4].SNOSkill) { // number of monsters to spawn int spawn_count = 3; // list of actorSNO values to pick from when spawning int[] actorSNO_values = { 5387, 6652, 5346 }; int actorSNO = actorSNO_values[RandomHelper.Next(actorSNO_values.Length)]; Logger.Debug("3 monsters spawning with actor sno {0}", actorSNO); for (int n = 0; n < spawn_count; ++n) { Vector3D position; if (targetPosition.X == 0f) { position = new Vector3D(user.Position); if ((n % 2) == 0) { position.X += (float)(RandomHelper.NextDouble() * 20); position.Y += (float)(RandomHelper.NextDouble() * 20); } else { position.X -= (float)(RandomHelper.NextDouble() * 20); position.Y -= (float)(RandomHelper.NextDouble() * 20); } } else { position = new Vector3D(targetPosition); position.X += (float)(RandomHelper.NextDouble() - 0.5) * 20; position.Y += (float)(RandomHelper.NextDouble() - 0.5) * 20; position.Z = user.Position.Z; } Monster mon = new Monster(user.World, actorSNO, null); mon.SetBrain(new Mooege.Core.GS.AI.Brains.MonsterBrain(mon)); mon.Position = position; mon.Scale = 1.35f; mon.Attributes[GameAttribute.Hitpoints_Max_Total] = 5f; mon.Attributes[GameAttribute.Hitpoints_Max] = 5f; mon.Attributes[GameAttribute.Hitpoints_Total_From_Level] = 0f; mon.Attributes[GameAttribute.Hitpoints_Cur] = 5f; mon.Attributes[GameAttribute.Attacks_Per_Second_Total] = 1.0f; mon.Attributes[GameAttribute.Damage_Weapon_Min_Total, 0] = 5f; mon.Attributes[GameAttribute.Damage_Weapon_Delta_Total, 0] = 7f; mon.Attributes[GameAttribute.Casting_Speed_Total] = 1.0f; user.World.Enter(mon); } // spawn some useful items for testing at the ground of the player if (!_spawnedHelperItems) { _spawnedHelperItems = true; Items.ItemGenerator.Cook((Players.Player)user, "Sword_2H_205").EnterWorld(user.Position); Items.ItemGenerator.Cook((Players.Player)user, "Crossbow_102").EnterWorld(user.Position); for (int n = 0; n < 30; ++n) Items.ItemGenerator.Cook((Players.Player)user, "Runestone_Unattuned_07").EnterWorld(user.Position); } return true; } #endregion // find and run a power implementation var implementation = PowerLoader.CreateImplementationForPowerSNO(powerSNO); if (implementation != null) { return RunPower(user, implementation, target, targetPosition, targetMessage); } else { // no power script is available, but try to play the cast effects var efgTag = Mooege.Core.GS.Common.Types.TagMap.PowerKeys.CastingEffectGroup_Male; var tagmap = PowerTagHelper.FindTagMapWithKey(powerSNO, efgTag); if (tagmap != null) user.PlayEffectGroup(tagmap[efgTag].Id); return false; } }