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:
In data\movements\movements.xml:
So, what do I need to edit?
In bossBailout.lua:
-- Under function AddItem, you just need to edit:
-- Under function removeCreature, you just need to edit:
Map instructions:
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!
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:
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: