• 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!

TalkAction [GlobalEvent] [Creaturescript] Kill Streaks - Stealth, Immortality, Sentry Gun

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
So I finally got this sh*t working. I won't make this to a mod because that just f* everything up for me, I don't know why.

So what the script does,
When anyone dies the script will broadcast a message in a channel of your choice, in this case channel with id 11(custom channel)
When you reach X numbers of kills you are able to use special features such as Stealth, Immortality, Restore, spawn a sentry gun and explode on death.
I guess that's all for now!

Creaturescripts/creaturescripts.xml
Code:
<event type="login" name="streakLogin" event="script" value="kill streaks/onLogin.lua"/>
<event type="kill" name="Kill streak" event="script" value="kill streaks/onKill.lua"/>
<event type="combat" name="Immortality" event="script" value="kill streaks/onCombat.lua"/>
Now make a new folder in creaturescripts called kill streaks.
Creaturescripts/scripts/kill streaks/onCombat.lua
Code:
local immortal = {
    storageActive = 1006, -- Storage when you are immortal
}
    
function onCombat(cid, target)
	if isPlayer(cid) then
		if getPlayerStorageValue(target, immortal.storageActive) == 1 then
			return false
		else
			return true
		end
	end
end
Creaturescripts/scripts/kill streaks/onLogin.lua
Code:
local kills = 1000

-- Replenish - Talkaction: !restore
local replenish = {
    storageCanUse = 1002, -- Storage
    alreadyGiven = 1003, -- storage
    onCooldown = 1004, -- storage
}

-- Immortality -- Talkaction: !immortal
local immortal = {
    storageCanUse = 1005, -- Storage
    storageActive = 1006, -- Storage when you are immortal
    alreadyGiven = 1007, -- storage
    onCooldown = 1008, -- storage
}

-- Stealth - Talkaction: !stealth
local stealth = {
    storageCanUse = 1010, -- storage
    alreadyGiven = 1011, -- storage
    onCooldown = 1012, -- storage
}

-- Sentry gun - Talkaction: !sentry
local sentry = {
    storageCanUse = 1014, -- storage
    alreadyGiven = 1015, -- storage
    onCooldown = 1016, -- storage
}
    
function onLogin(cid)
    setPlayerStorageValue(cid, replenish.alreadyGiven, 0)
    setPlayerStorageValue(cid, immortal.alreadyGiven, 0)
    setPlayerStorageValue(cid, stealth.alreadyGiven, 0)
    setPlayerStorageValue(cid, sentry.alreadyGiven, 0)

    setPlayerStorageValue(cid, replenish.onCooldown, 0)
    setPlayerStorageValue(cid, immortal.onCooldown, 0)
    setPlayerStorageValue(cid, stealth.onCooldown, 0)
    setPlayerStorageValue(cid, sentry.onCooldown, 0)

    setPlayerStorageValue(cid, replenish.storageCanUse, 0)
    setPlayerStorageValue(cid, immortal.storageCanUse, 0)
    setPlayerStorageValue(cid, stealth.storageCanUse, 0)
    setPlayerStorageValue(cid, sentry.storageCanUse, 0)
    
    setPlayerStorageValue(cid, immortal.storageActive, 0)

    setPlayerStorageValue(cid, kills, 0)
    
    if getPlayerStorageValue(cid, kills) < 0 then
        setPlayerStorageValue(cid, kills, 0)
    elseif getPlayerStorageValue(cid, deaths) < 0 then
        setPlayerStorageValue(cid, deaths, 0)
    end
    registerCreatureEvent(cid, "Kill streak")
    registerCreatureEvent(cid, "Immortality")
return true
end
Creaturescripts/scripts/kill streaks/onKill.lua
Code:
local kills = 1000
local deaths = 1001
local channel = 11

local explode = {
    useExplode = true,
    effect = CONST_ME_FIREATTACK,
    damage = 500, -- How much damage will the explosion do when you die.
    reqKills = 5, -- If you have 5 kills or more you will explode on death if explodeOnDeath is true.
    area = {5, 5}, -- How many sqms will the bomb cover? default 5x5. x, y.
    healthAmount = 500, -- (min, max) How much health will be restored when used.
    manaAmount = 500, -- (min, max) How much mana will be restored when used.
}

-- Replenish - Talkaction: !restore
local replenish = {
    useReplenish = true, -- true/false. If true: Will restore X health and X mana.
    healthAmount = 500, -- (min, max) How much health will be restored when used.
    manaAmount = 400, -- (min, max) How much mana will be restored when used.
    cooldown = 40, -- How long you have to wait until you can use it again, in seconds.
    reqKills = 7, -- How many kills you need to be able to use !restore.
    storageCanUse = 1002, -- Storage
    alreadyGiven = 1003, -- storage
    onCooldown = 1004, -- storage
}

