internal static void Party_ShareExp(int partyNum, int exp, int index, int mapNum) { int expShare = 0; int leftOver = 0; int i = 0; int tmpindex = 0; byte loseMemberCount = 0; // check if it's worth sharing if (!(exp >= Party[partyNum].MemberCount)) { // no party - keep exp for self S_Events.GivePlayerExp(index, exp); return; } // check members in others maps for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++) { tmpindex = Party[partyNum].Member[i]; if (tmpindex > 0) { if (S_NetworkConfig.Socket.IsConnected(tmpindex) && S_NetworkConfig.IsPlaying(tmpindex)) { if (S_Players.GetPlayerMap(tmpindex) != mapNum) { loseMemberCount = (byte)(loseMemberCount + 1); } } } } // find out the equal share expShare = exp / (Party[partyNum].MemberCount - loseMemberCount); leftOver = exp % (Party[partyNum].MemberCount - loseMemberCount); // loop through and give everyone exp for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++) { tmpindex = Party[partyNum].Member[i]; // existing member? if (tmpindex > 0) { // playing? if (S_NetworkConfig.Socket.IsConnected(tmpindex) && S_NetworkConfig.IsPlaying(tmpindex)) { if (S_Players.GetPlayerMap(tmpindex) == mapNum) { // give them their share S_Events.GivePlayerExp(tmpindex, expShare); } } } } // give the remainder to a random member if (!(leftOver == 0)) { tmpindex = Party[partyNum].Member[S_GameLogic.Random(1, Party[partyNum].MemberCount)]; // give the exp S_Events.GivePlayerExp(tmpindex, leftOver); } }
public static void HandleClearProjectile(int index, ref byte[] data) { int ProjectileNum; int Targetindex; Enums.TargetType TargetType; int TargetZone; int mapNum; int Damage; int armor; int npcnum; ByteStream buffer = new ByteStream(data); ProjectileNum = buffer.ReadInt32(); Targetindex = buffer.ReadInt32(); TargetType = (Enums.TargetType)buffer.ReadInt32(); TargetZone = buffer.ReadInt32(); buffer.Dispose(); mapNum = S_Players.GetPlayerMap(index); switch (MapProjectiles[mapNum, ProjectileNum].OwnerType) { case (byte)Enums.TargetType.Player: { if (MapProjectiles[mapNum, ProjectileNum].Owner == index) { switch (TargetType) { case Enums.TargetType.Player: { if (S_NetworkConfig.IsPlaying(Targetindex)) { if (Targetindex != index) { if (S_Players.CanPlayerAttackPlayer(index, Targetindex, true) == true) { // Get the damage we can do Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage; // if the npc blocks, take away the block amount armor = Convert.ToInt32(S_Players.CanPlayerBlockHit(Targetindex)); Damage = Damage - armor; // randomise for up to 10% lower than max hit Damage = S_GameLogic.Random(1, Damage); if (Damage < 1) { Damage = 1; } S_Players.AttackPlayer(index, Targetindex, Damage); } } } break; } case Enums.TargetType.Npc: { npcnum = modTypes.MapNpc[mapNum].Npc[Targetindex].Num; if (S_Players.CanPlayerAttackNpc(index, Targetindex, true) == true) { // Get the damage we can do Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage; // if the npc blocks, take away the block amount armor = 0; Damage = Damage - armor; // randomise from 1 to max hit Damage = S_GameLogic.Random(1, Damage); if (Damage < 1) { Damage = 1; } S_Players.PlayerAttackNpc(index, Targetindex, Damage); } break; } } } break; } } ClearMapProjectile(mapNum, ProjectileNum); }