PC Check

Status
Not open for further replies.

lostrelms

New member
Joined
May 12, 2006
Messages
10
Reaction score
0
Points
0
I was wondering how I would go about adding a PC Check sub to a macro, so that the macro paused if a PC was within X amount of distance of me. Any help is appreciated, thanks~.
 
Code:
/if (${SpawnCount[pc radius X]>1}) /PauseMacroSub
 
That didn't work, but I figured it out. Thanks though. Here's for reference for anyone else though, just add a call for PCCheck along with the following sub:

Code:
Sub PCCheck

  :PCCheck 
   /if (${SpawnCount[pc radius 500]}>1) {
      /beep
   /delay 5s
      /echo PC detected within range, pausing macro...
   /goto :PCCheck
   }

/return
 
Heh, it didn't work because /PauseMacroSub was a placeholder example to call a real one.

Depending on how your mac is set up, you may not want it spamming the box every 5 seconds with somebody in range. This should say it once, then idle until they leave.

Code:
Sub PCCheck
/if (${SpawnCount[pc radius X]}==1) /return
/beep
/echo PC Detected within range, pausing macro...
:PCCheck
/delay 5s
/if (${SpawnCount[pc radius X]}>1) /goto :PCCheck
/echo PC has left the area, resuming macro...
/return
 
What I use...

This is what I use to watch for PCs near me. It has a "friendlies" list in it so when your leeching friends stop by they don't stop your macro. Also adds name and time to a log file as well as a popup message flashes for you so you don't wonder why your macro looks broken. :D

Add this someplace in your Sub Main declare section. (Then you can hotkey /echo ${PauseCount} to see how many total seconds wandering toons have forced you to pause. Or add it to your HUD.)

/declare PeopleWatchRadius int outer 500
/declare PauseCount int outer 0

Code:
Sub PeopleCheck
/if (${Spawn[gm].ID}>0) { 
    /echo GM in the zone! ${time}
    /echo Ending Macro!!!
    /endmacro
} 
/squelch /alert clear 1
| Alert 1 contains people to filter out and you don't care if they're near.
/squelch /alert add 1 pc "[COLOR="Red"]OneOfMyFriends[/COLOR]"
/squelch /alert add 1 pc "[COLOR="red"]MyOnlyOtherFriend[/COLOR]"

:PeopleCheck
/if (${SpawnCount[pc zradius 50 radius ${[COLOR="Lime"]PeopleWatchRadius[/COLOR]} noalert 1]}>0) {
    /echo People near. ${Spawn[pc noalert 1].Name} - ${Time}
    /afk Cleaning up from too much pr0n!
    :Wait1
        /popup PAUSED! Because ${Spawn[pc noalert 1].Name} is near.
        /delay 1s
        /varcalc PauseTime ${PauseTime} + 1
        /doevents
        /if (${SpawnCount[pc zradius 50 radius ${PeopleWatchRadius} noalert 1]}>0) /goto :Wait1
    /varcalc PauseCount ${PauseCount} +1 
    /if (${Me.AFK}) /afk
}
/return

Hope this helps...

-PW
 
Last edited:
The above examples will trigger all the time ;) Why? Because you yourself is also a Player Character (PC) and you're obviously within the set radius since you're at radius 0.

<edit>Hmm, perhaps I should rewrite my include and use Peter Warrens idea on alert lists to exclude friends (the post just above this one). That would certainly clean up some code.</edit>

The most simple way to do the check without regard of being grouped or a friend etc. would be a simple line like this (highlighted important part):
Code:
/if (${SpawnCount[pc radius 300 zradius 50 [COLOR=Red]notid ${Me.ID}[/COLOR]]}) /echo Players within 300 units.
I created an include (which I've unfortunately not had the time to test properly, mostly because I always jump from project to project :( ) that should make it somewhat easier to have it all within your own macros, and since I'm lazy so I'll just copy/paste my post from RG here ;)

Name:
SafetyCheck.inc


Description:
A simple include to use for all those AFK macroes. Will check for players within specified distance (default 500) as well as GM's. It will return OK if everything checks out fine, GM if a GM is detected and PC if a non-excluded players is in range.


Changes:
2006-08-11
  • Beta 1.
    Untested.
2006-08-12
  • Fixed a copy/paste error in the "All features" example.
2006-12-14
  • Fixed a missing parenthisis set in an /if.
  • Updated macro to use alert lists instead of arrays (Thanks to Peter Waren for the idea).
Syntax:
Code:
/call SafetyCheck [int CheckRadius] [int AlertList]
Examples:
Advanced:
Code:
#Include SafetyCheck.inc
Sub Main
    |--------------------------------------------------------------------------|
    |- First clear the alert list. Using alert list #1                        -|
    |--------------------------------------------------------------------------|
    /alert clear 1

    |--------------------------------------------------------------------------|
    | Then populate the alert list. Still using alert list #1 ;)              -|
    |--------------------------------------------------------------------------|
    /alert add 1 pc "ThisOneIsOkay"
    /alert add 1 pc "ThisOneCanAlsoBeAroundMe"

    |--------------------------------------------------------------------------|
    | Do the SafetyCheck with a radius of 500 and excluding players on alert  -|
    | list #1                                                                 -|
    |--------------------------------------------------------------------------|
    /call SafetyCheck 500 1
    /if (${Macro.Return.NotEqual[OK]}) {
        /popup There's someone near who isn't welcome...
        /if (${Macro.Return.Equal[GM]}) {
            /popup OMG! It's a GM. Time to bail...
            /quit
            /endmacro
        } else /if (${Macro.Return.Equal[PC]}) {
            /popup Pesky players, they're everywhere...
            /say Beat it! This is my camp.
        }
    }
/return
Simple:
Code:
#Include SafetyCheck.inc
Sub Main
    /call SafetyCheck
    /if (${Macro.Return.NotEqual[OK]}) /endmacro
/return
SafetyCheck.inc
Code:
|**
 * SafetyCheck.inc - by EvenLessSpam
 *
 * Version: 0.0.1
 *
 * Changes:
 *  0.0.1
 *  - Beta 1. Untested.
 *
 *  0.1.0
 *  - Changed the player exclusion list from array based to alert list based.
 *      thanks to Peter Waren of MMOBugs for the idea.
**|

Sub SafetyCheck(int Radius, int Exclude)
    /declare i              int     local   0
    /declare c              int     local   0
    /if (!${Defined[Radius]}) /declare Radius   int     local   500
    /declare SafeSearch     string  local   pc radius ${Radius} zradius 50 notid ${Me.ID}
    /if (${Defined[Exclude]}) /varset SafeSearch ${SafeSearch} noalert ${Exclude}

    /if (${SpawnCount[${SafeSearch}]} || ${SpawnCount[gm]}) {
        /if (${SpawnCount[gm]}) {
            /return GM
        } else {
            /for i 1 to ${SpawnCount[${SafeSearch}]}
                /if (${Group.Member[${NearestSpawn[${i}, ${SafeSearch}]}]}) /goto :Continue
                /return PC
                :Continue
            /next i
        }
    }
/return OK
 
Last edited:
/if (${SpawnCount[pc radius X]}>1) /goto :pCCheck


Please note the highlighted text. That keeps it from auto-triggering. It checks if there is You + Another person.

And the first line in my code checks to see if it's JUST YOU, and if so, /returns.
 
Bah!

I was too hasty pulling the character names out of the alert list since I just did a cut/paste from one of my macros and I accidentally deleted my name from it. Good catch.

-PW
 
Status
Not open for further replies.