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

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,670
Solutions
125
Reaction score
1,117
Location
Germany
GitHub
slawkens
Its combination, action + movement. :}

movements/scripts/fireworks rocket.lua
1. Replace data\actions\scripts\other\fireworksrocket.lua with this:

How it works?
You place firework (Id: 6576) on FIRE FIELD, and it will automatically start timer, and after 5 seconds boom :p

You can also simply USE it. It will also work !
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if fromPosition.x ~= CONTAINER_POSITION then
		fireWorkRocketBoom(fromPosition)
	else
		doSendMagicEffect(fromPosition, CONST_ME_HITBYFIRE)
		doSendMagicEffect(fromPosition, CONST_ME_EXPLOSIONAREA)
		doCreatureSay(cid, "Ouch! Rather place it on the ground next time.", TALKTYPE_ORANGE_1)
		doCreatureAddHealth(cid, -10)
	end
	doRemoveItem(cid, item.uid, 1)
	return TRUE
end

2. Create new file, movements/script/fireworksrocket.lua
Code:
--by slaw
--Config
local timeToBoom = 5
local fireFields = {1487, 1488, 1489, 1492, 1493, 1494}

function fireWorkTimer(seconds, pos, itemid)
	local tmp = getTileItemById(pos, itemid)
	if tmp.uid == FALSE then
		return FALSE
	end

	if seconds == 0 then
		fireWorkRocketBoom(pos)
		doRemoveItemFromPos(pos, itemid)
		return TRUE
	end

	doSendAnimatedText(pos, seconds, 150)

	seconds = seconds - 1
	addEvent(fireWorkTimer, 1000, seconds, pos, itemid)
end

function onAddItem(moveitem, tileitem, pos)
	pos.stackpos = STACKPOS_TOP_FIELD
	if isInArray(fireFields, getThingFromPos(pos).itemid) == TRUE then
		fireWorkTimer(timeToBoom, pos, moveitem.itemid)
	end

	return TRUE
end

movements.lua
Code:
	<!-- FIREROCKET by slawkens -->
	<movevent event="AddItem" itemid="6576" script="fireworks.lua" />

global.lua/function.lua
Code:
function fireWorkRocketBoom(fromPosition)
		local tmpPos = {}
		local i = 4
		while(i >= 1) do

			tmpPos = {x=fromPosition.x - i, y=fromPosition.y - i, z=fromPosition.z, stackpos=0}
			if isSightClear(fromPosition, tmpPos, FALSE) == TRUE then
				if(hasProperty(getThingFromPos(tmpPos).uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) ~= TRUE) then
					doSendDistanceShoot(fromPosition, tmpPos, 3)
					addEvent(doSendMagicEffect, 350, tmpPos, math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
					break
				end
			end
			i = i - 1
		end
end

There is also needed this function to work: (Place in global.lua, or function.lua if 0.3)
http://otland.net/f163/doremoveitemfrompos-18703/#post189330

Btw. Happy new year!:thumbup:
 
Last edited:
Back
Top