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

Action on item throw?

Forum General

1st Donator Division
Joined
May 6, 2010
Messages
200
Reaction score
1
Location
Toronto, Canada
Is it possible to do an actions script that does X when the item is tossed to the ground?

For example, if I were to toss [item 8840] 5 squares from me, it would start a script or something.

What I really want it to do;
You throw [item 8840] anywhere and it ticks 3 seconds, then blows up, creating a 3x3 explosion and damages everyone in that radius.
It's basically like a grenade.

Also, when you're in PZ, it doesn't tick or blow up when you throw it, to prevent PZ abuse.
 
Yea, that's my idea. But most of those (invisible) items are blocking. And uh, if they have 'lookThrough' attribute, you can move the item even if they're on top of it ;/ (This only applies to invisible items)
 
I tried putting some kind of glittery object on top of a item, and it didn't move the item nor the glittery object. So, I guess a glitter wouldn't be too bad. And it is a look-through.

8046 - glitter ID.

Can that be possible for you?
 
Okay this is what I've made so far:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
function onGetFormulaValues(cid, level, maglevel)
	return -50, -75
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

local function blowUp(pos, guid)
	pos.stackpos = 1
	while getThingfromPos(pos).uid > 0 do
		local v = getThingfromPos(pos)
		if v.actionid == guid + 100 then
			local p = getPlayerByGUID(guid)
			if p then
				local op = getThingPos(p)
				if op.z ~= pos.z then
					doTeleportThing(p, pos)
				end
				doCombat(p, combat, positionToVariant(pos))
				doTeleportThing(p, op)
			else
				doSendMagicEffect(pos, CONST_ME_POFF)
			end
			doRemoveItem(v.uid)
			pos.stackpos = pos.stackpos - 1
			local k = getThingfromPos(pos)
			if k.itemid == 8046 then
				doRemoveItem(k.uid)
			else
				pos.stackpos = pos.stackpos + 1
				doRemoveItem(getThingfromPos(pos).uid)
			end
			break
		end
		pos.stackpos = pos.stackpos + 1
	end
end

function onAddItem(moveItem, tileItem, position, cid)
	if isPlayer(cid) and not getTileInfo(getThingPos(cid)).protection and not getTileInfo(position).protection and getTileItemByType(position, ITEM_TYPE_TELEPORT).uid < 1 then
		doCreateItem(8046, 1, position)
		doItemSetAttribute(moveItem.uid, "aid", getPlayerGUID(cid) + 100)
		addEvent(blowUp, 3000, position, getPlayerGUID(cid))
		doSendAnimatedText(position, 3, TEXTCOLOR_RED)
		addEvent(doSendAnimatedText, 1000, position, 2, TEXTCOLOR_RED)
		addEvent(doSendAnimatedText, 2000, position, 1, TEXTCOLOR_RED)
	end
end
Add in movements.xml:
Code:
	<movevent type="AddItem" itemid="8840" event="script" value="bomb.lua"/>
 
Last edited:
[06/05/2010 20:32:23] [Error - LuaScriptInterface::loadFile] data/movements/scripts/bomb.lua:12: 'do' expected near '0'
[06/05/2010 20:32:23] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/bomb.lua)
[06/05/2010 20:32:23] data/movements/scripts/bomb.lua:12: 'do' expected near '0'
 
bugas
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
function onGetFormulaValues(cid, level, maglevel)
	return -50, -75
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

local function blowUp(pos, guid)
	pos.stackpos = 1
	while [B][COLOR="Red"](getThingfromPos(pos).uid > 0)[/COLOR][/B] do
		local v = getThingfromPos(pos)
		if v.actionid == guid + 100 then
			if getPlayerByGUID(guid) then
				doCombat(getPlayerByGUID(guid), combat, positionToVariant(pos))
			else
				doSendMagicEffect(pos, CONST_ME_POFF)
			end
			doRemoveItem(v.uid)
			pos.stackpos = pos.stackpos - 1
			local k = getThingfromPos(pos)
			if k.itemid == 8046 then
				doRemoveItem(k.uid)
			else
				pos.stackpos = pos.stackpos + 1
				doRemoveItem(getThingfromPos(pos).uid)
			end
			break
		end
		pos.stackpos = pos.stackpos + 1
	end
end

function onAddItem(moveItem, tileItem, position, cid)
	if isPlayer(cid) and not getTileInfo(getThingPos(cid)).protection and not getTileInfo(position).protection and getTileItemByType(position, ITEM_TYPE_TELEPORT).uid < 1 then
		doCreateItem(8046, 1, position)
		doItemSetAttribute(moveItem.uid, "aid", getPlayerGUID(cid) + 100)
		addEvent(blowUp, 3000, position, getPlayerGUID(cid))
		doSendAnimatedText(position, 3, TEXTCOLOR_RED)
		addEvent(doSendAnimatedText, 1000, position, 2, TEXTCOLOR_RED)
		addEvent(doSendAnimatedText, 2000, position, 1, TEXTCOLOR_RED)
	end
end
works for me btw
 
Last edited:
Is it possible to do an actions script that does X when the item is tossed to the ground?

For example, if I were to toss [item 8840] 5 squares from me, it would start a script or something.

What I really want it to do;
You throw [item 8840] anywhere and it ticks 3 seconds, then blows up, creating a 3x3 explosion and damages everyone in that radius.
It's basically like a grenade.

Also, when you're in PZ, it doesn't tick or blow up when you throw it, to prevent PZ abuse.

Also, is it possible that it give a PZ-lock when you throw it? People can just go out of PZ and throw it and go back in.
 
No, it's not possible ;/

Also, it IS 3x3

Edit: Updated script, the bomb will now detonate even if you're not on the same floor as it.
 
Last edited:
Back
Top