This script was originally created by Slaktaren. I converted it into a Mod. So all credits goes to the original scripter.
Make a new file in the Mods folder called killstreak.xml and add this
Then goto ...\mods\monsters\custom and create a file called sentry gun.xml and add this
and in mods\custommonsters.xml add this line
and your done.
Original Post
This mod was tested using TFS 0.3.6!
Make a new file in the Mods folder called killstreak.xml and add this
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Killstreak" version="1.0" author="Collz" contact="none" enabled="yes">
<event type="login" name="streakLogin" event="script"><![CDATA[
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
]]></event>
<event type="combat" name="Immortality" event="script"><![CDATA[
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
]]></event>
<event type="kill" name="Kill streak" event="script"><![CDATA[
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
]]></event>
<globalevent name="immortal" interval="3" event="script"><![CDATA[
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
]]></globalevent>
<talkaction words="!immortal;!restore;!stealth;!sentry" event="script"><![CDATA[
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
]]></talkaction>
</mod>
XML:
<?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>
XML:
<monster name="Sentry Gun" file="Custom/sentry gun.xml"/>
Original Post
This mod was tested using TFS 0.3.6!
Last edited: