Sphereserver / Source-X

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

[Feature Request] New trigger: @AfkMode #1161

Closed canerksk closed 1 month ago

canerksk commented 11 months ago

It may be necessary to add a trigger that fires when AFK mode is turned on or off, perhaps something for people entering or exiting AFK mode. For example, on my previous server, I was creating a zZz effect (not the z text) on top of the person entering afk mode.

eg;

        case CHV_AFK:
            // toggle ?
            {
                bool fAFK = ( Skill_GetActive() == NPCACT_NAPPING );
                bool fMode;
                if ( s.HasArgs())
                    fMode = ( s.GetArgVal() != 0 );
                else
                    fMode = ! fAFK;
                if ( fMode != fAFK )
                {
                    if ( fMode )
                    {
                        SysMessageDefault(DEFMSG_CMDAFK_ENTER);
                        m_Act_p = GetTopPoint();
                        Skill_Start( NPCACT_NAPPING );
                    }
                    else
                    {
                        SysMessageDefault(DEFMSG_CMDAFK_LEAVE);
                        Skill_Start( SKILL_NONE );
                    }
                    CScriptTriggerArgs  args;
                    args.m_iN1 = fMode;
                    if (IsTrigUsed(TRIGGER_AFKMODE))
                    {
                        OnTrigger(CTRIG_AfkMode, pSrc, &args);
                    }

                }
            }
            break;
on=@afkmode
// ARGN1 = 1 : afk mode on
// ARGN1 = 0 : afk mode off

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