Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
54 stars 43 forks source link

[Feature Request] NPCs can drink potion. #1147

Closed canerksk closed 4 days ago

canerksk commented 10 months ago

In the past, NPCs could drink potion, but this is not the case nowadays. If you want to be added;

old;

        if ( pCharSrc->IsPriv(PRIV_GM) )
            return ItemBounce(pItem);

        if ( !CanCarry(pItem) )
        {
            if ( NPC_CanSpeak() )
                Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_WEAK));
            return false;
        }

        // Place item on backpack

new;

        if ( !CanCarry(pItem) )
        {
            if ( NPC_CanSpeak() )
                Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_WEAK));
            return false;
        }

        if (pItem->IsType(IT_POTION))
        {
            if (Use_Item(pItem))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        if (pCharSrc->IsPriv(PRIV_GM))
            return ItemBounce(pItem);

        // Place item on backpack

The codes here are purely examples. Although many have been tested, some may need to be rewritten.

cbnolok commented 10 months ago

So, right now, if you drop a potion on a NPC, it isn't used but put in its backpack?

canerksk commented 10 months ago

So, right now, if you drop a potion on a NPC, it isn't used but put in its backpack?

If an staff character leaves a potion on the entity, it falls into its backpack; if the character who left the potion on the entity is a player, the entity rejects it.

xwerswoodx commented 10 months ago

Maybe drinking potion can be good for human characters, but it can be silly if all npcs can drink it. Like why horse drink potion because you throw it on? I am not sure if there is a check under Use_Item for humans. Honestly I am totally against to the idea of adding ability to drink potion for non-human creatures.

canerksk commented 10 months ago

Maybe drinking potion can be good for human characters, but it can be silly if all npcs can drink it. Like why horse drink potion because you throw it on? I am not sure if there is a check under Use_Item for humans. Honestly I am totally against to the idea of adding ability to drink potion for non-human creatures.

It seemed ridiculous to me that we chose not to add things that the community has been used to for many years and that have existed for a long time, as an option, instead of things that we personally consider ridiculous.

xwerswoodx commented 10 months ago

Honestly I am not a decision maker here :) I am just telling my idea about it, yes I agree it should be there for human characters, but thinking about horse still seems wrong for me. It can be added as a flag in sphere ini to allow non-human creatures drink potions on drop.

cbnolok commented 1 month ago

The potions can be drank only if the char giving those to them is a owner or a friend, right?

Tolokio commented 1 week ago

I think there are tools to let devs choose. Not tested Example:

[Event e_general_player_event]
on=@itemdropon_char
if (<act.type>==t_potion && !<serv.spell.<more1>.flags>& SPELLFLAG_HARM)
  If <argo.owner>==<uid> // || f_is_friendly <argo>
      argo.use <act>
   elif <argo.f_do_I_have_backpack?>
       argo.bounce <act>
  else
       bounce <act>
  endif
endif     
return 1 

@receiveItem should be used as well as it allow you to work from npc side and that could be better, but the "return 1" denys it. Maybe "retuen 1" should be changed.

[event e_potion_drinker]
on=@receiveItem
    //whatever you want to do:
return 1 //will this return item to backpack? where it was taken from? or just deny internal behaviour?

image What happen if potions is already drinked when "return 1" and it dosnt exist anymore? Crash? warning?

Is hard for me to find where the fix is done. 90 commits most of them not well named (but nice work with all thoose fixes) I prefer fixes than no fixes. Found by github browser

image

No check for anything but owner and sphere.ini settings. This fix make me wonder:

-Should poison be drinked as well? -What happen with explosions? -Can u give poisons and explosions to npcs so they killed themselves? -Where should empty potion go if horse drinks a potion? to player? horse's stomach? -Will be player revealed if hidden or invis? Should it be? -What happens if potions is given to pack horse/llama or beatle? -Was this feature removed for a good reason? -What do clouds smell like?

Tolokio commented 1 week ago

Maybe drinking potion can be good for human characters, but it can be silly if all npcs can drink it. Like why horse drink potion because you throw it on? I am not sure if there is a check under Use_Item for humans. Honestly I am totally against to the idea of adding ability to drink potion for non-human creatures.

It seemed ridiculous to me that we chose not to add things that the community has been used to for many years and that have existed for a long time, as an option, instead of things that we personally consider ridiculous.

If there was that feature and it was removed, maybe decision was made by a smart guy for a good reason and not by mistake or a "ridiculous" reason. I think someone removed that feature because right now there is a trigger to customize it very easily, it requires many checks for various cases, and it can't please everyone. I don't want to talk about what I find "ridiculous"...