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

MoveEvent Boss Bailout

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,019
Solutions
1
Reaction score
1,029
Location
United States
So, I was bored one day, been trying to work on my server little bits by little bits.
And I came up with this one idea of bailing out something. And I wanted to use a very rare function in it (onAddItem).

So, I was trying to figure out how I should use both ideas and put them into one script. I came up with an idea of some kind of wishing well method.
The wishing well method is when you put something in something, then something happens.

Therefore, in this script, if you put gold in a specific area, then something will happen, in this case, a boss will be bailed out.
Every gold will be counted and added up and the required amount will be deducted. When the required amount reaches 0 or less, the boss is bailed out and will be summoned elsewhere.

Let's begin adding the scripts, then I'll do the explanations in the end.

In data\movements\scripts\bossBailout.lua:
Lua:
-- BOSS BAILOUT
-- By: Evan @ otland.net

local goldCoins = {
	[2148] = {worth = 1},
	[2152] = {worth = 100},
	[2160] = {worth = 10000}
}

-- This function was made to remove a creature from the jail (to make it look more realistic) --
function removeCreature()
	for x = 1035, 1039 do -- location of the boss in jail (x = topLeft, topRight)
		for y = 1002, 1005 do -- location of the boss in jail (y = bottomLeft, topLeft)
			local a = getTopCreature({x=x, y=y, z=7}).uid -- Don't forget to change the z-coordinate if necessary
			if a ~= 0 and isMonster(a) then
				doRemoveCreature(a)
			end
		end
	end
	return true
end

-- This function is used when the amount of gold is reached --
function doSomething() 
		doCreateMonster(newBoss, newBossLocation)
		doBroadcastMessage(releaseMessage, advance)
		setGlobalStorageValue(goldStore, 0)
		doSetItemSpecialDescription(object.uid, "There are 0 gold coins in here.\n"..(targetCount).." more gold coins is needed.")
		removeCreature()
	return true
end

-- Main function --
function onAddItem(moveitem, tileitem, position)
-- YOU CAN CHANGE ANYTHING HERE --
goldStore = 8890 								-- The storage ID of where the amount of gold is stored
pos = {x = 1037, y = 1012, z = 7, stackpos = 1} -- Location of the sign
targetCount = 3500000							-- The amount of gold that is required to doSomething()
newBoss = 'Orshabaal'							-- The boss that will be bailed out
newBossLocation = {x = 1025, y = 1036, z = 7}	-- The location where the boss will be summoned
releaseMessage = "It was a hefty payment, but the Orshabaal has been bailed out!" -- The message sent when the boss is bailed out
-- DO NOT CHANGE ANYTHING HERE UNLESS YOU KNOW WHAT YOU'RE DOING --
goldCountStore = getGlobalStorageValue(goldStore)
object = getThingFromPos(pos)
goldWeight = getItemWeight(moveitem.uid) * 10

local v = goldCoins[moveitem.itemid]
	if v then
		doRemoveItem(moveitem.uid)
		doSendMagicEffect(position, 3)
		setGlobalStorageValue(goldStore, goldCountStore + (goldWeight * v.worth))
		doSetItemSpecialDescription(object.uid, "There are " ..(goldCountStore + (goldWeight * v.worth)).. " gold coins in here.\n"..(targetCount - (goldCountStore + (goldWeight * v.worth))).." more gold coins is needed.")
		if ((targetCount - (goldCountStore + (goldWeight * v.worth)))) <= 0 then
			doSomething()
		end
	else
		doRemoveItem(moveitem.uid)
		doSendMagicEffect(position, CONST_ME_POFF)
	end
	return true
end

In data\movements\movements.xml:
Lua:
<movevent type="AddItem" tileitem="1" actionid="8910" event="script" value="bossBailout.lua"/>



So, what do I need to edit?

In bossBailout.lua:
-- Under function AddItem, you just need to edit:
Lua:
goldStore = 8890 								-- The storage ID of where the amount of gold is stored
pos = {x = 1037, y = 1012, z = 7, stackpos = 1} -- Location of the sign
targetCount = 3500000							-- The amount of gold that is required to doSomething()
newBoss = 'Orshabaal'							-- The boss that will be bailed out
newBossLocation = {x = 1025, y = 1036, z = 7}	-- The location where the boss will be summoned
releaseMessage = "It was a hefty payment, but the Orshabaal has been bailed out!" -- The message sent when the boss is bailed out

-- Under function removeCreature, you just need to edit:
Lua:
	for x = 1035, 1039 do -- location of the boss in jail (x = topLeft, topRight)
		for y = 1002, 1005 do -- location of the boss in jail (y = bottomLeft, topLeft)
			local a = getTopCreature({x=x, y=y, z=7}).uid -- Don't forget to change the z-coordinate if necessary


Map instructions:

Zf0bz.png



IF YOU WANT IT TO SUMMON A RANDOM MONSTER FROM AN ARRAY:
http://otland.net/f81/boss-bailout-149128/index3.html#post1529977


ALL QUESTIONS, SUGGESTIONS, COMMENTS, CRITICISM, LIKES, REPS, ANYTHING IS WELCOME!
 
Last edited:
I gotta admit that's pretty awesome, going to try it out later. what happens if people throw junk in there?
 
I gotta admit that's pretty awesome, going to try it out later. what happens if people throw junk in there?

Nothing will happen, it will poof the item.
 
so it teleports the creature outside, or does it remove the tittles of the cage
 
Not hard to add, just it wasn't fitting for my map.
 
Any idea why it's not bailing out the monster? I add the money and nothing changes at all.

Does the monster need to be placed in the jail as a spawn as well?
 
Everything works except that the boss doesn't get tped out and I get this error.
Code:
[19:51:45.149] [Error - MoveEvents Interface]
[19:51:45.149] data/movements/scripts/bossbailout.lua nAddItem
[19:51:45.149] Description:
[19:51:45.149] data/movements/scripts/bossbailout.lua:52: attempt to call global 'doSetItemSpecialDescription' (a nil value)
[19:51:45.149] stack traceback:
[19:51:45.149]  data/movements/scripts/bossbailout.lua:52: in function <data/movements/scripts/bossbailout.lua
Can you help fix it?:p
 
Hmm, when it fails to attempt calling the function, in most cases, it means the function does not exist.
This could possibly mean you're not using the latest TFS, in other words, you're using a server that is 8.6 or something.

I'm not sure if the 8.6 version of TFS has a similar function but a different name, if it does, then you can just change the name.
If it doesn't then you can probably program the function in the sources, but that's something that I'm currently not good at.

However, there are several alternatives, you can remove that line of code and use something else, like a command that will tell how much gold has been placed in.
 
Back
Top