public static void StartGain(Mobile killer, Mobile killed) { Setup set = new Setup(); PlayerMobile pm = null; if (killer is PlayerMobile) //Find & Set killer { pm = killer as PlayerMobile; } else { BaseCreature bc = killer as BaseCreature; if (bc.Controlled && set.ExpFromPetKills) { pm = bc.GetMaster() as PlayerMobile; } } if (pm == null) //if no killer Exit system { return; } double Gain = Figures.GetKillExp(pm, killed, new Setup()); //Get the exp for the kill FinalizeExp(pm, killed, Gain, new Setup()); }
public static bool IsControlled(this Mobile m, out Mobile master) { if (m is BaseCreature) { BaseCreature c = (BaseCreature)m; master = c.GetMaster(); return(c.Controlled); } master = null; return(false); }
public static TMobile GetMaster <TMobile>(this BaseCreature creature) where TMobile : Mobile { return(creature != null?creature.GetMaster() as TMobile : null); }
public static void Set(Mobile killer, Mobile killed) { XMLPlayerLevelAtt xmlplayerklr = (XMLPlayerLevelAtt)XmlAttach.FindAttachment(killer, typeof(XMLPlayerLevelAtt)); PlayerMobile klr = null; Party pty = null; Configured c = new Configured(); LevelHandler lh = new LevelHandler(); ConfiguredPetXML cp = new ConfiguredPetXML(); if (killer is BaseCreature) { BaseCreature bc = killer as BaseCreature; BaseCreature bckilled = killed as BaseCreature; if (bc.Controlled && c.PetKillGivesExp) { klr = bc.GetMaster() as PlayerMobile; } if (bc.Summoned && c.PetKillGivesExp) { klr = bc.GetMaster() as PlayerMobile; } } else { if (killer is PlayerMobile) //double check ;) { klr = killer as PlayerMobile; } } if (lh.MemberCount.Count > 0) { foreach (Mobile il in lh.MemberCount) { lh.MemberCount.Remove(il); } } if (klr != null) { Mobile m = (Mobile)killer; pty = Party.Get(klr); if (m is PlayerMobile) { XMLPlayerLevelAtt xmlplayerklr2 = (XMLPlayerLevelAtt)XmlAttach.FindAttachment(m, typeof(XMLPlayerLevelAtt)); if (xmlplayerklr2.Levell < 1) { xmlplayerklr2.Levell = 1; } if (xmlplayerklr2.ToLevell < 50) { xmlplayerklr2.ToLevell = 50; } if (!(xmlplayerklr2.MaxLevel == c.StartMaxLvl && xmlplayerklr2.MaxLevel > c.EndMaxLvl)) { xmlplayerklr2.MaxLevel = c.StartMaxLvl; } } AddExp(klr, killed, pty, new Configured()); } }