public RiftClient(TCPManager Server) : base(Server) { Random random = new Random(); byte[] randomKey = new byte[128]; random.NextBytes(randomKey); Array.Resize(ref randomKey, randomKey.Length + 1); mLocalPrivateKey = new BigInteger(randomKey); mLocalPublicKey = BigInteger.ModPow(GENERATOR, mLocalPrivateKey, MODULUS); }
public void HandleEvent(Player player, Objective_Type type, uint entry, int count, ushort contributionGain, string pqGoClicked = null) { if (Stage == null) { return; } byte objid = 0; string objectID = "0"; foreach (PQuestObjective obj in Stage.Objectives) { if (obj.IsDone()) { objid++; continue; } if (obj.Objective.Type != (int)type) { objid++; continue; } int oldCount = obj.Count; switch (type) { case Objective_Type.QUEST_SPEAK_TO: case Objective_Type.QUEST_KILL_MOB: uint outVal = 0; //More than one type of NPC can count to the same PQ objective kill count if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId) == entry)) { objectID = obj.Objective.ObjectId; obj.Count += count; break; } if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId2, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId2) == entry)) { objectID = obj.Objective.ObjectId2; obj.Count += count; break; } if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId3, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId3) == entry)) { objectID = obj.Objective.ObjectId3; obj.Count += count; break; } if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId4) == entry)) { objectID = obj.Objective.ObjectId4; obj.Count += count; break; } if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId5) == entry)) { objectID = obj.Objective.ObjectId4; obj.Count += count; break; } if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId6) == entry)) { objectID = obj.Objective.ObjectId4; obj.Count += count; break; } break; case Objective_Type.QUEST_PROTECT_UNIT: if (obj.Objective.Creature != null && entry == obj.Objective.Creature.Entry) { obj.Count += count; } break; case Objective_Type.QUEST_USE_GO: if (obj.Objective.GameObject != null && entry == obj.Objective.GameObject.Entry) { // This will turn off Interactable flag on clicked GO, some more work can be // done with GO despawning and UNKs[3] unk modification // Default respawn time: 60 seconds Object target = player.CbtInterface.GetCurrentTarget(); if (target != null) { GameObject go = target.GetGameObject(); if (go != null && go.IsGameObject()) { if (go.Spawn.AllowVfxUpdate == 1) { go.VfxState = 1; } go.Interactable = false; go.EvtInterface.AddEvent(MakeGOInteractable, 60000, 1, target); } } obj.Count += count; } break; case Objective_Type.QUEST_KILL_GO: if (obj.Objective.GameObject != null && entry == obj.Objective.GameObject.Entry) { obj.Count += count; } break; case Objective_Type.QUEST_UNKNOWN: if (obj.Objective.Guid == entry) { obj.Count += count; } break; } if (obj.Count != oldCount) { if (player != null) { uint influenceid; if (Info.Type == 0 && player.CurrentArea != null) { if (player.Realm == GameData.Realms.REALMS_REALM_ORDER) { influenceid = player.CurrentArea.OrderInfluenceId; } else { influenceid = player.CurrentArea.DestroInfluenceId; } } else // normaly we should only use the area inf but to not break every pq we keep it like this for now { influenceid = Info.ChapterId; } if (player.WorldGroup == null) { player.AddInfluence((ushort)influenceid, (ushort)(100)); } else { player.WorldGroup.AddInfluenceCount(player, (ushort)influenceid, (ushort)(100 * player.WorldGroup.GetPlayersCloseTo(player, 300).Count)); } if (!Players.ContainsKey(player.CharacterId)) { Players.Add(player.CharacterId, new ContributionInfo(player)); } if (Players.ContainsKey(player.CharacterId)) { Players[player.CharacterId].BaseContribution += contributionGain; Players[player.CharacterId].ActiveTimeEnd = TCPManager.GetTimeStamp() + 5; } } else { foreach (uint plr in ActivePlayers) { if (Players.ContainsKey(plr)) { Players[plr].BaseContribution += contributionGain; } } } foreach (uint plr in ActivePlayers) { Player targPlayer = Player.GetPlayer(plr); if (targPlayer != null) { PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_UPDATE); Out.WriteUInt32(Info.Entry); Out.WriteByte(1); Out.WriteByte(Info.Type); //realm Out.WriteUInt32(UInt32.Parse(Stage.Objectives.First().Objective.ObjectId)); //ephermal id, sent in main packet for PQ_INFO Out.WriteByte(objid); //index of objective to update Out.WriteUInt16((ushort)obj.Count); // new total targPlayer.SendPacket(Out); } } } objid++; } if (Stage.IsDone()) { NextStage(); } }
public void SendCurrentStage(Player player) { player.QtsInterface.UpdateObjects(); if (Stage == null) { //Log.Error("Public Quest Object", "No Stage!"); return; } if (_ended) { PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO); Out.WriteUInt32(Info.Entry); Out.WriteByte(1); Out.WriteByte(0); Out.WriteByte(1); // 1 1 condition 2 or condition Out.WriteUInt16(0); Out.WritePascalString(Info.Name); Out.WriteUInt32((UInt32)(_stageTimeEnd - TCPManager.GetTimeStamp())); // time left Out.Fill(0, 4); player.SendPacket(Out); } else { PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO); Out.WriteUInt32(Info.Entry); Out.WriteByte(0); // Type Out.WriteByte(Info.Type); Out.WriteByte(1); // 1 1 condition 2 or condition Out.WriteUInt16(0); Out.WritePascalString(Info.Name); Out.WriteByte(Info.Type); Out.WriteUInt32(UInt32.Parse(Stage.Objectives.First().Objective.ObjectId)); Out.WriteByte(0); Out.WriteByte((byte)Stage.Objectives.Count); byte i = 0; foreach (PQuestObjective obj in Stage.Objectives) { Out.WriteByte(i); Out.WriteUInt16((ushort)obj.Objective.Count); // kill count Out.WriteUInt16((ushort)obj.Count); Out.WriteByte(0); Out.WritePascalString(obj.Objective.Objective); i++; } Out.WriteByte((byte)(Info.PQDifficult > 0 ? (Info.PQDifficult - 1) : 0 - 1)); // difficulty 0 - 2 Out.WriteByte(0); Out.WritePascalString(Stage.StageName); Out.WriteByte(0); Out.WritePascalString(Stage.Objectives.First().Objective.Description); Out.WriteUInt16(0); if (Stage.Number == 0) { Out.WriteUInt16(0); } else { Out.WriteUInt16(1); } Out.WriteUInt32((UInt32)(_stageTimeEnd - TCPManager.GetTimeStamp())); // time left Out.WriteUInt32(0); Out.WriteByte(0x48); Out.WriteUInt32(0); player.SendPacket(Out); if (player.DebugMode) { player.SendLocalizeString("PQ STAGE ID: " + Stage.Objectives.First().ObjectiveID, ChatLogFilters.CHATLOGFILTERS_ALLIANCE, GameData.Localized_text.CHAT_TAG_MONSTER_EMOTE); } } }
/// <summary> /// Dishes out contribution earned from this mob. /// </summary> /// <param name="mob"></param> public void NotifyKilled(PQuestCreature mob) { float totalDamageDealt = 1.0f; float totalHits = 0; int damagedCount = 0; // Handle contribution to the PQ. int rankMod; switch (mob.Rank) { case 1: rankMod = 4; break; case 2: rankMod = 20; break; default: rankMod = 1; break; } #region For having taken damage foreach (ContributionInfo plrInfo in Players.Values) { if (plrInfo.DamageTakenFrom.ContainsKey(mob.Oid)) { damagedCount++; totalDamageDealt += plrInfo.DamageTakenFrom[mob.Oid].DamageTaken; totalHits += plrInfo.DamageTakenFrom[mob.Oid].NumHits; } } foreach (ContributionInfo tankerInfo in Players.Values) { if (tankerInfo.DamageTakenFrom.ContainsKey(mob.Oid)) { Player targPlayer = Player.GetPlayer(tankerInfo.PlayerCharId); float scaler = tankerInfo.DamageTakenFrom[mob.Oid].NumHits / totalHits; if (targPlayer != null && targPlayer.CrrInterface.GetArchetype() != EArchetype.ARCHETYPE_Tank && totalHits < 6) { scaler *= totalHits / 6; } if (targPlayer != null) { SplitContribution(targPlayer, (ushort)(100 * rankMod * scaler)); //targPlayer.SendClientMessage("Received " + (ushort)(100 * rankMod * scaler) + " contribution from tanking damage.", ChatLogFilters.CHATLOGFILTERS_QUEST, true); } tankerInfo.ActiveTimeEnd = TCPManager.GetTimeStamp() + 5; } } #endregion #region For healers of damage float totalHealing = 0; if (_playerHealing.ContainsKey(mob.Oid)) { Dictionary <uint, uint> mobHealing = _playerHealing[mob.Oid]; foreach (uint healing in mobHealing.Values) { totalHealing += healing; } foreach (uint Plr in ActivePlayers) { Player targPlayer = Player.GetPlayer(Plr); if (targPlayer != null) { if (mobHealing.ContainsKey(targPlayer.CharacterId)) { if (!Players.ContainsKey(targPlayer.CharacterId)) { Players.Add(targPlayer.CharacterId, new ContributionInfo(targPlayer)); } if (Players.ContainsKey(targPlayer.CharacterId)) { SplitContribution(targPlayer, (ushort)(mobHealing[targPlayer.CharacterId] / totalHealing * rankMod * 100)); //targPlayer.SendClientMessage("Received " + (ushort)(mobHealing[targPlayer.CharacterId] / totalHealing * rankMod * 100) + " contribution from healing other players.", ChatLogFilters.CHATLOGFILTERS_QUEST, true); Players[targPlayer.CharacterId].ActiveTimeEnd = TCPManager.GetTimeStamp() + 5; } } } } } #endregion float leftoverFactor = 1f - totalHealing / totalDamageDealt; if (leftoverFactor > 0) { foreach (ContributionInfo plrInfo in Players.Values) { if (plrInfo.DamageTakenFrom.ContainsKey(mob.Oid)) { plrInfo.HealingDamagePool += (uint)(totalDamageDealt * (leftoverFactor / damagedCount)); plrInfo.HealingContribPool += (uint)(100 * rankMod * (leftoverFactor / damagedCount)); plrInfo.DamageTakenFrom.Remove(mob.Oid); } } } _playerHealing.Remove(mob.Oid); }
private void SpawnNPCFromGO(Unit killer = null) { long now = TCPManager.GetTimeStampMS(); if (now > CreatureSpawnCooldown) { Random rand = new Random(); Creature_proto Proto = CreatureService.GetCreatureProto(this.Spawn.Proto.CreatureId); for (int i = 0; i < this.Spawn.Proto.CreatureCount; i++) // CreatureCount - how many creatures are spawned { Creature_spawn CreSpawn = new Creature_spawn(); CreSpawn.Guid = (uint)CreatureService.GenerateCreatureSpawnGUID(); CreSpawn.BuildFromProto(Proto); CreSpawn.WorldO = this.Spawn.WorldO; CreSpawn.WorldX = (int)(this.Spawn.WorldX + 50 - 150 * rand.NextDouble()); CreSpawn.WorldY = (int)(this.Spawn.WorldY + 50 - 150 * rand.NextDouble()); CreSpawn.WorldZ = this.Spawn.WorldZ; CreSpawn.ZoneId = this.Spawn.ZoneId; Creature c = null; if (killer != null && killer is Player) { c = killer.Region.CreateCreature(CreSpawn); } else { c = this.Region.CreateCreature(CreSpawn); } if (this.Spawn.Proto.CreatureCooldownMinutes > 0) { CreatureSpawnCooldown = TCPManager.GetTimeStampMS() + (int)this.Spawn.Proto.CreatureCooldownMinutes * 60000; // Cannot be spawned more often than once per respawn time c.EvtInterface.AddEventNotify(EventName.OnDie, RemoveNPC); c.EvtInterface.AddEvent(c.Destroy, (int)this.Spawn.Proto.CreatureCooldownMinutes * 60000, 1); // Creature goes away after the respawn time this.EvtInterface.AddEvent(EventSendMeTo, (int)this.Spawn.Proto.CreatureCooldownMinutes * 60000, 1); } else { CreatureSpawnCooldown = TCPManager.GetTimeStampMS() + 120000; // Creature cannot be spawned more than once every 120 second if it is normal NPC c.EvtInterface.AddEventNotify(EventName.OnDie, RemoveNPC); c.EvtInterface.AddEvent(c.Destroy, 120000, 1); // Creature goes away after 2 minutes this.EvtInterface.AddEvent(EventSendMeTo, 120000, 1); } var prms = new List <object>() { c, Spawn.Proto.CreatureSpawnText }; if (!String.IsNullOrEmpty(this.Spawn.Proto.CreatureSpawnText)) // It is possible to allow the GO to say something after the NPCs spawned //if (c != null) { EvtInterface.AddEvent(DelayedSay, 500, 1, prms); } //c.Say(this.Spawn.Proto.CreatureSpawnText, ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); } /*if (!String.IsNullOrEmpty(this.Spawn.Proto.CreatureSpawnText)) // It is possible to allow the GO to say something after the NPCs spawned * this.Say(this.Spawn.Proto.CreatureSpawnText, ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);*/ // This check if the GO we clicked is a Door - if it is we don't want to mess with its // VFXState because we can break it if (this.Spawn.DoorId == 0) { this.EvtInterface.AddEvent(EventSendMeTo, 60000, 1); if (this.Spawn.AllowVfxUpdate == 1) { this.VfxState = 1; } foreach (Player plr in PlayersInRange) { this.UpdateVfxState(this.VfxState); } } } else { this.Say("**You must wait a little longer...**", ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); } }
public override void Think(long tick) { base.Think(tick); if (_unit.IsDead) { return; } if ((FriendlyTarget == null)) { var friendlyPlayers = _unit.GetInRange <Unit>(120).Where(x => x.Realm == _unit.Realm && x.PctHealth < 100).OrderBy(o => o.PctHealth).ToList(); if (friendlyPlayers.Count() > 0) { _logger.Debug($"{_unit} changing friendly target to {(friendlyPlayers[0]).Name}"); SpeakYourMind($"{_unit.Name} friendly target=> {(friendlyPlayers[0]).Name}"); FriendlyTarget = friendlyPlayers[0]; } } if (_unit.AbtInterface.CanCastCooldown(0) && TCPManager.GetTimeStampMS() > NextTryCastTime) { Combat.SetTarget(FriendlyTarget.Oid, TargetTypes.TARGETTYPES_TARGET_ALLY); var rand = StaticRandom.Instance.Next(10); switch (rand) { case 0: { //Rune of Regeneration SimpleCast(_unit, FriendlyTarget, "Rune of Regeneration", 1590); break; } case 1: { //Rune of Mending SimpleCast(_unit, FriendlyTarget, "Rune of Mending", 1599); break; } case 2: { //Rune of Shielding if (runeofShieldingCooldown < FrameWork.TCPManager.GetTimeStamp()) { SimpleCast(_unit, FriendlyTarget, "Rune of Shielding", 1593); runeofShieldingCooldown = FrameWork.TCPManager.GetTimeStamp() + 20; // available in another 20 seconds } break; } case 3: { // 1587 - Grungni's Gift SimpleCast(_unit, FriendlyTarget, "Grungni's Gift", 1587); break; } case 4: case 5: case 6: { var friendlyPlayers = _unit.GetInRange <Unit>(120).Where(x => x.Realm == _unit.Realm && x.PctHealth < 100).OrderBy(o => o.PctHealth).ToList(); if (friendlyPlayers.Count() > 0) { _logger.Debug($"{_unit} changing friendly target to {(friendlyPlayers[0]).Name}"); FriendlyTarget = friendlyPlayers[0]; } break; } } NextTryCastTime = TCPManager.GetTimeStampMS() + NEXT_ATTACK_COOLDOWN; } }
public Client(TCPManager srv) : base(srv) { }
public Client(TCPManager srv) : base(srv) { RSACryptoServiceProvider Prov = new RSACryptoServiceProvider(); }
/// <summary> /// Sends objective's detailed info in upper right corner of the screen. /// </summary> /// <param name="plr"></param> public void SendFlagInfo(Player plr) { // return; var owningRealm = OwningRealm; var assaultingRealm = AssaultingRealm; if (_tier == 4) { var prFrnt = (ProximityProgressingBattlefront)Region.Bttlfront; if (prFrnt != null && ZoneId != prFrnt.Zones[prFrnt._battlefrontStatus.OpenZoneIndex].ZoneId) { owningRealm = OwningRealm; assaultingRealm = OwningRealm; } } // Log.Info("Name", ID.ToString()); // Log.Info("OwningRealm", Enum.GetName(typeof(Realms), owningRealm)); // Log.Info("AssaultingRealm", Enum.GetName(typeof(Realms), assaultingRealm)); var Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO, 32); Out.WriteUInt32((uint)Id); Out.WriteByte(0); Out.WriteByte((byte)owningRealm); //(byte)OwningRealm Out.WriteByte(1); Out.WriteUInt16(0); Out.WritePascalString(Name); // // // Out.WriteByte(2); Out.WriteUInt32(0x0000348F); Out.WriteByte((byte)assaultingRealm); // (byte)AssaultingRealm // Expansion for objective goal Out.WriteByte(0); Out.WriteUInt16(0xFF00); Out.WritePascalString(GetStateText(plr.Realm)); Out.WriteByte(0); switch (State) { case StateFlags.ZoneLocked: case StateFlags.Locked: Out.WritePascalString("This area has been captured by ", GetRealmString(OwningRealm), ". The battle wages on elsewhere!"); break; case StateFlags.Contested: if (plr.Realm != OwningRealm) { Out.WritePascalString("This Battlefield Objective is being assaulted by ", GetRealmString(AssaultingRealm), ". Ensure the timer elapses to claim it for your Realm!"); } else { Out.WritePascalString("This Battlefield Objective is being assaulted by ", GetRealmString(AssaultingRealm), ". Reclaim this Battlefield Objective for ", GetRealmString(plr.Realm), "!"); } break; case StateFlags.Secure: if (plr.Realm == OwningRealm) { Out.WritePascalString("This Battlefield Objective is generating resources for ", GetRealmString(OwningRealm), ". Defend the flag from enemy assault!"); } else { Out.WritePascalString("This Battlefield Objective is generating resources for ", GetRealmString(OwningRealm), ". Claim this Battlefield Objective for ", GetRealmString(plr.Realm), "!"); } break; case StateFlags.Unsecure: Out.WritePascalString("This Battlefield Objective is open for capture!"); break; default: Out.WritePascalString(""); break; } // Displayed transition timer in seconds var transitionTimer = _nextTransitionTimestamp == 0 ? (ushort)0 : (ushort)((_nextTransitionTimestamp - TCPManager.GetTimeStampMS()) / 1000); transitionTimer = (ushort)_displayedTimer; // Log.Info("transitionTimer", _displayedTimer.ToString()); Out.WriteUInt16(0); // _displayedTimer Out.WriteUInt16((ushort)_displayedTimer); // _displayedTimer Out.WriteUInt16(0); // _displayedTimer Out.WriteUInt16((ushort)_displayedTimer); // _displayedTimer Out.Fill(0, 4); Out.WriteByte(0x71); Out.WriteByte(1); Out.Fill(0, 3); plr.SendPacket(Out); }
public static TCPProcessCmdResults ProcessAdvanceLingYuLevel( TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; string[] fields = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket))); return(TCPProcessCmdResults.RESULT_FAILED); } try { fields = cmdData.Split(':'); //角色id:翎羽Type:材料不足时消耗钻石 if (fields.Length != 3) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length)); return(TCPProcessCmdResults.RESULT_FAILED); } int roleID = Convert.ToInt32(fields[0]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (null == client || client.ClientData.RoleID != roleID) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID)); return(TCPProcessCmdResults.RESULT_FAILED); } int type = Convert.ToInt32(fields[1]); int useZuanshiIfNoMaterial = Convert.ToInt32(fields[2]); LingYuError lyError = LingYuManager.AdvanceLingYuLevel(client, roleID, type, useZuanshiIfNoMaterial); LingYuData lyData = null; lock (client.ClientData.LingYuDict) { if (!client.ClientData.LingYuDict.TryGetValue(type, out lyData)) { lyData = new LingYuData(); lyData.Type = type; lyData.Level = DEFAULT_LINGYU_LEVEL; lyData.Suit = 0; } } string strcmd = string.Format("{0}:{1}:{2}:{3}", roleID, (int)lyError, lyData.Type, lyData.Level); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "ProcessAdvanceLingYuLevel", false); } return(TCPProcessCmdResults.RESULT_DATA); }
/// <summary> /// Distributes the loot and contribution rewards for this particular NPC. /// </summary> /// <param name="killer"></param> protected override void HandleDeathRewards(Player killer) { Dictionary <Group, XpRenown> groupXPRenown = new Dictionary <Group, XpRenown>(); uint totalXP = WorldMgr.GenerateXPCount(killer, this); RemoveDistantDamageSources(); if (DamageSources.Count == 0 || TotalDamageTaken == 0) { return; } Player looter = null; uint bestDamage = 0; foreach (KeyValuePair <Player, uint> kvpair in DamageSources) { Player curPlayer = kvpair.Key; if (curPlayer == null) { continue; } float damageFactor = (float)kvpair.Value / TotalDamageTaken; uint xpShare = (uint)(totalXP * damageFactor); // Handle contribution to the PQ. int rankMod; switch (Rank) { case 1: rankMod = 4; break; case 2: rankMod = 20; break; default: rankMod = 1; break; } _publicQuest.HandleEvent(curPlayer, Objective_Type.QUEST_KILL_MOB, Spawn.Entry, bestDamage == 0 ? 1 : 0, (ushort)(100 * damageFactor * rankMod)); curPlayer.SendClientMessage("Received " + 100 * damageFactor * rankMod + " contribution for dealing damage.", ChatLogFilters.CHATLOGFILTERS_QUEST, true); // Solo player, add their rewards directly. if (curPlayer.PriorityGroup == null) { curPlayer.AddXp(xpShare, true, true); if (kvpair.Value > bestDamage) { looter = curPlayer; bestDamage = kvpair.Value; } } else { if (groupXPRenown.ContainsKey(curPlayer.PriorityGroup)) { groupXPRenown[curPlayer.PriorityGroup].XP += xpShare; } else { groupXPRenown.Add(curPlayer.PriorityGroup, new XpRenown(xpShare, 0, 0, 0, TCPManager.GetTimeStampMS())); } groupXPRenown[curPlayer.PriorityGroup].Damage += kvpair.Value; if (groupXPRenown[curPlayer.PriorityGroup].Damage > bestDamage) { looter = curPlayer; bestDamage = kvpair.Value; } } } if (groupXPRenown.Count > 0) { foreach (KeyValuePair <Group, XpRenown> kvpair in groupXPRenown) { kvpair.Key.AddXpCount(killer, kvpair.Value.XP); } } if (looter != null) { GenerateLoot(looter, 1f); } CreditQuestKill(looter); _publicQuest.NotifyKilled(this); }
public void Fire(Player player, ushort targetID, ushort targetX, ushort targetY, ushort targetZ, ushort zoneId, ushort power) { if (!HasPlayer(player) || !_weapon.AbtInterface.CanCastCooldown(_abilityId)) { return; } // RB 6/25/2016 Reset timer before death every time the siege is fired _deathTime = TCPManager.GetTimeStampMS() + 300 * 1000; switch (Type) { case SiegeType.GTAOE: Point3D targetPos = ZoneService.GetWorldPosition(_weapon.Zone.Info, targetX, targetY, targetZ); if (!ArcHit(zoneId, new Point3D(targetX, targetY, targetZ), targetPos)) { player.SendClientMessage("Can't hit that position from here", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR); return; } Siege artillery = _weapon as Siege; if (artillery != null && !artillery.CanFire(player)) { return; } _weapon.AbtInterface.StartCastAtPos(player, _abilityId, ZoneService.GetWorldPosition(_weapon.Zone.Info, targetX, targetY, targetZ), _weapon.Zone.ZoneId, 0); break; case SiegeType.OIL: _weapon.AbtInterface.StartCastAtPos(player, _abilityId, ZoneService.GetWorldPosition(_weapon.Zone.Info, targetX, targetY, targetZ), _weapon.Zone.ZoneId, 0); break; case SiegeType.SNIPER: Unit target = _weapon.Region.GetObject(targetID) as Unit; if (target == null || !CombatInterface.CanAttack(player, target)) { return; } Siege cannon = _weapon as Siege; if (cannon != null && !cannon.CanFire(player)) { return; } _weapon.CbtInterface.SetTarget(targetID, TargetTypes.TARGETTYPES_TARGET_ENEMY); _weapon.AbtInterface.StartCast(player, _abilityId, 0, 0, Math.Max((byte)1, (byte)(_weapon.Level * power * 0.01f))); break; case SiegeType.RAM: Unit ramTarget = null; foreach (Object obj in _Owner.ObjectsInRange) { KeepDoor.KeepGameObject door = obj as KeepDoor.KeepGameObject; if (door == null) { continue; } if (!CombatInterface.CanAttack(player, door)) { continue; } if (!_Owner.IsObjectInFront(door, 90) || !door.IsWithinRadiusFeet(_Owner, 20)) { continue; } ramTarget = door; break; } //Unit target = _weapon.Region.GetObject(targetID) as Unit; if (ramTarget != null) { _weapon.CbtInterface.SetTarget(ramTarget.Oid, TargetTypes.TARGETTYPES_TARGET_ENEMY); _weapon.AbtInterface.StartCast(player, _abilityId, 0, 0, Math.Max((byte)1, (byte)(_weapon.Level * power * 0.01f))); } else { foreach (var plrInfo in Players) { plrInfo.Key.SendClientMessage("No target", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR); } } break; } SendSiegeCooldown(); // Disable Firing? /* * Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE); * Out.WriteUInt16(_Owner.Oid); * Out.WriteByte(0x1C); * Out.WriteByte(2); * Out.Fill(0, 6); * player.SendPacket(Out); */ SendSiegeUserUpdate(); /* * Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE); * Out.WriteUInt16(_Owner.Oid); * Out.WriteByte(0x1E); * Out.WriteUInt16(0); * Out.WriteByte((byte)_Owner.Name.Length); * Out.WriteUInt16(0); * Out.WriteCString(_Owner.Name); * Out.WriteByte(0); * player.SendPacket(Out); */ SendSiegeIdleTimer(player); }
public virtual long MovementElapsedMs() { long Elapsed = TCPManager.GetTimeStampMS() - MovementStart; return(Elapsed); }
/// <summary> /// 处理分享相关命令 /// </summary> /// <param name="tcpMgr"></param> /// <param name="socket"></param> /// <param name="tcpClientPool"></param> /// <param name="pool"></param> /// <param name="nID"></param> /// <param name="data"></param> /// <param name="count"></param> /// <param name="tcpOutPacket"></param> /// <returns></returns> public static TCPProcessCmdResults ProcessShareCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; string[] fields = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket))); return(TCPProcessCmdResults.RESULT_FAILED); } try { fields = cmdData.Split(':'); int roleID = Convert.ToInt32(fields[0]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (null == client || client.ClientData.RoleID != roleID) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID)); return(TCPProcessCmdResults.RESULT_FAILED); } int resoult = 0; int extdata = 0; switch ((TCPGameServerCmds)nID) { case TCPGameServerCmds.CMD_SPR_GETSHARESTATE: if (HasDoneShare(client)) { if (CanGetShareAward(client)) { extdata = 1; //表示可领取,按钮状态激活 } else { extdata = 2; //表示已经领取 } } else { extdata = 0; } break; case TCPGameServerCmds.CMD_SPR_UPDATESHARESTATE: UpdateRoleShareState(client); if (HasDoneShare(client)) { if (CanGetShareAward(client)) { extdata = 1; //表示可领取,按钮状态激活 } else { extdata = 2; //表示已经领取 } } else { extdata = 0; } break; case TCPGameServerCmds.CMD_SPR_GETSHAREAWARD: resoult = GiveRoleShareAward(client); if (resoult == 0 || resoult == -2) { extdata = 2; //修改状态已经领取 } else if (resoult == -1) { extdata = 0; //按钮状态是未激活,灰色 } else { extdata = 1; //领取按钮激活,可领取 } break; } string strcmd = string.Format("{0}:{1}", resoult, extdata); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "ProcessShareCMD", false); } return(TCPProcessCmdResults.RESULT_DATA); }
public GameRiftClient(TCPManager Srv) : base(Srv) { }
public LobbyClient(TCPManager srv) : base(srv) { }
public WorldClient(TCPManager srv) : base(srv) { }
private void HandleInteractionEvents(Player player) { if (!IsDead) { player.QtsInterface.HandleEvent(Objective_Type.QUEST_USE_GO, Spawn.Entry, 1); } // This will spawn a creature after interacting with the GO if (this.Spawn.Proto.CreatureId != 0 && IsAttackable == 0) { SpawnNPCFromGO(); } // This will play sound after clicking on the GO long now = TCPManager.GetTimeStampMS(); if (this.Spawn.SoundId != 0 && now > SoundCooldown) { this.PlaySound((ushort)this.Spawn.SoundId); SoundCooldown = TCPManager.GetTimeStampMS() + 60 * 1000; } HandleCustomInteraction(); PublicQuest pq = player.QtsInterface.PublicQuest; pq?.HandleEvent(player, Objective_Type.QUEST_USE_GO, Spawn.Entry, 1, 50); if (Spawn.Proto.TokUnlock != null && Spawn.Proto.TokUnlock.Length > 1 && IsAttackable == 0) { player.TokInterface.AddToks(Spawn.Proto.TokUnlock); // This check if the GO we clicked is a Door - if it is we don't want to mess with its // VFXState because we can break it if (this.Spawn.DoorId == 0) { this.EvtInterface.AddEvent(EventSendMeTo, 60000, 1); if (this.Spawn.AllowVfxUpdate == 1) { this.VfxState = 1; } foreach (Player plr in PlayersInRange) { this.UpdateVfxState(VfxState); } } } if (Spawn.TokUnlock != null && Spawn.TokUnlock.Length > 1 && IsAttackable == 0) { player.TokInterface.AddToks(Spawn.TokUnlock); // This check if the GO we clicked is a Door - if it is we don't want to mess with its // VFXState because we can break it if (this.Spawn.DoorId == 0) { this.EvtInterface.AddEvent(EventSendMeTo, 60000, 1); if (this.Spawn.AllowVfxUpdate == 1) { this.VfxState = 1; } foreach (Player plr in PlayersInRange) { this.UpdateVfxState(VfxState); } } } }
// This is for handling custom GO interaction private void HandleCustomInteraction() { if (Entry == 2000579) // This is Mourkain Gem for Ard 'ta Feed Gunbad Boss and part of his mechanics { if (LastUsedTimestamp == 0) { Say("*** Sinister energy is gone from the gem... ***", ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); } LastUsedTimestamp = TCPManager.GetTimeStampMS(); bool removeBuff = false; foreach (Object o in ObjectsInRange) { GameObject go = o as GameObject; if (go != null && go != this && go.Entry == 2000579) // This is 2nd Mourkain Gem { if (go.LastUsedTimestamp != 0 && (LastUsedTimestamp - go.LastUsedTimestamp < 2001)) { LastUsedTimestamp = 0; go.LastUsedTimestamp = 0; removeBuff = true; } else if (go.LastUsedTimestamp != 0) { LastUsedTimestamp = 0; go.LastUsedTimestamp = 0; Say("*** You are too late! Better hurry and try again! ***", ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); } } } if (removeBuff) { foreach (Object ob in ObjectsInRange) // This is looking for ard to feed in range { Creature c = ob as Creature; if (c != null && c.Entry == 15102) // This is ard ta feed { c.BuffInterface.RemoveBuffByEntry(20364); NewBuff newBuff = c.BuffInterface.GetBuff(20364, null); if (newBuff != null) { newBuff.RemoveBuff(true); } c.AbtInterface.StartCast(c, 5308, 0); Say("*** Wicked energy evaporates from the cursed jewel... ***", ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); c.Say("*** Monstrous squig calms a bit... ***", ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY); } GameObject gobject = ob as GameObject; if (gobject != null && gobject.Entry == 98876) // This is Mourkain Henge { gobject.VfxState = 0; foreach (Player player in gobject.PlayersInRange) { gobject.SendMeTo(player); } } } } } }
public TCPProcessCmdResults ProcessQueryQingGongYanCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true); return(TCPProcessCmdResults.RESULT_FAILED); } try { string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true); return(TCPProcessCmdResults.RESULT_FAILED); } int roleID = Convert.ToInt32(fields[0]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID)) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true); return(TCPProcessCmdResults.RESULT_FAILED); } int DBGrade = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_grade", "0")); int TotalCount = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_joincount", "0")); int JoinMoney = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_joinmoney", "0")); string QingGongYanJoinFlag = Global.GetRoleParamByName(client, "QingGongYanJoinFlag"); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); int lastJoinDay = 0; int joinCount = 0; if (null != QingGongYanJoinFlag) { string[] strTemp = QingGongYanJoinFlag.Split(new char[] { ',' }); if (2 == strTemp.Length) { lastJoinDay = Convert.ToInt32(strTemp[0]); joinCount = Convert.ToInt32(strTemp[1]); } } if (currDay != lastJoinDay) { joinCount = 0; } string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { roleID, DBGrade, joinCount, TotalCount, JoinMoney }); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "ProcessHoldQingGongYanCMD", false, false); } return(TCPProcessCmdResults.RESULT_FAILED); }