-- Immortality -- Talkaction: !immortal
local immortal = {
    useImmortality = true, -- true/false. If true: You can activate immortality, makes you invulnerable against incoming damage for X seconds.
    reqKills = 10, -- How many kills you need to be able to activate immortality.    immortal.time = 25 -- How long you will be immortal, in seconds.    
    storageCanUse = 1005, -- Storage
    alreadyGiven = 1007, -- storage
    onCooldown = 1008, -- storage
}

-- Stealth - Talkaction: !stealth
local stealth = {
    useStealth =  true, -- true/false. If true: Will make you invisible for X seconds. Invisible to EVERYTHING, even players.
    reqKills = 10, -- How many kills you need to be able to use the invisibility skill.
    storageCanUse = 1010, -- storage
    alreadyGiven = 1011, -- storage
    onCooldown = 1012, -- storage
}

-- Sentry gun - Talkaction: !sentry
local sentry = {
    useSentryGun = true, -- true/false. If true: Will spawn a Sentry gun at your location, shooting everyone who you target.
    reqKills = 10, -- How many kills you need to be able to spawn the sentry gun.
    storageCanUse = 1014, -- storage
    alreadyGiven = 1015, -- storage
    onCooldown = 1016, -- storage
}

local kstreak = {
    lastKills = 8, -- How many kills you need for the last message
-- [kills]= {kills, "Message"} -- Yes kills two times..
    [1] = {1, ""},
    [2] = {2, "Double Kill!"},
    [3] = {3, "Triple Kill!"},
    [4] = {4, "Quad Kill!", ""},
    [5] = {5, "M-M-M-Monster Kill!!"},
    [6] = {6, "BLOODBATH!"},
    [7] = {7, "UNSTOPPABLE!"},
    [8] = {8, "GODLIKE!!"}} -- Will be sent if you got this much kills or more.
        
function onKill(cid, target, lastHit)
    if isPlayer(cid) and isPlayer(target) then
        if explode.useExplode then
            if getPlayerStorageValue(target, kills) >= explode.reqKills then
                local fromPos = {getPlayerPosition(target).x-explode.area[1], getPlayerPosition(target).y-explode.area[2], getPlayerPosition(target).z}
                local toPos = {getPlayerPosition(target).x+explode.area[1], getPlayerPosition(target).y+explode.area[2], getPlayerPosition(target).z}
                for x = fromPos[1], toPos[1] do
                    for y = fromPos[2], toPos[2] do
                        for z = fromPos[3], toPos[3] do
                            local pos = {x=x, y=y, z=z, stackPos=253}
                            local getCreatures = getTopCreature(explode).uid
                            doSendMagicEffect(pos, explode.effect)
                            if isCreature(getCreatures) then
                                doCreatureAddHealth(getCreatures, -explode.damage)
                            end
                        end
                    end
                end
            end
        end
        if replenish.useReplenish then
            if getPlayerStorageValue(cid, kills) >= replenish.reqKills and getPlayerStorageValue(cid, replenish.alreadyGiven) ~= 1 then
                setPlayerStorageValue(cid, replenish.storageCanUse, 1)
                setPlayerStorageValue(cid, replenish.alreadyGiven, 1)
            end
        end
        if immortal.useImmortality then
            if getPlayerStorageValue(cid, kills) >= immortal.reqKills and getPlayerStorageValue(cid, immortal.alreadyGiven) ~= 1 then
                setPlayerStorageValue(cid, immortal.storageCanUse, 1)
                setPlayerStorageValue(cid, immortal.alreadyGiven, 1)
            end
        end
        if stealth.useStealth then
            if getPlayerStorageValue(cid, kills) >= stealth.reqKills and getPlayerStorageValue(cid, stealth.alreadyGiven) ~= 1 then
                setPlayerStorageValue(cid, stealth.storageCanUse, 1)
                setPlayerStorageValue(cid, stealth.alreadyGiven, 1)
            end
        end
        if sentry.useSentryGun then
            if getPlayerStorageValue(cid, kills) >= sentry.reqKills and getPlayerStorageValue(cid, sentry.alreadyGiven) ~= 1 then
                setPlayerStorageValue(cid, sentry.storageCanUse, 1)
                setPlayerStorageValue(cid, sentry.alreadyGiven, 1)
            end
        end

        setPlayerStorageValue(cid, kills, getPlayerStorageValue(cid, kills)+1)
        setPlayerStorageValue(target, kills, 0)
        for _, tid in ipairs(getPlayersOnline()) do
            local k = kstreak[getPlayerStorageValue(cid, kills)]
            if getPlayerStorageValue(cid, kills) > kstreak.lastKills then
                local msg = kstreak[getPlayerStorageValue(cid, kills)]
                doPlayerSendChannelMessage(tid, "Streaks", getPlayerName(target) .. " [" .. getPlayerLevel(target) .. "] got eliminated by " .. getPlayerName(cid) .. " [" .. getPlayerLevel(cid) .. "] - " .. kstreak[kstreak.lastKills][2], TALKTYPE_CHANNEL_O, channel)
            elseif getPlayerStorageValue(cid, kills) == k[1] and getPlayerStorageValue(cid, kills) <= kstreak.lastKills then
                local msg = kstreak[getPlayerStorageValue(cid, kills)]
                doPlayerSendChannelMessage(tid, "Streaks", getPlayerName(target) .. " [".. getPlayerLevel(target) .. "] got eliminated by " .. getPlayerName(cid) .. " [" .. getPlayerLevel(cid) .. "] - " .. msg[2], TALKTYPE_CHANNEL_O, channel)
            end
        end
    end
