Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
57 stars 45 forks source link

[Feature Request] @NPCShrink new trigger #1148

Open canerksk opened 11 months ago

canerksk commented 11 months ago

The need for a trigger to be triggered on the NPC when the NPC is shrinked can be evaluated.

eg;

    case NV_SHRINK:
    {
        // we must own it.
        if (!NPC_IsOwnedBy(pCharSrc))
        {
            return false;
        }
        CItem* pItem = NPC_Shrink(); // this deletes the char !!!
        if (pItem)
        {
            pCharSrc->m_Act_UID = pItem->GetUID();
        }
        // Put in your bankbox - Default pack = bank
        CItemContainer* pContBank = pCharSrc->GetBank();

        // Put in your pack
        //CItemContainer* pContPack = pCharSrc->GetPackSafe();

        bool ShrinkContainerToPack; // backpack
        if (s.GetArg16Val() <= 0)
        {
            ShrinkContainerToPack = true;
        }
        else
        {
            ShrinkContainerToPack = false;
        }

        if (IsTrigUsed(TRIGGER_NPCSHRINK))
        {
            CScriptTriggerArgs args;
            args.m_pO1 = pItem; // argo = shrink item
            args.m_iN1 = ShrinkContainerToPack == true ? 0 : 1; // argn1 = read pack/bank
            if (OnTrigger(CTRIG_NPCShrink, pCharSrc, &args) == TRIGRET_RET_TRUE)
            {
                return false;
            }
            ShrinkContainerToPack = args.m_iN1 == 0 ? true : false;
        }

        if (ShrinkContainerToPack == true)
        {
            // shrink send to pack
            //pContPack->ContentAdd(pItem);
            pCharSrc->ItemBounce(pItem);
            //pCharSrc->SysMessagef("Binek cantaniza gonderildi.");
        }
        else
        {
            // shrink send to bank
            pContBank->ContentAdd(pItem);
            //pCharSrc->SysMessagef("Binek bankaniza gonderildi.");
        }

        return (pItem != nullptr);

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