[Tutorial] How to add a Kill Counter

03/25/2021 22:53 XV50#1
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
03/25/2021 23:37 Apourtartt#2
I never used Opennos but... Tattoo ? :thinking:
03/25/2021 23:41 XV50#3
Was a typo cuz i copied it.
03/29/2021 05:05 Singleplayer™#4
nice to see that someone is still sharing stuff , but i am sure 90% of the "dev´s" here still need help for that simple stuff :lul:

maybe you should explain the logic/function of "input.KillCount" , the copy/pasters here dont need this but for the 1% which want to understand it would helps maybe
03/29/2021 06:44 XV50#5
Quote:
Originally Posted by Singleplayer™ View Post
nice to see that someone is still sharing stuff , but i am sure 90% of the "dev´s" here still need help for that simple stuff :lul:

maybe you should explain the logic/function of "input.KillCount" , the copy/pasters here dont need this but for the 1% which want to understand it would helps maybe
input just safes to the db. Otherwise it'll reset each logout because it's only safed internally.