Skip to content
Snippets Groups Projects
Commit 3b1f3178 authored by DarkGod's avatar DarkGod
Browse files

New cosmetic donator feature: Shimmering! In the Fortress you can now unlock...

New cosmetic donator feature: Shimmering! In the Fortress you can now unlock the Mirror of Reflections to alter the doll image of any worn items to any other item's you wore on any characters (on the same computer) that have the same type/subtype! Look amazing, awesome, plain, strange, your choice now!
parent fb21eff7
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -97,6 +97,17 @@ function _M:getInven(id)
end
end
--- Returns the content of an inventory as a table
function _M:getInvenDef(id)
if type(id) == "number" then
return self.inven_def[id]
elseif type(id) == "string" then
return self.inven_def[self["INVEN_"..id]]
else
return nil
end
end
--- Tells if an inventory still has room left
function _M:canAddToInven(id)
if type(id) == "number" then
......
......@@ -1820,11 +1820,11 @@ function _M:setupCommands()
end end,
[{"_g","ctrl"}] = function() if config.settings.cheat then
for _, ip in ipairs{
{"armor", "cloak"},
{"armor", "head"},
} do
for tier = 1, 5 do
local special = function(e) return e.material_level == tier and (not ip[3] or ip[3](e)) end
local o = game.zone:makeEntity(game.level, "object", {ignore_material_restriction=true, type=ip[1], subtype=ip[2], special=special, not_properties={"unique"}, ego_filter={ego_chance=-1000}}, nil, true)
local o = game.zone:makeEntity(game.level, "object", {ignore_material_restriction=true, type=ip[1], subtype=ip[2], special=special, not_properties={"unique"}, ego_filter={ego_chance=100}}, nil, true)
if o then
o:identify(true)
game.zone:addEntity(game.level, o, "object", game.player.x, game.player.y)
......
......@@ -1399,6 +1399,12 @@ function _M:onWear(o, slot, bypass_set)
if o.power_source and o.power_source.antimagic and not game.party:knownLore("nature-vs-magic") and self:attr("has_arcane_knowledge") then
game.party:learnLore("nature-vs-magic")
end
-- Shimmer stuff
local invendef = self:getInvenDef(slot)
if invendef and invendef.infos and invendef.infos.shimmerable then
world:unlockShimmer(o)
end
end
--- Call when an object is added
......
......@@ -86,3 +86,33 @@ function _M:hasSeenZone(short_name)
self.seen_zones = self.seen_zones or {}
return self.seen_zones[short_name]
end
function _M:unlockShimmer(o)
if not o.slot or type(o.type) ~= "string" or type(o.subtype) ~= "string" then return end
self.unlocked_shimmers = self.unlocked_shimmers or {}
local shimmer_name
local unique = nil
if o.unique and not o.randart then
shimmer_name = o:getName{do_color=true, no_add_name=true, no_image=true, force_id=true}
unique = true
elseif o.__original and not o.__original.randart then
o = o.__original
shimmer_name = o:getName{do_color=true, no_add_name=true, no_image=true, force_id=true}
else
return
end
local moddables = {}
for _, p in ipairs{"moddable_tile", "moddable_tile2", "moddable_tile_back", "moddable_tile_hood", "moddable_tile_particle", "moddable_tile_ornament"} do
if o[p] then moddables[p] = o[p] end
end
if next(moddables) then
self.unlocked_shimmers[o.slot] = self.unlocked_shimmers[o.slot] or {}
if not self.unlocked_shimmers[o.slot][shimmer_name] then
game.log("#LIGHT_BLUE#New shimmer option unlocked: #{italic}#%s#{normal}#", shimmer_name)
end
self.unlocked_shimmers[o.slot][shimmer_name] = { type = o.type, subtype = o.subtype, unique=unique, moddables = moddables}
end
end
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2016 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local function shimmer(player, slot)
return function()
package.loaded['mod.dialogs.Shimmer'] = nil
local d = require("mod.dialogs.Shimmer").new(player, slot)
game:registerDialog(d)
end
end
local answers = {}
for slot, inven in pairs(player.inven) do
if player.inven_def[slot].infos and player.inven_def[slot].infos.shimmerable and inven[1] then
local o = inven[1]
if o.slot then
answers[#answers+1] = {"[Alter the appearance of "..o:getName{do_color=true, no_add_name=true}.."]", action=shimmer(player, slot), jump="welcome"}
end
end
end
answers[#answers+1] = {"[Leave the mirror alone]"}
newChat{ id="welcome",
text = [[*#LIGHT_GREEN#As you gaze into the mirror you see an infinite number of slightly different reflections of yourself. You feel dizzy.#WHITE#*]],
answers = answers
}
return "welcome"
......@@ -353,3 +353,18 @@ newEntity{
always_remember = true,
block_move = true,
}
newEntity{
define_as = "SHIMMER_CONTROL",
name = "Mirror of Reflection", image = "terrain/solidwall/solid_floor1.png", add_displays = {class.new{image="terrain/pedestal_orb_02.png", display_h=2, display_y=-1}},
display = '*', color=colors.PURPLE,
notice = true,
always_remember = true,
block_move = function(self, x, y, e, act, couldpass)
if e and e.player and act then
local chat = require("engine.Chat").new("shertul-fortress-shimmer", self, e, {player=e})
chat:invoke()
end
return true
end,
}
......@@ -38,7 +38,7 @@ function _M:init(source)
local recur = false
if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 then
local donation_features = { "#GOLD#Custom character tiles#WHITE#", "#GOLD#Exploration mode (infinite lives)#WHITE#"}
local donation_features = { "#GOLD#Custom character tiles#WHITE#", "#GOLD#Exploration mode (infinite lives)#WHITE#", "#GOLD#Item's appearance change (Shimmering)#WHITE#"}
self:triggerHook{"DonationDialog:features", list=donation_features}
-- First time donation
......
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2016 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Dialog = require "engine.ui.Dialog"
local Textzone = require "engine.ui.Textzone"
local ActorFrame = require "engine.ui.ActorFrame"
local List = require "engine.ui.List"
module(..., package.seeall, class.inherit(Dialog))
function _M:init(player, slot)
self.true_actor = player
self.true_object = player:getInven(slot)[1]
self.actor = player:cloneFull()
self.actor.x, self.actor.y = nil, nil
self.actor:removeAllMOs()
self.object = self.actor:getInven(slot)[1]
local oname = self.object:getName{do_color=true, no_add_name=true}
Dialog.init(self, "Shimmer object: "..oname, 680, 500)
self:generateList()
self.c_list = List.new{scrollbar=true, width=300, height=self.ih - 5, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
local donatortext = ""
if not profile:isDonator(1) then donatortext = "\n#{italic}##CRIMSON#This cosmetic feature is only available to donators/buyers. You can only preview.#WHITE##{normal}#" end
local help = Textzone.new{width=math.floor(self.iw - self.c_list.w - 20), height=self.ih, no_color_bleed=true, auto_height=true, text="You can alter "..oname.." to look like an other item of the same type/slot.\n#{bold}#This is a purely cosmetic change.#{normal}#"..donatortext}
local actorframe = ActorFrame.new{actor=self.actor, w=128, h=128}
self:loadUI{
{left=0, top=0, ui=self.c_list},
{right=0, top=0, ui=help},
{right=(help.w - actorframe.w) / 2, vcenter=0, ui=actorframe},
}
self:setupUI(false, true)
self.key:addBinds{
EXIT = function()
game:unregisterDialog(self)
end,
}
end
function _M:use(item)
if not item then end
game:unregisterDialog(self)
if profile:isDonator(1) then
self.true_object.shimmer_moddable = item.moddables
self.true_actor:updateModdableTile()
else
Dialog:yesnoPopup("Donator Cosmetic Feature", "This cosmetic feature is only available to donators/buyers.", function(ret) if ret then
game:registerDialog(require("mod.dialogs.Donation").new("shimmer ingame"))
end end, "Donate", "Cancel")
end
end
function _M:select(item)
if not item then end
self.object.shimmer_moddable = item.moddables
self.actor:updateModdableTile()
end
function _M:generateList()
local unlocked = world.unlocked_shimmers and world.unlocked_shimmers[self.object.slot] or {}
local list = {}
list[#list+1] = {
moddables = {},
name = "#GREY#[Invisible]",
sortname = "--",
}
for name, data in pairs(unlocked) do
if self.object.type == data.type and self.object.subtype == data.subtype then
list[#list+1] = {
moddables = table.clone(data.moddables, true),
name = name,
sortname = name:removeColorCodes(),
}
end
end
table.sort(list, "sortname")
self.list = list
end
......@@ -87,8 +87,13 @@ function _M:use(item)
local a = game.zone:finishEntity(game.level, "object", e)
a.no_unique_lore = true -- to not spam
a:identify(true)
if a.name == a.unided_name then print("=================", a.name) end
game.zone:addEntity(game.level, a, "object", game.player.x, game.player.y)
if a.slot then
local invendef = game.player:getInvenDef(a.slot)
if invendef and invendef.infos and invendef.infos.shimmerable then
world:unlockShimmer(a)
end
end
end
end
elseif act == "magic_map" then
......
......@@ -117,20 +117,20 @@ KeyBind:load("move,hotkeys,inventory,actions,interface,tome,debug")
dofile("/mod/resolvers.lua")
-- Body parts
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.", nil, {equipdoll_back="ui/equipdoll/mainhand_inv.png"})
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use shields or a second weapon in your off-hand, if you have the talents for it.", nil, {equipdoll_back="ui/equipdoll/offhand_inv.png"})
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.", nil, {equipdoll_back="ui/equipdoll/mainhand_inv.png", shimmerable=true})
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use shields or a second weapon in your off-hand, if you have the talents for it.", nil, {equipdoll_back="ui/equipdoll/offhand_inv.png", shimmerable=true})
ActorInventory:defineInventory("PSIONIC_FOCUS", "Psionic focus", true, "Object held in your telekinetic grasp. It can be a weapon or some other item to provide a benefit to your psionic powers.", nil, {equipdoll_back="ui/equipdoll/psionic_inv.png", etheral=true})
ActorInventory:defineInventory("FINGER", "On fingers", true, "Rings are worn on fingers.", nil, {equipdoll_back="ui/equipdoll/ring_inv.png"})
ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets are worn around the neck.", nil, {equipdoll_back="ui/equipdoll/amulet_inv.png"})
ActorInventory:defineInventory("LITE", "Light source", true, "A light source allows you to see in the dark places of the world.", nil, {equipdoll_back="ui/equipdoll/light_inv.png"})
ActorInventory:defineInventory("BODY", "Main armor", true, "Armor protects you from physical attacks. The heavier the armor the more it hinders the use of talents and spells.", nil, {equipdoll_back="ui/equipdoll/body_inv.png"})
ActorInventory:defineInventory("CLOAK", "Cloak", true, "A cloak can simply keep you warm or grant you wondrous powers should you find a magical one.", nil, {equipdoll_back="ui/equipdoll/cloak_inv.png"})
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head.", nil, {equipdoll_back="ui/equipdoll/head_inv.png"})
ActorInventory:defineInventory("BODY", "Main armor", true, "Armor protects you from physical attacks. The heavier the armor the more it hinders the use of talents and spells.", nil, {equipdoll_back="ui/equipdoll/body_inv.png", shimmerable=true})
ActorInventory:defineInventory("CLOAK", "Cloak", true, "A cloak can simply keep you warm or grant you wondrous powers should you find a magical one.", nil, {equipdoll_back="ui/equipdoll/cloak_inv.png", shimmerable=true})
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head.", nil, {equipdoll_back="ui/equipdoll/head_inv.png", shimmerable=true})
ActorInventory:defineInventory("BELT", "Around waist", true, "Belts are worn around your waist.", nil, {equipdoll_back="ui/equipdoll/belt_inv.png"})
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.", nil, {equipdoll_back="ui/equipdoll/hands_inv.png"})
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.", nil, {equipdoll_back="ui/equipdoll/boots_inv.png"})
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.", nil, {equipdoll_back="ui/equipdoll/hands_inv.png", shimmerable=true})
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.", nil, {equipdoll_back="ui/equipdoll/boots_inv.png", shimmerable=true})
ActorInventory:defineInventory("TOOL", "Tool", true, "This is your readied tool, always available immediately.", nil, {equipdoll_back="ui/equipdoll/tool_inv.png"})
ActorInventory:defineInventory("QUIVER", "Quiver", true, "Your readied ammo.", nil, {equipdoll_back="ui/equipdoll/ammo_inv.png"})
ActorInventory:defineInventory("QUIVER", "Quiver", true, "Your readied ammo.", nil, {equipdoll_back="ui/equipdoll/ammo_inv.png", shimmerable=true})
ActorInventory:defineInventory("GEM", "Socketed Gems", true, "Gems worn in/on the body, providing their worn bonuses.", nil, {equipdoll_back="ui/equipdoll/gem_inv.png", stack_limit = 1})
ActorInventory:defineInventory("QS_MAINHAND", "Second weapon set: In main hand", false, "Weapon Set 2: Most weapons are wielded in the main hand. Press 'x' to switch weapon sets.", true)
ActorInventory:defineInventory("QS_OFFHAND", "Second weapon set: In off hand", false, "Weapon Set 2: You can use shields or a second weapon in your off-hand, if you have the talents for it. Press 'x' to switch weapon sets.", true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment