Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
53 stars 40 forks source link

Taming and OF_PetSlots bug? #1219

Closed AtillaG1 closed 2 months ago

AtillaG1 commented 3 months ago

// OF_PetSlots 00000010 // Enable AOS pet follower slots on chars. If enabled, all players must have MAXFOLLOWER property set (default=5)

If I activate this sphere.ini setting, set followerslots on NPC to 1, and have on char MAXFOLLOWERS=5 and try to tame the creature, it will immediately fall into this part.

          SysMessageDefault(DEFMSG_PETSLOTS_TRY_TAMING);
          return -SKTRIG_QTY;

Here is the full code: (it also add curfollowers to my status, but the creature is not tamed and doesnt act like it is.

  if (IsSetOF(OF_PetSlots))
  {
      short iFollowerSlots = (short)pChar->GetDefNum("FOLLOWERSLOTS", true, 1);
      if (!FollowersUpdate(pChar, maximum(0, iFollowerSlots), true))
      {
          SysMessageDefault(DEFMSG_PETSLOTS_TRY_TAMING);
          return -SKTRIG_QTY;
      }
  }

FOUND CONNECTION! Im using also this flag, and this flag is making it not work together with the above one. If i disable this flag, the behaviour above works fine.

// EF_FollowerList 000080 // Save the followers to the list and enable CURFOLLOWER.n.UID, CURFOLLOWER.ADD/DEL and CURFOLLOWER.CLEAR commands.

CONNECTION NO.2

If i disable OF_PetSlots and enable EF_FollowerList, new curfollower is not being added at all, via Taming.

I think these two are interfering in to each other somehow a bugging.

Jhobean commented 3 months ago

I added this piece of code recently but it was working. https://github.com/Sphereserver/Source-X/commit/eef10d80709153b304b37c54d2764ce35fc05912

AtillaG1 commented 3 months ago

mmm the one you posted isnt in core right now actually. 🤔

AtillaG1 commented 3 months ago

Update, connection to the problem is flag listed below. If both activated, its bugging the taming. If I disable this one, its fine.

// EF_FollowerList 000080 // Save the followers to the list and enable CURFOLLOWER.n.UID, CURFOLLOWER.ADD/DEL and CURFOLLOWER.CLEAR commands.

Jhobean commented 3 months ago

These flag is a new feature.seem s bug was added

AtillaG1 commented 3 months ago

Updated first post, with connections I found.

AtillaG1 commented 3 months ago

Also with both flags activated, the followerslots property doesnt work. Its always = 1.

xwerswoodx commented 3 months ago

If I understand you clearly, it's not a bug. Because EF_FollowerList is a new flag to add option to create list automatically for your followers. I meant FollowerSlots only working without this flag activated, because old system only keeping the number of followers while new system keeps list of followers. If you want to add npc manually to someone's follower list with EF flag active, you need to use

<PLAYER>.CURFOLLOWER.ADD <FOLLOWER.UID>

or

<PLAYER>.CURFOLLOWER.DELETE <FOLLOWER.UID>

to remove.

<PLAYER>.CURFOLLOWER.CLEAR

clears the list.

IF you activate EF_FollowerList you tell the Sphere, that you gonna use new system, so you need to use ADD command to add something manually to the list, CURFOLLOWER += 1 or anything similar to this not working with new system.

AtillaG1 commented 3 months ago

Ok and what about the Taming not working at all?

"If I activate this sphere.ini setting, set followerslots on NPC to 1, and have on char MAXFOLLOWERS=5 and try to tame the creature, it will immediately fall into this part." "it also add curfollowers to my status, but the creature is not tamed and doesnt act like it is"

xwerswoodx commented 3 months ago

Hmm, okay I see the issue I will take a look now

cbnolok commented 2 months ago

Just to have it clear myself: is every pet "worth" 1 slot if using EF_FollowerList? How do you set an upper limit, by tweaking the trigger or is there some default/fixed value?

AtillaG1 commented 2 months ago

solved on dev branch, thank you!

DavideRei commented 1 month ago

I have a question about the new system, if a follower have FollowerSlots > 1, isn't curfollower returning the wrong number? CHC_CURFOLLOWER return m_followers.size() as followers number but that is the followers number not the followers total slots. For example if i have 2 followers, the first 1 with FollowerSlots = 1 and the second one with FollowerSlots = 2, CURFOLLOWER return 2 instead of 3.

AtillaG1 commented 1 month ago

Yea because apparently this new system (EF_FollowerList) was made as new thing and is not using the followerslots. ( you would need to script your own ) with the new trigger.

DavideRei commented 1 month ago

The fact is the function seems to use FollowerSlot but even if you change it using the @FollowersUpdate trigger they don't get updated, because CURFOLLOWER read only the follower array dimension, so you can't customize it. That would require a two-dimension array where for each follower you can save also the FollowerSlots.

@xwerswoodx

CScriptTriggerArgs Args;
        Args.m_iN1 = (iFollowerSlots >= 0) ? 0 : 1;
        Args.m_iN2 = abs(iFollowerSlots);
        if (OnTrigger(CTRIG_FollowersUpdate, pChar, &Args) == TRIGRET_RET_TRUE)
            return false;

        if (Args.m_iN1 == 1)
        {
            iFollowerSlots = -(short)(Args.m_iN2);
        }
        else
        {
            iFollowerSlots = (short)(Args.m_iN2);
        }