Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  costs for remove/damnation  (Read 318 times)

0 Members and 1 Guest are viewing this topic.

Dolfo

« on: 09, September 2023, 09:57:37 »
So because this is an unbalanced money gain logic with all our expensive cursed stuff to uncurse them for some few silvers to earn 100+ gold i looked in there.

Here are some changes for church.lua script. Sadly this is a broken script from public trunk failing somehow to remove curse/damnations from items. Also public trunk has a inactive level 50 church priest and a level 1 castle church priest, so for sure 2 "expert" npc there to test this.

Prototyp price calculation works fine. I can loop player inventory from lua code only and check for cursed/damned items in there. Atm i miss to loop also containers, but this is only one more loop in logic. I also compare priest level against item level. A level 1 priest can't take money for services he can't handle later.

But the current idea is simple. Count the value of the cursed/damned items priest can "cure" and take half the value for service costs. So players have still money gain on cursed stuff, but more balanced.  ::)

Edit: This is updated priest script. This script needs also an updated version of GameObject_PresentArchInOb.

Code: [Select]
/*****************************************************************************/
/* Name   : GameObject_PresentArchInOb                                       */
/* Lua    : object:PresentArchInOb("...")                                    */
/* Info   : searches for any objects with                                    */
/*          a matching archetype in the inventory of the given object.       */
/* Returns: The first matching object or NULL                                */
/*****************************************************************************/
// Prototype to access hooks->archetype_global->...
// can be expanded to access other archetype_global
// using a name string and the if check is a workaround to target the archetype_global structure
// implementing this in a better way, needs a lot of knowledge and time, I currently don't have
// I know it's ugly, but better than nothing
// used to access archetype_global->_royal_experience from royal_exp_transfer.lua
// extended for our priests (church.lua) to have access to the forces he can clean to make church script more intelligent
static int GameObject_PresentArchInOb(lua_State *L)
{
    char *name = NULL;
    lua_object *self;
    object_t *obj = NULL;

    get_lua_args(L, "Os", &self, &name);

    if (name)
    {
        if (strcmp(name, "_royal_experience") == 0)
        {
            obj = hooks->present_arch_in_ob(hooks->archetype_global->_royal_experience, WHO);
        }
        else if (strcmp(name, "_deathsick") == 0)
        {
            obj = hooks->present_arch_in_ob(hooks->archetype_global->_deathsick, WHO);
        }
        else if (strcmp(name, "_drain") == 0)
        {
            obj = hooks->present_arch_in_ob(hooks->archetype_global->_drain, WHO);
        }
        else if (strcmp(name, "_depletion") == 0)
        {
            obj = hooks->present_arch_in_ob(hooks->archetype_global->_depletion, WHO);
        }
        else if (strcmp(name, "_poisoning") == 0)
        {
            obj = hooks->present_arch_in_ob(hooks->archetype_global->_poisoning, WHO);
        }

        if(obj)
            return push_object(L, &GameObject, obj);
    }
  return 0;
}

church.lua
Code: [Select]
local player = event.activator
local npc = event.me

require("interface_builder")
local ib = InterfaceBuilder()

local realLevel = player.level
local drain=player:PresentArchInOb("_drain")
if drain then
    realLevel = realLevel + drain.level
end

-- deathsickness cost calculation
local function dsCost(level)
    local cost = 100 + 4 * level * level

    if level >= 60 then
        cost = cost + 4000 * level - 240000
    end
    return cost
end

-- calculate costs to remove curse/damnation
local function calcCursed(object)
    local value=0
    if object.inventory then
        local obj=object.inventory
        repeat
            if obj.f_sys_object == false then
                -- if priest can uncurse something there is no need to check also for damned, we only calculate one cost for both flags
                if obj.f_cursed == true and obj.level <= npc.level and obj.f_cursed_perm == false then
                    value=value+obj.value/10 -- lets take 10%
                elseif obj.f_damned == true and obj.level <= npc.level and obj.f_damned_perm == false then
                    value=value+obj.value/10 -- lets take 10%
                end

                --loop everything what has a inv pointer is not system
                if obj.inventory~=nil then
                    value=value+calcCursed(obj)
                end
            end
            obj=obj.below
        until(obj==nil)
    end
    return value