return true
end
Globalevents/globalevents.xml
Code:
<globalevent name="immortal" interval="[COLOR=Red]3[/COLOR]" event="script" value="immortal.lua"/>
The red 3 means 3 seconds. So every 3 second an effect will appear on everyone who is currently immortal.

Globalevents/scripts/immortal.lua
Code:
local immortal = {
    useImmortality = true, -- true/false. If true: You can activate immortality, makes you invulnerable against incoming damage for X seconds.
    useEffect = true, -- true/false. If true: An effect will appear on the player who is immortal.
    storageActive = 1006, -- Storage when you are immortal
    effect = CONST_ME_HOLYAREA, -- If immortal.useEffect = true then you will get this effect on a immortal player every 3 seconds.
}


function onThink(interval, lastExecution, thinkInterval)
    if immortal.useImmortality then
        if immortal.useEffect then
            for _, tid in ipairs(getPlayersOnline()) do
                if getPlayerStorageValue(tid, immortal.storageActive) == 1 then
                    doSendMagicEffect(getPlayerPosition(tid), immortal.effect)
                end
            end
        end
    end
    return true
end
Talkactions/talkactions.xml
Code:
<talkaction words="!immortal;!restore;!stealth;!sentry" event="script" value="features.lua"/>
Talkactions/scripts/features.lua
Code:
local kills = 1000
local channel = 11

-- Replenish - Talkaction: !restore
local replenish = {
    useReplenish = true, -- true/false. If true: Will restore X health and X mana.
    healthAmount = 500, -- How much health will be restored when used.
    manaAmount = 400, -- How much mana will be restored when used.
    cooldown = 40, -- How long you have to wait until you can use it again, in seconds.
    reqKills = 7, -- How many kills you need to be able to use !restore.
    storageCanUse = 1002, -- Storage needed to store charges.
    alreadyGiven = 1003, -- storage
    onCooldown = 1004, -- storage
}

-- Immortality -- Talkaction: !immortal
local immortal = {
    useImmortality = true, -- true/false. If true: You can activate immortality, makes you invulnerable against incoming damage for X seconds.
    reqKills = 10, -- How many kills you need to be able to activate immortality.    immortal.time = 25 -- How long you will be immortal, in seconds.    
    time = 25,
    cooldown = 240, -- How long you must wait until you can make yourself immortal again, in seconds.
    storageCanUse = 1005, -- Storage for charges.
    storageActive = 1006, -- Storage when you are immortal
    onCooldown = 1008 -- storage
}

-- Stealth - Talkaction: !stealth
local stealth = {
    useStealth =  true, -- true/false. If true: Will make you invisible for X seconds. Invisible to EVERYTHING, even players.
    reqKills = 10, -- How many kills you need to be able to use the invisibility skill.
    time = 25, -- How long you will be invisible, in seconds.
    cooldown = 180, -- How long you will have to wait until you can use the invisibility skill again.
    storageCanUse = 1010, -- storage
    onCooldown = 1012 -- storage
}

-- Sentry gun - Talkaction: !sentry
local sentry = {
    useSentryGun = true, -- true/false. If true: Will spawn a Sentry gun at your location, shooting everyone who you target.
    reqKills = 10, -- How many kills you need to be able to spawn the sentry gun.
    time = 25, -- How long the sentry gun will be spawned.
    cooldown = 120, -- How long you will have to wait until you can spawn the sentry gun again.
    storageCanUse = 1014, -- storage
    onCooldown = 1016, -- storage
    sentryName = "Sentry Gun", -- Name of the "monster" that will be spawned as your sentry gun.
}
        
