• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Count "killed monsters" from character created

erikbs

Member
Joined
Jul 15, 2010
Messages
39
Reaction score
8
Hi there,

Ive been searching for a while after a script or clues on how to do this, but I havent been able to find anything yet.


So, Iam looking for a solution for when a new character is created, it starts counting how many monsters the character has killed without him/her having to talk to any "monster kill task NPC). I would like it to have a counter for total monsters killed, and total monsters killed within a group, lets say "orcs" (orc spearman, orc warrior etc) or for example Dragons (dragon, dragon lord, hydra etc).

The idea is that these numbers follows each individual player on their journey throughout the game, and when they reach certain amounts (total or within a category), they will recieve a currency/item they can use to trade different kinds of reward chests.

I allready have a system for the reward chests, but I would like a character to recieve a number of currency/items after X amount of kills, as well as a text displaying how many he/she has killed and that they recieved the currency/items.

If this made sense, and if anyone wants to help me out with this, I would be a happy chap :)
 
Solution
Thank you for your reply zxmatzx.
I kind of understand the idea, but sadly Iam still in my "beginningphase" of scripting.
Ive looked at scripts like the "Monster Tasks by Limos" - script, and understand parts of it. Coding it from scratch, even with with the help you provided in your reply seems a few steps further down the coding-line XD

Is there any chance you have the time on your hand to help me further?

cheers
Always post your server version.
I did this script quickly, it's for TFS 1.x

data/creaturescripts/scripts/monstersToCount.lua:
Lua:
--use monsters name in low-case
local monstersToCount = {
    ["dragon"] = {storage = 1000, groupStorage = 5000},
    ["dragon lord"] = {storage = 1001, groupStorage = 5000}...
Hi,
Make a table holding: storage number, monster name and rewards to recive. Use a onKill creaturescript to check if killed monster are in the table, if yes, increment the storage and check if new storage value is valid for a reward.
 
Make a table holding: storage number, monster name and rewards to recive. Use a onKill creaturescript to check if killed monster are in the table, if yes, increment the storage and check if new storage value is valid for a reward.

Thank you for your reply zxmatzx.
I kind of understand the idea, but sadly Iam still in my "beginningphase" of scripting.
Ive looked at scripts like the "Monster Tasks by Limos" - script, and understand parts of it. Coding it from scratch, even with with the help you provided in your reply seems a few steps further down the coding-line XD

Is there any chance you have the time on your hand to help me further?

cheers
 
Thank you for your reply zxmatzx.
I kind of understand the idea, but sadly Iam still in my "beginningphase" of scripting.
Ive looked at scripts like the "Monster Tasks by Limos" - script, and understand parts of it. Coding it from scratch, even with with the help you provided in your reply seems a few steps further down the coding-line XD

Is there any chance you have the time on your hand to help me further?

cheers
Always post your server version.
I did this script quickly, it's for TFS 1.x

data/creaturescripts/scripts/monstersToCount.lua:
Lua:
--use monsters name in low-case
local monstersToCount = {
    ["dragon"] = {storage = 1000, groupStorage = 5000},
    ["dragon lord"] = {storage = 1001, groupStorage = 5000},
    ["demon"] = {storage = 1002, groupStorage = 5001},
    ["warlock"] = {storage = 1003, groupStorage = 5002},
}

function onKill(creature, target)
    if not Player(creature) then --check if killer is a Player
        return true
    end
    
    if not Monster(target) then --check if killed is a Monster
        return true
    end
    
    local monsterIndex = monstersToCount[string.lower(target:getName())] --get monster info from table using string.lower() to change target name to low-case
    if monsterIndex then --if exist monster info
        --update individual count
        local monsterKilledCount = creature:getStorageValue(monsterIndex.storage)
        if monsterKilledCount < 0 then--check if individual count is lower than 0 (default storage value = -1) and set to 0
            creature:setStorageValue(monsterIndex.storage, 0)
            monsterKilledCount = 0
        end
        creature:setStorageValue(monsterIndex.storage, monsterKilledCount + 1)
        
        --update group count
        local monsterGroupKilledCount = creature:getStorageValue(monsterIndex.groupStorage)
        if monsterGroupKilledCount < 0 then--check if group count is lower than 0 (default storage value = -1) and set to 0
            creature:setStorageValue(monsterIndex.groupStorage, 0)
            monsterGroupKilledCount = 0
        end
        creature:setStorageValue(monsterIndex.groupStorage, monsterGroupKilledCount + 1)
        
        creature:sendTextMessage(MESSAGE_EVENT_ORANGE, "You killed "..(monsterKilledCount + 1).." "..target:getName().." and "..(monsterGroupKilledCount + 1).." monsters of this group.")
    end
    return true
end

data/creaturescripts/creaturescripts.xml:
XML:
 <event type="kill" name="countMonsters" script="monstersToCount.lua"/>

data/creaturescripts/scripts/login.lua:
above the last return true put:
Lua:
player:registerEvent("countMonsters")

Try kill a monster that contains the name in table and see what happens.
Remember to configure monsters in table with low-case name to avoid missmatchs.
Monsters of same group should have the same groupStorage number in table config.

I hope it helps you.
 
Solution
Great! Thank you my friend.
This is very much appreciated.

Yes sorry my bad. Its TFS 1.3. It works like a charm :)

So now I can add stages as an IF statement so that if
monsterGroupKilledCount => 500 then etc? And then for 1500, 2500 with different loot?
And Iam wondering how can I make the loot different for each monster group? Lets say I kill 500 of Dragongroup, and 500 of Trollgroup, I would want the reward to be different. If that made sense.


And again, Thank you for helping me out. I did not expect you to do this, but its very much appreciated.
btw, how do I give you credit for your help?


Cheers
 
Great! Thank you my friend.
This is very much appreciated.

Yes sorry my bad. Its TFS 1.3. It works like a charm :)

So now I can add stages as an IF statement so that if
monsterGroupKilledCount => 500 then etc? And then for 1500, 2500 with different loot?
And Iam wondering how can I make the loot different for each monster group? Lets say I kill 500 of Dragongroup, and 500 of Trollgroup, I would want the reward to be different. If that made sense.


And again, Thank you for helping me out. I did not expect you to do this, but its very much appreciated.
btw, how do I give you credit for your help?


Cheers
So now I can add stages as an IF statement so that if
monsterGroupKilledCount => 500 then etc? And then for 1500, 2500 with different loot?
And Iam wondering how can I make the loot different for each monster group? Lets say I kill 500 of Dragongroup, and 500 of Trollgroup, I would want the reward to be different. If that made sense.
Yes. The best way is add to the table monstersToCount the stages and rewards for individual monsters. To work well with groups rewards we first have to unificate the groups, should work better.

And again, Thank you for helping me out. I did not expect you to do this, but its very much appreciated.
btw, how do I give you credit for your help?
Glad it helped you. Don't worry about credit, this is a free script just to help you out, you can use it freely. It can be a lot better, when i have some free time, i will try do a better version, it's a system that i want have too.
 
Yes. The best way is add to the table monstersToCount the stages and rewards for individual monsters. To work well with groups rewards we first have to unificate the groups, should work better.
Aha, that makes sense, alltho its kinda Greek too me how to do this hehe.

Glad it helped you. Don't worry about credit, this is a free script just to help you out, you can use it freely. It can be a lot better, when i have some free time, i will try do a better version, it's a system that i want have too.
Aha, Well thank you very much. its very appreciated.
I would love it if you could keep me updated on that script? Would love to have a fully functional version of it on my server.
iam a huge fan of GW2 (Guild wars 2), and there they have loads of different counters of what you do. I want to focus on monsters right now, so that when you kill a certain amount of monsters you will reach "Goal 1", where you will get rewarded with some kind of credit. Maybe added directly to the depot, or maybe it not being a physical item at all, but a storage number representing that you killed 500 monsters in that category (Goal 1). Then the same for 1500, 2500 (goal 2 and 3).
The idea is that you can use X amount of this credit/item to buy chests of your choice. You can use X amount of credit to buy for example "Legendary Archer chest" that will contain a few different random items with Legendary rank that is good for distance fighting. You will have multiple choices.
The chest system is allready set up :)
I think it adds depth to the game to have multiple goals, and this is one from GW2 that i really like.

So It would be awesome if you are able to make something like this, and if you want to, Iam sure we can come to an agreement.

Thank you for your help so far my friend.
Talk later :)
 
Last edited:
Back
Top