public void Feed(int i) { HungerPrc += (byte)i; if (HungerPrc > 100) { HungerPrc = 100; } Asda2PetHandler.SendUpdatePetHungerResponse(Owner.Client, this); }
public Asda2PetRecord AddAsda2Pet(PetTemplate petTemplate, bool silent = false) { var newPet = new Asda2PetRecord(petTemplate, this); newPet.Create(); OwnedPets.Add(newPet.Guid, newPet); Asda2TitleChecker.OnPetCountChanged(OwnedPets.Count, this); if (!silent) { Asda2PetHandler.SendInitPetInfoOnLoginResponse(Client, newPet); } return(newPet); }
public bool GainXp(int i) { if (Level == 10) { return(false); } int num = Asda2PetMgr.ExpTable[Template.Rank][Template.Rarity][Level - 1]; if (Level == MaxLevel && Expirience >= num) { Expirience = (short)num; return(false); } Expirience += (short)i; if (Level == MaxLevel) { if (Expirience > num) { Expirience = (short)num; } Asda2PetHandler.SendUpdatePetExpResponse(Owner.Client, this, false); return(true); } if (Expirience > num) { RemoveStatsFromOwner(); ++Level; AddStatsToOwner(); Asda2CharacterHandler.SendUpdateStatsResponse(Owner.Client); Asda2CharacterHandler.SendUpdateStatsOneResponse(Owner.Client); GlobalHandler.UpdateCharacterPetInfoToArea(Owner); Asda2PetHandler.SendUpdatePetHungerResponse(Owner.Client, this); } Asda2PetHandler.SendUpdatePetExpResponse(Owner.Client, this, true); return(true); }
public bool GainXp(int i) { if (this.Level == (byte)10) { return(false); } int num = Asda2PetMgr.ExpTable[this.Template.Rank][this.Template.Rarity][(int)this.Level - 1]; if ((int)this.Level == (int)this.MaxLevel && (int)this.Expirience >= num) { this.Expirience = (short)num; return(false); } this.Expirience += (short)i; if ((int)this.Level == (int)this.MaxLevel) { if ((int)this.Expirience > num) { this.Expirience = (short)num; } Asda2PetHandler.SendUpdatePetExpResponse(this.Owner.Client, this, false); return(true); } if ((int)this.Expirience > num) { this.RemoveStatsFromOwner(); ++this.Level; this.AddStatsToOwner(); Asda2CharacterHandler.SendUpdateStatsResponse(this.Owner.Client); Asda2CharacterHandler.SendUpdateStatsOneResponse(this.Owner.Client); GlobalHandler.UpdateCharacterPetInfoToArea(this.Owner); Asda2PetHandler.SendUpdatePetHungerResponse(this.Owner.Client, this); } Asda2PetHandler.SendUpdatePetExpResponse(this.Owner.Client, this, true); return(true); }
public override void Update(int dt) { base.Update(dt); if (m_isLoggingOut) { m_logoutTimer.Update(dt); } if (!IsMoving && LastSendIamNotMoving < (uint)Environment.TickCount) { LastSendIamNotMoving = (uint)(Environment.TickCount + CharacterFormulas.TimeBetweenImNotMovingPacketSendMillis); Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(this, true, false); } Asda2MovmentHandler.CalculateAndSetRealPos(this, dt); if (Asda2Pet != null) { if (LastPetExpGainTime < (uint)Environment.TickCount) { Asda2Pet.GainXp(1); LastPetExpGainTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetExpGainSecs * 1000; } if (!PetNotHungerEnabled && LastPetEatingTime < (uint)Environment.TickCount) { if (Asda2Pet.HungerPrc == 1) { Asda2TitleChecker.OnPetStarve(this); //Stop pet Asda2PetHandler.SendPetGoesSleepDueStarvationResponse(Client, Asda2Pet); Asda2Pet.RemoveStatsFromOwner(); Asda2Pet.HungerPrc = 0; Asda2Pet = null; GlobalHandler.UpdateCharacterPetInfoToArea(this); } else { Asda2Pet.HungerPrc--; LastPetEatingTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetEatingsSecs * 1000; } } } if (PremiumBuffs.Count > 0) { foreach (var functionItemBuff in PremiumBuffs.Values) { if (functionItemBuff.Duration < dt) { ProcessFunctionalItemEffect(functionItemBuff, false); CategoryBuffsToDelete.Add(functionItemBuff.Template.Category); functionItemBuff.DeleteLater(); } else { functionItemBuff.Duration -= dt; } } } foreach (var functionItemBuff in LongTimePremiumBuffs) { if (functionItemBuff == null) { continue; } if (functionItemBuff.EndsDate < DateTime.Now) { ProcessFunctionalItemEffect(functionItemBuff, false); CategoryBuffsToDelete.Add(functionItemBuff.Template.Category); functionItemBuff.DeleteLater(); } } if (CategoryBuffsToDelete.Count > 0) { foreach (var asda2ItemCategory in CategoryBuffsToDelete) { PremiumBuffs.Remove(asda2ItemCategory); for (int i = 0; i < LongTimePremiumBuffs.Length; i++) { if (LongTimePremiumBuffs[i] == null || LongTimePremiumBuffs[i].Template.Category != asda2ItemCategory) { continue; } LongTimePremiumBuffs[i] = null; break; } } CategoryBuffsToDelete.Clear(); } var toDelete = new List <Asda2PereodicActionType>(); foreach (var pereodicAction in PereodicActions) { pereodicAction.Value.Update(dt); if (pereodicAction.Value.CallsNum <= 0) { toDelete.Add(pereodicAction.Key); } } foreach (var t in toDelete) { PereodicActions.Remove(t); } if (SoulmateRecord != null) { SoulmateRecord.OnUpdateTick(); } if (BanChatTill < DateTime.Now) { BanChatTill = null; ChatBanned = false; SendInfoMsg("Chat is unbanned."); } }