function removeStealth(cid)
    doCreatureExecuteTalkAction(cid, "/ghost", true)
    setPlayerGroupId(cid, 1)
end

function stealthCooldown(cid)
    setPlayerStorageValue(cid, stealth.onCooldown, 0)
end

function replenishCooldown(cid)
    setPlayerStorageValue(cid, replenish.onCooldown, 0)
end

function immortalCooldown(cid)
    setPlayerStorageValue(cid, immortal.onCooldown, 0)
end

function removeImmortal(cid)
    setPlayerStorageValue(cid, immortal.storageActive, 0)
end

function sentryCooldown(cid)
    setPlayerStorageValue(cid, sentry.onCooldown, 0)
end

function removeSentry(cid)
    local s = getCreatureSummons(cid)
    for _, summons in ipairs(s) do
    doRemoveCreature(summons)
    end
end
    
function onSay(cid, words, param, channel)
    if immortal.useImmortality and words == "!immortal" then
        for _, tid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, kills) >= immortal.reqKills then
                if getPlayerStorageValue(cid, immortal.onCooldown) ~= 1 then
                    if getPlayerStorageValue(cid, immortal.storageCanUse) == 1 then
                        addEvent(immortalCooldown, immortal.cooldown * 1000, cid)
                        addEvent(removeImmortal, immortal.time * 1000, cid)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now immortal!")
                        doPlayerSendChannelMessage(tid, "Streaks", getPlayerName(cid) .. " used " .. (getPlayerSex(cid) == 0 and "her" or "his") .. " immortality!!", TALKTYPE_CHANNEL_O, channel)
                        setPlayerStorageValue(cid, immortal.onCooldown, 1)
                        setPlayerStorageValue(cid, immortal.storageActive, 1)
                    else
                        doPlayerSendCancel(cid, "You can't use this ability yet!")
                    end
                else
                    doPlayerSendCancel(cid, "You have to wait " .. immortal.cooldown .. " seconds until you can use the immortal ability again!")
                end
            else
                doPlayerSendCancel(cid, "You need " .. immortal.reqKills .. " kills to use the immortal ability.")
            end
        end

    elseif replenish.useReplenish and words == "!restore" then
        for _, tid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, kills) >= replenish.reqKills then
                if getPlayerStorageValue(cid, replenish.onCooldown) ~= 1 then
                    if getPlayerStorageValue(cid, replenish.storageCanUse) == 1 then
                        doCreatureAddHealth(cid, replenish.healthAmount)
                        doCreatureAddMana(cid, replenish.manaAmount)
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HEARTS)
                        addEvent(replenishCooldown, replenish.cooldown * 1000, cid)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You used your restore ability!")
                        setPlayerStorageValue(cid, replenish.onCooldown, 1)
                    else
                        doPlayerSendCancel(cid, "You can't use this ability yet!")
                    end
                else
                    doPlayerSendCancel(cid, "You have to wait " .. replenish.cooldown .. " seconds until you can use the replenish ability again!")
                end
            else
                doPlayerSendCancel(cid, "You need " .. replenish.reqKills .. " kills to use the replenish ability.")
            end
        end

    elseif stealth.useStealth and words == "!stealth" then
        for _, tid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, kills) >= stealth.reqKills then
                if getPlayerStorageValue(cid, stealth.onCooldown) ~= 1 then
                    if getPlayerStorageValue(cid, stealth.storageCanUse) == 1 then
                        doCreatureExecuteTalkAction(cid, "/ghost", true)
                        addEvent(stealthCooldown, stealth.cooldown * 1000, cid)
                        addEvent(removeStealth, stealth.time * 1000, cid)
                        setPlayerGroupId(cid, 2)
                        doPlayerSendChannelMessage(tid, "Streaks", getPlayerName(cid) .. " used " .. (getPlayerSex(cid) == 0 and "her" or "his") .. " Stealth ability!!", TALKTYPE_CHANNEL_O, channel)
                        setPlayerStorageValue(cid, stealth.onCooldown, 1)
                    else
                        doPlayerSendCancel(cid, "You can't use this ability yet!")
                    end
                else
                    doPlayerSendCancel(cid, "You have to wait " .. stealth.cooldown .. " seconds until you can use the stealth ability again!")
                end
            else
                doPlayerSendCancel(cid, "You need " .. stealth.reqKills .. " kills to use the stealth ability.")
            end
        end
        
    elseif sentry.useSentryGun and words == "!sentry" then
        for _, tid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, kills) >= sentry.reqKills then
                if getPlayerStorageValue(cid, sentry.onCooldown) ~= 1 then
                    if getPlayerStorageValue(cid, sentry.storageCanUse) == 1 then
                        addEvent(sentryCooldown, sentry.cooldown * 1000, cid)
                        addEvent(removeSentry, sentry.time * 1000, cid)
                        doSummonMonster(cid, sentry.sentryName)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You spawned your sentry gun!")
                        doPlayerSendChannelMessage(tid, "Streaks", getPlayerName(cid) .. " spawned " .. (getPlayerSex(cid) == 0 and "her" or "his") .. " Sentry gun!!", TALKTYPE_CHANNEL_O, channel)
                        setPlayerStorageValue(cid, sentry.onCooldown, 1)
                    else
                        doPlayerSendCancel(cid, "You can't use this ability yet!")
                    end
                else
                    doPlayerSendCancel(cid, "You have to wait " .. sentry.cooldown .. " seconds until you can spawn the sentry gun again!")
                end
            else
                doPlayerSendCancel(cid, "You need " .. sentry.reqKills .. " kills to spawn a sentry gun.")
            end
        end
    else
        doPlayerSendCancel(cid, "This ability have been disabled by the admin.")
    end
