• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Grenade

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
Well, this is a grenade script, is basically the same system as cs-tibia.com server.
Lua:
function isWalkable(pos, creature, proj, pz)-- by Nord
        if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
        if getTopCreature(pos).uid > 0 and creature then return false end
        if getTileInfo(pos).protection and pz then return false, true end
        local n = not proj and 3 or 2
        for i = 0, 255 do
                pos.stackpos = i
                local tile = getTileThingByPos(pos)
                if tile.itemid ~= 0 and not isCreature(tile.uid) then
                        if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                                return false
                        end
                end
        end
        return true
end
function getTime(s)
        local n = math.floor(s / 60)
        s = s - (60 * n)
        return n, s
end
local items = {
[2388] = {
	delay  = 1, -- seconds
	mindamage = -1, 
	maxdamage = -30, 
	damagetype = COMBAT_FIREDAMAGE, 
	storagetime = 643, 
	time = 13
}
}
local bombstorage = 38477422
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by Xafterin
local function boom(cid, min, max, damagetype, pos)
	-- COMBAT FUNCTION --	
	local area = {
		{x = pos.x+1, y = pos.y, z = pos.z},
		{x = pos.x, y = pos.y+1, z = pos.z},
		{x = pos.x-1, y = pos.y, z = pos.z},
		{x = pos.x+1, y = pos.y+1, z = pos.z},
		{x = pos.x-1, y = pos.y-1, z = pos.z},
		{x = pos.x, y = pos.y-1, z = pos.z},
		{x = pos.x+1, y = pos.y-1, z = pos.z},
		{x = pos.x-1, y = pos.y+1, z = pos.z},
		{x = pos.x, y = pos.y, z = pos.z}
		}
	for i = 1,#area do
		doAreaCombatHealth(0, damagetype, area[i], 0, min, max, 0) 
	end
	doRemoveItem(getPlayerStorageValue(cid, bombstorage), 1)
	return true
end
	local gren = items[item.itemid]
	if gren then
		if not isWalkable(toPosition, false, false, false) then
			return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You cannot throw the ".. getItemNameById(item.itemid) .." here!.")
		end
		if getTilePzInfo(getCreaturePosition(cid)) or getTilePzInfo(toPosition) then 
			return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You cannot use this weapon in a protection zone!.")
		end
		local time = gren.time
		if os.time()-getPlayerStorageValue(cid, gren.storagetime)+1 <= time then
			minutes,seconds = getTime(time-(os.time()-getPlayerStorageValue(cid, gren.storagetime)))
			return  doPlayerSendTextMessage(cid, 27, "Wait "..seconds.." seconds.")
		end		
		local k = doCreateItem(item.itemid, 1, toPosition)
		setPlayerStorageValue(cid, bombstorage, item.uid-6000)
		doItemSetAttribute(k, "uid", item.uid-6000)
		addEvent(boom, gren.delay * 1000, cid, gren.min, gren.max, gren.damagetype, toPosition)
		setPlayerStorageValue(cid, gren.storagetime, os.time())
		doRemoveItem(item.uid, 1)
		doPlayerAddSkillTry(cid, 5, 1)   
	end
	return true
end

actions.xml
XML:
<action itemid="grenadeid" event="script" value="name.lua" allowfaruse="1"/>
 
Last edited:
Thx 10/10
+1

EDITED Aint Working....
using 0.4.0
 
Last edited:
Yeah, I was about to say the same, don't know if I'm using the item in-game right..
No errors in the console, but it just doesn't seem to be working.
 
I have tested on 0.3.6pl1 and the script is completlly working.
 
There's seems to be a problem with dealing damage? Shouldn't there be 'damagetype = FIREDAMAGE,' instead of 'combat_firedamage'? That way mosnters at least show poff effect still there's no damage. Am I lame and can't config it or the script itself is ^^ ?
 
Back
Top