• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 0.X Kill "x" monster and appear a boss

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,237
Solutions
17
Reaction score
104
Location
Brazil
Hello guys,

Does someone have a script who works globaly, when all players kills "x" of specific monster, spawn a boss? I have looked in forum but find nothing.
 

Dries390

Well-Known Member
Joined
Sep 8, 2007
Messages
74
Solutions
4
Reaction score
58
You could take any regular old script for killing creatures and use Game.setStorageValue(num, val) to keep a global count. Might be an interesting exercise.
Post automatically merged:

I quickly whipped up an example for you.


bossSpawn.lua in creaturescripts/scripts
Lua:
local mob = "Troll"
local bossName = "Orshabaal"
local killCount = 15
local positionBossSpawn = {x = 98, y = 104, z = 6}
local storValGlobal = 1024
local bossMsg = "The skies darken as Orshabaal enters the world! Flee mortals!"

function onKill(creature, target)
    if isPlayer(target) ~= TRUE and getCreatureName(target) == mob then
        if Game.getStorageValue(storValGlobal) == nil then
            Game.setStorageValue(storValGlobal, 0)
        end
        Game.setStorageValue(storValGlobal, Game.getStorageValue(storValGlobal) + 1)
    end
   
    if Game.getStorageValue(storValGlobal) == killCount then
        Game.createMonster(bossName, positionBossSpawn)
        broadcastMessage(bossMsg)
        Game.setStorageValue(storValGlobal, 0)
    end
end
Add to login.lua
Lua:
player:registerEvent("BossSpawnAfterKills")

creaturescripts.xml
XML:
<event type="kill" name="BossSpawnAfterKills" script="bossspawn.lua"/>
 
Last edited:
OP
OP
potinho

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,237
Solutions
17
Reaction score
104
Location
Brazil
You could take any regular old script for killing creatures and use Game.setStorageValue(num, val) to keep a global count. Might be an interesting exercise.
Post automatically merged:

I quickly whipped up an example for you.


bossSpawn.lua in creaturescripts/scripts
Lua:
local mob = "Troll"
local bossName = "Orshabaal"
local killCount = 15
local positionBossSpawn = {x = 98, y = 104, z = 6}
local storValGlobal = 1024
local bossMsg = "The skies darken as Orshabaal enters the world! Flee mortals!"

function onKill(creature, target)
    if isPlayer(target) ~= TRUE and getCreatureName(target) == mob then
        if Game.getStorageValue(storValGlobal) == nil then
            Game.setStorageValue(storValGlobal, 0)
        end
        Game.setStorageValue(storValGlobal, Game.getStorageValue(storValGlobal) + 1)
    end
 
    if Game.getStorageValue(storValGlobal) == killCount then
        Game.createMonster(bossName, positionBossSpawn)
        broadcastMessage(bossMsg)
        Game.setStorageValue(storValGlobal, 0)
    end
end
Add to login.lua
Lua:
player:registerEvent("BossSpawnAfterKills")

creaturescripts.xml
XML:
<event type="kill" name="BossSpawnAfterKills" script="bossspawn.lua"/>
Tried to put em 0.X code, but got a problem:


I tried to change to
Lua:
local mob = "Guzzlemaw"
local bossName = "Orshabaal"
local killCount = 15
local positionBossSpawn = {x = 932, y = 1356, z = 12}
local storValGlobal = 1024
local bossMsg = "The skies darken as Orshabaal enters the world! Flee mortals!"

function onKill(cid, target)
    if isPlayer(target) ~= TRUE and getCreatureName(target) == mob then
        if getGlobalStorageValue(storValGlobal) == nil then
            setGlobalStorageValue(storValGlobal, 0)
        end
        setGlobalStorageValue(cid, getGlobalStorageValue(storValGlobal) + 1)
    end
  
    if getGlobalStorageValue(storValGlobal) == killCount then
        doCreateMonster(bossName, positionBossSpawn)
        broadcastMessage(bossMsg, MESSAGE_STATUS_WARNING)
        setGlobalStorageValue(storValGlobal, 0)
    end
end


And now monster dont fall in ground, but no error on console
 
Last edited:

Dries390

Well-Known Member
Joined
Sep 8, 2007
Messages
74
Solutions
4
Reaction score
58
Are you sure it's not related to your previous issue?
Does it work for regular trolls? I upgraded from 0.X years ago so I can't be sure what might be the matter here.
 
OP
OP
potinho

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,237
Solutions
17
Reaction score
104
Location
Brazil
Are you sure it's not related to your previous issue?
Does it work for regular trolls?
Pretty sure, it was fixed a long by those links:




I changed my script to:

Lua:
local mob = "Guzzlemaw"
local bossName = "Orshabaal"
local killCount = 15
local positionBossSpawn = {x = 932, y = 1356, z = 12}
local storValGlobal = 1024
local bossMsg = "The skies darken as Orshabaal enters the world! Flee mortals!"

function onKill(cid, target)
    if isPlayer(target) ~= TRUE and getCreatureName(target) == mob then
        if getGlobalStorageValue(storValGlobal) == nil then
            setGlobalStorageValue(storValGlobal, 0)
        end
        setGlobalStorageValue(cid, getGlobalStorageValue(storValGlobal) + 1)
    end
 
    if getGlobalStorageValue(storValGlobal) >= killCount then
        doCreateMonster(bossName, positionBossSpawn)
        broadcastMessage(bossMsg, MESSAGE_STATUS_WARNING)
        setGlobalStorageValue(storValGlobal, 0)
    end
    return true
end

Now monsters die (fall in ground) but nothing happens, i kill 15, 60, 192831298319, and no boss is summoned.
Post automatically merged:

Solved (thanks to @M0ustafa)

Lua:
local mob = "Guzzlemaw"
local bossName = "Reflection of Mawhawk"
local killCount = 1000
local positionBossSpawn = {x = 932, y = 1356, z = 12}
local storValGlobal = 1024
local bossMsg = "The skies darken as Reflection of Mawhawk enters the world! Flee mortals!"

function onKill(cid, target)
    if isPlayer(target) ~= TRUE and getCreatureName(target) == mob then
        if getGlobalStorageValue(storValGlobal) == nil then
            setGlobalStorageValue(storValGlobal, 0)
        end
        setGlobalStorageValue(storValGlobal, getGlobalStorageValue(storValGlobal) + 1)
    end
  
    if getGlobalStorageValue(storValGlobal) >= killCount then
        doCreateMonster(bossName, positionBossSpawn)
        broadcastMessage(bossMsg, MESSAGE_STATUS_WARNING)
        setGlobalStorageValue(storValGlobal, 0)
    end
    return true
end
 
Last edited:

Dries390

Well-Known Member
Joined
Sep 8, 2007
Messages
74
Solutions
4
Reaction score
58
I was just staring at this; line 13
C++:
setGlobalStorageValue(cid, getGlobalStorageValue(storValGlobal) + 1)

shouldn't that be

C++:
setGlobalStorageValue(storValGlobal, getGlobalStorageValue(storValGlobal) + 1)

Edit: Bah, beaten by 20 minutes :p
 
OP
OP
potinho

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,237
Solutions
17
Reaction score
104
Location
Brazil
I was just staring at this; line 13
C++:
setGlobalStorageValue(cid, getGlobalStorageValue(storValGlobal) + 1)

shouldn't that be

C++:
setGlobalStorageValue(storValGlobal, getGlobalStorageValue(storValGlobal) + 1)

Edit: Bah, beaten by 20 minutes :p
Thanks anyway, u gave me a starting point <3
 
Top