Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unrealized dream and explosive present #214

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/actions/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@
<action fromid="14767" toid="14771" script="other/hive_doors2.lua" />

<!-- Other -->
<action itemid="22598" script="other/unrealized_dream.lua" />
<action itemid="8110" script="other/explosive_present.lua" />
<action itemid="11339" script="other/claylump.lua" />
<action itemid="3955" script="other/voodoo_doll.lua" />
<action itemid="5468" script="other/firebug.lua" />
Expand Down
6 changes: 6 additions & 0 deletions data/actions/scripts/other/explosive_present.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:say("KABOOOOOOOOOOM!", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
item:remove()
return true
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always add a new line in the end of new files, and in this one add the achievement as well :P

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new lines and that achievement.
Just curious - why new line?

69 changes: 69 additions & 0 deletions data/actions/scripts/other/unrealized_dream.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
local items = {
{1032, "Snowball", "You try to concentrate and your dream comes true. You wished for something cool."},
{1070, "Rubbish", "You try to concentrate and your dream comes true. You knew it would be some rubbish!"},
{485, "Piggy Bank", "You try to concentrate and your dream comes true. You just thought about your wealth."},
{956, "Blue Rose", "You try to concentrate and your dream comes true. You just thought about spring."},
{481, "Lute", "You try to concentrate and your dream comes true. Well, part of. You thought about getting rich and a pile of loot..."},
{960, 8110, "You try to concentrate and your dream comes true. You were that curious for the surprise."},
{956, "Simple Dress", "You try to concentrate and ... Oops, where did that dream come from?"},
{188, "Silver Prison Key", "You try to concentrate and your dream comes true. You just thought about a true challenge."},
{419, "Spellwand", "You try to concentrate and your dream comes true. Somehow you seemed to get distracted when you thought of Ferumbras."},
{977, "Dice", "You try to concentrate and your dream comes true. You just wondered if you'd be lucky this time."},
{95, "Mirror", "You try to concentrate and your dream comes true. You shouldn't really think about yourself that often."},
{128, "Cluster of Solace", "You try to concentrate and your dream comes true. You thought of your last night's dream, You try to concentrate and your dream comes true. You couldn't focus on anything specific."},
{320, "Meat", "You try to concentrate and your dream comes true. Unfortunately you were subconsciouly thinking about something to eat."},
{383, "Goldfish Bowl", "You try to concentrate and your dream comes true. You just thought about a loyal companion."},
{204, "Copper Prison Key", "You try to concentrate and your dream comes true. You just thought about a true challenge."},
{203, "Bronze Prison Key", "You try to concentrate and your dream comes true. You just thought about a true challenge."},
{50, "Golden Prison Key", "You try to concentrate and your dream comes true. You just thought about a true challenge."},
{60, "Wedding Ring", "You try to concentrate and your dream comes true. You wonder what were you thinking about."},
{41, "Stuffed Bunny", "You try to concentrate and your dream comes true. You just thought about having a true friend."},
{51, "Dream Warden Claw", "You try to concentrate and your dream comes true. You wonder what were you thinking about."},
{59, "Pair of Earmuffs", "You try to concentrate and your dream comes true. Sadly you had cold ears just in that moment."},
{23, "Bag of Apple Slices", "You try to concentrate and your dream comes true. You thought about your sore feet."}
}

local function randomizeItem()
local x, y = 0, 0
for i = 1, #items do
local itemChance = items[i][1]
x = x + itemChance
end

local chance = math.random(x)
for i = 1, #items do
local dasChance = items[i][1]
itemName = items[i][2]
itemMessage = items[i][3]
y = y + dasChance
if y > chance then
break
end
end
return itemName, itemMessage
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local spectators = Game.getSpectators(Position(33628, 32370, 5), false, true, 20, 20, 20, 20)
if #spectators < 1 then
return false
end

for i = 1, #spectators do
local spectator = spectators[i]
if spectator.uid ~= player.uid then
-- should it send some message if player isn't near the dreamcatcher device?
return false
end
end

randomizeItem()
if not player:addItem(itemName) then
print("Bug in unrealizedDream.lua. Could not create ".. itemName ..". Player name: ".. player:getName() ..".")
return false
end

item:remove(1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, itemMessage)
return true
end