end

-- we do the unapply costs separate here, this don't need recursive search
-- everywhere we can't remove curse/damnation we calc 1 silver each player level for unapply this.
local function calcApplied(object)
    local value=0
    local item = nil
    for i = 0, game.EQUIP_MAX - 1 do
        item = player:GetEquipment(i)
        if item ~= nil then
            if (item.f_cursed == true and (item.f_cursed_perm==true or item.level>npc.level)) or
               (item.f_damned == true and (item.f_damned_perm==true or item.level>npc.level)) then
                value = value + realLevel*100;
            end
        end
    end
    return value
end

local function topicDefault()
    ib:SetHeader("st_001", npc)
    ib:SetTitle("The Church of the Tabernacle")
    ib:SetMsg("Hello! I am " .. npc.name ..".\n\nWelcome to the church of the Tabernacle!\n\n")

    if player:PresentArchInOb("_poisoning")~=nil then
        ib:AddMsg("You are poisoned? Wait I cast a spell on you.\n\n")
        npc:CastSpell(player, game:GetSpellNr("cure poison"), 0, 0, "")
        ib:AddMsg("|** " .. npc.name .. " casts cure poison on you! **|\n\n")
    end

    ib:AddMsg("If you need information to my services, I can ^explain^ it.\n\n")
    ib:AddMsg("What can I do for you?\n\n")

    local needHelp = false

    if player:PresentArchInOb("_deathsick")~=nil then
        ib:AddLink("Remove Death Sickness", "cast sick")
        needHelp = true
    end

    if drain~=nil then
        ib:AddLink("Cast Restoration", "cast restore")
        needHelp = true
    end

    if player:PresentArchInOb("_depletion")~=nil then
        ib:AddLink("Cast Remove Depletion", "cast deplete")
        needHelp = true
    end

    if calcCursed(player)+calcApplied(player)>0 then
        ib:AddLink("Remove Curse and Damnation", "cast damn")
        needHelp = true
    end

    if needHelp == false then
        ib:AddMsg("You look very healthy to me!\n\n")
    end

    -- disease.c has find_disease function we could use here, if we want diseases logic more intelligent
    -- but atm its a waste of time here to code more, diseases are inactive and need a rework before.
    -- I am not sure if diseases spreading through server from player to player is a good concept.
    ib:AddLink("I think I have one of this old forgotten diseases.", "cast disease")
end

local function topicExplain()
    ib:SetHeader("st_002", npc)
    ib:SetTitle("About our Services")
    ib:AddMsg("I can cure various things by casting the named spells on you when you pay me the money.\n\n")
    ib:AddMsg("Deathsick is a stronger form of depletion.\nEverytime you die stats are depleted by death sickness.")
    ib:SetButton("Back", "hi")
    player:Interface(game.GUI_NPC_MODE_NPC, ib:Build())
end

local function topicCast(what)
    ib:SetHeader("st_005", npc)
    if what=="sick" then
        if player:PresentArchInOb("_deathsick")==nil then
            ib:SetMsg("You have no death sickness!")
            return
        else
            ib:SetMsg("I can cast ~Remove Deathsick~ for " .. player:ShowCost(dsCost(realLevel)))
        end
    elseif what == "deplete" then
        if player:PresentArchInOb("_depletion")==nil then
            ib:SetMsg("You are not depleted!")
            return
        else
            ib:SetMsg("I can cast ~Remove Depletion~ for ".. player:ShowCost(5 * realLevel))
        end
    elseif what == "restore" then
        if drain==nil then
            ib:SetMsg("You are not drained!")
            return
        else
            ib:SetMsg("I can cast ~Restoration~ for ".. player:ShowCost(100*drain.level) ..".") -- 1 silver each drained level
        end
    elseif what == "disease" then
        ib:SetMsg("I can not see if you are diseased, but if you want,\n\n")
        ib:AddMsg("I can cast ~Cure Disease~ for ".. player:ShowCost(100 * realLevel) .. " on you.")
    elseif what == "damn" then

        local costs=calcCursed(player)+calcApplied(player)
        if costs==0 then
            ib:SetMsg("You have no cursed or damned items, why you ask me?")
            return
        else
            ib:SetMsg("I can cast ~Remove Damnation~ for " .. player:ShowCost(costs)) --player:ShowCost(100 + 3 * realLevel))
        end
    else
        ib:SetMsg("You want me to cast ".. what .."? Sorry I don't know this spell.")
        return
    end
    ib:AddMsg(".\n\nYou have " .. player:ShowCost(player:GetMoney()) .. ".\n\nDo you want me to do it now?")
    ib:SetAccept(nil, "docast " .. what)
    ib:SetDecline(nil, "hi")