end


My sentry gun, put it in monster folder.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Sentry gun" nameDescription="a sentry gun" race="undead" experience="0" speed="0" manacost="0">
    <health now="1" max="1"/>
    <look typeex="1560" corpse="1740"/>
    <targetchange interval="2000" chance="0"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="0"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="0"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="1"/>
        <flag runonhealth="100"/>
        <flag hidehealth="0"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" skill="1" attack="1"/>
        <attack name="physical" interval="1000" chance="100" range="7" min="-80" max="-140">
            <attribute key="shootEffect" value="throwingstar"/>
            <attribute key="areaEffect" value="yellowspark"/>
        </attack>
    </attacks>
    <defenses armor="1" defense="1"/>
    <immunities>
        <immunity physical="1"/>
        <immunity energy="1"/>
        <immunity fire="1"/>
        <immunity poison="1"/>
        <immunity ice="1"/>
        <immunity holy="1"/>
        <immunity death="1"/>
        <immunity lifedrain="1"/>
        <immunity manadrain="1"/>
        <immunity paralyze="1"/>
        <immunity drunk="1"/>
        <immunity outfit="1"/>
        <immunity invisible="1"/>
    </immunities>
</monster>
Known bugs;
*
Sometimes when you use the stealth ability, you will stay on the other players screen at the place where you made stealth until the other players move out of the screen. This may cause debugs. Can't really explain that good, but I hope you understand what I mean!
I don't know why the stealth bug is happening, when I make /ghost with a GM this bug never happens.
* Please report all bugs you find.


Post your ideas on how I could improve it!



Tested and working on TFS 0.3.6!
Don't tell me it doesn't work.
 
Last edited:
Kick ass this will make any and every war ots out there worthwhile,
so i think it will, also at what you guys where arguing about, even
though the creaturescript is bigger than the others the real foundation
(what will make this whole system worthwhile) is the talkactions, since
it contains what really makes this system fun, anyways that's my opinion.
 
Well I don't understand what these features have to do with killing streaks..

About the !stealth ye it is bugged. I made a lua function setPlayerGhost(cid) and had the same problem.
 
It's already in the script.. I added description on every single thing ;s

Just take a look at the talkaction script at the configs.. "reqKills"

Well I don't understand what these features have to do with killing streaks..

About the !stealth ye it is bugged. I made a lua function setPlayerGhost(cid) and had the same problem.
It was working first, then it became buggy ;s strange
 
Last edited:
Holy shit.

your other thread, I was totally joking about the sentry gun and shit. but you made it.

LOL
 
nice 1 man you added the sentry gun woop woop :p

wondering if this is possible, all killstreaks work say 5 kills 7 kills 10 kills etc...

but to activate it you can say killstreak without the "!" and it works if you have killed the ammount you need to activate that killstreak it works?

example:

i have 7 kills i say "killstreak" and it uses one. i also then get 10 kills and i can then say "killstreak" again to activate another one but with the same word
 
Last edited:
function onCombat(cid, target)
[...]

will give error if target is monster.
 
Yo Slaktaren, why happened to the MOD? Why did it fuck up?
you probably had a misplaced 'domodlib' that happened to us
with our MOD it would fuck up even though the whole script
was bad. Anyways just asking!
 
Back
Top