Well, i got asked a lot by people to explain how to add a Kill Counter.
It's actually easy, and sad to see that most of the "Developer" doesn't even know how to write 7 lines of code.
What it will do:
- Safe killed Monster Amount in Database
- Display killed Monster in Database
- Handle Rewards for a certain Kill Count
1. Add a new Column in DB on Character called KillCount
> Go to DAL.EF > Character.cs and add
Code:
public int KillCount { get; set; }
> Go to OpenNos.Data > CharacterDTO.cs and add
Code:
public int KillCount { get; set; }
> Go to GameObject > Character.cs and add
Code:
KillCount = input.KillCount;
> Go to the Mapper and add (x2, ToCharacter and ToCharacterDTO)
Code:
output.KillCount = input.KillCount;
2. Add GenerateKillCountBonus
> Go to GameObject > Character.cs and add whereever u want
Code:
public void GenerateKillCountBonus()
{
switch (KillCount)
{
//When Character killed 100 Monsters
case 100:
break;
}
}
3. Implement the Generation
> Go to GenerateKillBonus, go to #region EXP, Reputation and Dignity in GenerateKillBonus and add on top of that region
Code:
#region Generate KillCount Bonus
if (Hp > 0 && !monsterToAttack.BattleEntity.IsMateTrainer(monsterToAttack.MonsterVNum))
{
switch (KillCount)
{
case 100:
GenerateKillCountBonus();
break;
}
}
#endregion
Increase the KillCounter where ever u want. Simple way to do it is on GenerateKillBonus, for each kill.
Code:
Session.Character.KillCount++;
Done. This implementation is fairly easy and safe to use. It's simple af.
You can also check by using if statement at the end instead of case. I like this one more.
Happy leech