end

local function topicDoCast(what)
    local sum
    local spell
    ib:SetHeader("st_005", npc)
    if what == "sick" then
        sum = dsCost(realLevel)
        spell = "remove death sickness"
    elseif what == "deplete" then
        sum = 5 * realLevel
        spell = "remove depletion"
    elseif what == "restore" then
        sum = 100 * (realLevel-player.level) -- 1 silver each drained level
        spell = "restoration"
    elseif what == "disease" then
        sum = 100 * realLevel
        spell = "cure disease"
    elseif what == "damn" then
        sum = calcCursed(player)+calcApplied(player)
        spell = "remove damnation"
    end
    ib:SetTitle("Casting " .. spell)
    if player:PayAmount(sum) == 1 then
        npc:CastSpell(player, game:GetSpellNr(spell), 0, 0, "")
        ib:SetMsg("|** " .. npc.name .. " takes your money **|\n\ndone!")
    else
        ib:SetMsg("You don't have enough money!")
    end
    ib:SetButton("Back", "Hi")
end

require("topic_list")
tl = TopicList()
tl:AddGreeting(nil, topicDefault)
tl:SetDefault(topicDefault)
tl:AddTopics("explain", topicExplain)
tl:AddTopics("cast (.*)", topicCast)
tl:AddTopics("docast (.*)", topicDoCast)
ib:ShowSENTInce(game.GUI_NPC_MODE_NPC, tl:CheckMessage(event, true))
« Last Edit: 25, September 2023, 18:10:09 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Shroud

« Reply #1 on: 09, September 2023, 12:25:06 »
One interesting note is that I believe shop only pays around half the value for items so if priest charges half the value then shop would only cover the priest's bill. As a side note if we start having really high bills it would be handy if the priest can take the funds directly from your bank account to avoid extra trips to the bank assuming players don't have 50g regularly on hand.
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

Dolfo

« Reply #2 on: 09, September 2023, 12:51:57 »
Paying direct from bank works with bankcard. Atm my logic is limited to mark the card, but mark a card would fail, when you want to reforge something. We can't mark two items. So we need to wait for a better solution like to ready the bankcard on torch slot.  ::)

The 50% was a fast choice, like priests are "fair" and share 50/50. For sure selling to shop, the shop take 20% more from your profit. But shop has also some few % you can gain by charisma.

So the idea its mainly,

"you find potions you sell to shop"

"you find cursed potions, the priests rip you first, taking half the profit"

we can go for 40%, if we want come closer to half profit, then we are still ignoring charisma or later royal bankcard bonus in our calculation.  :P
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Shroud

« Reply #3 on: 09, September 2023, 13:07:01 »
Well currently removing damnation is a trivial cost so it makes sense to increase the price. Exact rate is more an economic issue and only likely edge cases is when rate is high enough that people no longer both to carry cursed items (e.g. currently most players dump items of mass as value isn't worth 65kg of loot)
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

Dolfo

« Reply #4 on: 15, September 2023, 14:54:27 »
Could be also interesting, that priest can't remove the cursed/damned flags from items. Instead they can unapply these items for players? ???
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Shroud

« Reply #5 on: 16, September 2023, 16:57:48 »
Could be also interesting, that priest can't remove the cursed/damned flags from items. Instead they can unapply these items for players? ???
Actually I believe that's exactly how scrolls work. Although in that case all cursed items instantly become worthless as shop doesn't accept money for cursed items.
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

Dolfo

« Reply #6 on: 21, September 2023, 12:53:45 »
Looks like we can also cheat our priests, when we let drain us first. Lua only checks for player levels for calculation and don't check for drained levels.
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Dolfo

« Reply #7 on: 22, September 2023, 19:47:54 »
I reworked the priest script. I have still some problems with browsing containers from lua site, but the other mechanics looking cleaner now. Priest is a little more intelligent.

You get only the links, when they make sense. So remove deathsickness only if you have deathsickness. Same for restoration and remove depletion. For remove poison i choosed an automatic cure without the need for money. So if you come to priest and are poisend he cures you when talking to him. Only for disease there is still a perma link in. I rebuild the dialog a little to make it cleaner for players, that they can start a cure disease at their own risk(costs). I have only looked in disease.c some seconds and was close to jump out of my window. Luckyly i live ground floor.  :P

With the new "function" to access the forces i can also get first time the real level of player (level+drained level) in lua script, so the calculation can't be exploited anymore with draining some levels.

I changed costs for restoration to 1 silver per drained level.

For remove damnation i want try half the item value to clean curse/damned flags and when this is not working (perma damned or to high level) than unapply an item is in relation to player level 1 silver each total level.

I really want to end this somehow and continue on new item slot and finish bankcard logic.
« Last Edit: 22, September 2023, 19:52:14 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Dolfo

« Reply #8 on: 24, September 2023, 07:02:05 »
This is no end here. But when we are here, why not discuss this? Currently players mainly go to priest, uncurse their items and then sell it to shop. I personally store first all my cursed stuff in appartment and containers and go for a "big uncurse all items at once" business trip.

So cursed stuff is mostly full selling prices except the priest costs or the scroll price.

Why not give full money for cursed stuff at shop?

Its remove one line in shop.c function query_cost line 49
Code: [Select]
if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED))
  return 0;
This would end:
Players need to uncurse first before selling.
Players start to collect curse items for more money efficience and trash their apartments.
Also
We can't detect curses later in future scenarios by the value.
New changes on curse logics, didnt't kill the values for unremovable cursed items.
I didn't kill the player stock cursed item values, when i update the curse/damned flags from perma items in loader.

I see only advantages for players here.  ???

For sure i need to go also in examine logic to show value for cursed/damned stuff. Looks like this target the same function query_cost from above.

When we go this way, the need for uncurse priest services and the need for uncurse scrolls will reduce. We could also rethink the costs for the priest service. Does it makes sense to pay half the item values for uncurse then?  ???
« Last Edit: 24, September 2023, 07:53:46 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Shroud

« Reply #9 on: 24, September 2023, 19:43:37 »
That's probably sensible and also means that in the event someone sells an unidentified item to the shop then they don't get a shock when they get nothing cause it's cursed
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

Dolfo

« Reply #10 on: 24, September 2023, 20:56:53 »
0 value in shops dont vanish, they drop on floor like money. That's reason we have(had) often cursed items in shop players dropped there.

Yes selling unidentified items to shop has also some strange logics. I don't like this! I would give full price or drop on ground, but don't allow to sell for a percent? Must look in there.  ::)

But we can't save players against their own clicks in shop. If they drop the RoA, it's gone. We could track the items a player sold to shop and build in an undo function. At least a buffer for 10 last sold items perhaps? Then players can talk to a near smith and undo their selling. But atm if have to much other things todo. Don't think such a logic is finished in 2 weeks.
« Last Edit: 24, September 2023, 20:58:53 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Shroud

« Reply #11 on: 24, September 2023, 23:02:14 »
Actually having accidentally sold items in the past has taught me the value of the lock command. Personally I suspect the undo sale command probably is fairly non-essential and while it would be nice to have it I imagine it has a poor cost/benefit ratio
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

Tags:
 

Related Topics

  Subject / Started by Replies Last post
5 Replies
778 Views
Last post 19, April 2006, 02:39:57
by longir
12 Replies
1863 Views
Last post 21, August 2008, 02:21:22
by Unislash
1 Replies
3914 Views
Last post 29, August 2010, 22:35:53
by clobber
9 Replies
5179 Views
Last post 26, September 2011, 09:32:25
by blingking114
31 Replies
77937 Views
Last post 22, July 2021, 08:57:28
by Clort