UOGamers Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • To obtain new Razor updates, please reinstall Razor from our new website.

How I overcame getfriend not finding a friend ....

This is how I finally overcame getfriend and presumably getenemy not really found.

If you have a better way pretty please reply here, this vexed me for some time ....

Code:
  setalias Friend self
  getfriend 'Friend'
  pause 100
  if name friend != "Enigma Maitreya"
     sysmsg "A friend was found"
  else
     sysmsg "A friend was not found"
  endif
 
Simple test demonstrating the failure

Code:
getfriend 'friend'
pause 1000
if findalias 'friend'
   sysmsg "A Friend was found"
else
   sysmsg "A Friend was not found"
endif
if name friend == "arb"
   sysmsg "arb was found"
endif

Results:
A Friend was not found
arb was found
////////////////////////////////////
the getfriend 'friend' will not set the 'friend' alias as empty or not found or in any way I can find give one the information that it didnt find a friend. Keep in mind that getfriend does not look at the ignorelist.

ergo

Code:
// This will always be false regardless of there being a friend
if findalias 'friend'
   sysmsg "A Friend was found"
else
   sysmsg "A Friend was not found"
endif

// Hence one can not get away with the following and no Friends
// Also without the DoWork timeout the while loop will just run forever, with a friend or without a friend
@settimer 'DoWork' 0
while timer 'DoWork' < 5000
  @setalias Friend self
  @getfriend 'Friend'
  pause 100
  @settimer 'DoWork' 5000
//  if name friend != "Enigma Maitreya"
    if not @inlist 'AABPIgnore' Friend
      @pushlist 'AABPIgnore' Friend
      pause 100
      if not @inlist 'Pets' Friend
        pause 100
        if @infriendlist Friend
          sysmsg 'Found a Friend'
          pause 100
          @pushlist 'Pets' Friend
          pause 100
          @unsetalias 'PetTypeFound'
          if @list 'VegTypes' > 0
            for 0 to 'VegTypes'
              if 'graphic' Friend == VegTypes[]
                if not @inlist 'Veg' 'Friend'
                  sysmsg 'Found a Vegan'
                  @pushlist 'Veg' Friend
                  @setalias 'PetTypeFound' self
                endif
              endif
            endfor
          endif
          if not @findalias 'PetTypeFound'
            if not @inlist 'RawMeat' Friend
              sysmsg 'Found a Meat Eater'
              @pushlist 'RawMeat' Friend
            endif
          endif
          @settimer 'DoWork' 0
        endif
      endif
      pause 100
    endif
//  endif
endwhile
removetimer 'DoWork'

The failure, well as far as I can tell, is there is no way to determine if the getfriend really did find a friend. Said differently I can not find anything that suggest it can tell me getfriend failed.

What I am doing is building a list of Pets that are in my Friend List so that I ca do this, don't fall for this being a simple heal a pet, it is more complicated than that, also the food type code is just so I can keep different food requirement pets fed and is not central to this issue.

Code:
  if list 'Pets' > 0
    for 0 to 'Pets'
      if 'Hits' Pets[] <= 80
        cast "Invisibility"
        waitfortarget 15000
        target! Pets[]
        settimer 'CastDelay' 0
        pause 1000
        waitforcontext Pets[] 1 15000
        waitfortarget 15000
        target! 'self'
      endif
    endfor
  endif

So there are cases where I want the macro to work without pets and work with pets. The failure has been with no pets out and in the friend list, the buildpets simply will loop forever, if I force a stop then the pet list is filed with what I believe is equivelent to null as the second code fragment spams messages that hits pets[] can not be found. Why I say pets[] is populated is because of the if list 'pets' > 0
 
Last edited:

c0d3r

Traveler
Code:
@getfriend 'friend'
if @findobject 'friend'
  // found
else
  // not found
endif
or
Code:
@getfriend 'friend'
if @inrange 'friend' 12
  // found AND in range
else
  // not found OR not in range
endif
both should work...
now creating a loop sample:
Code:
while not dead
  @getfriend 'friend'
  if not @findobject 'friend'
    // stop loop bc friend doesnt exist
    break
  endif
  // friend found
  // give the loop a pause
  pause 100
endwhile
 
c0d34

Code:
@getfriend 'friend'
if @findobject 'friend' 12
   sysmsg "Object was found"
else
   sysmsg "Object was not found"
endif
if @inrange 'friend' 12
   sysmsg "Friend was found"
else
   sysmsg "friend was not found"
endif
if name friend == "arb"
   sysmsg "Arb was found"
else
   sysmsg "Arb was not found"
endif

All 3 provided consistent results, not knowing how the find or inrange work, i am probably going to keep the name check, based on nothing more than probably stupid assumption that it is faster, all of this is part of a larger macro, were I want to pull a pet before it gets its butt kicked and timing can be a problem.

BUT thanks for the findobject though, I had seen that but didnt consider it because the findalias failed
 

c0d3r

Traveler
findalias - checks if an alias has been created/assigned to a serial
findobject - checks if an alias or serial actually exists in game
inrange - checks not only if it exists but also if it is in range (number of tiles between you and the object)
hope this clarifies :)
 
findalias - checks if an alias has been created/assigned to a serial
findobject - checks if an alias or serial actually exists in game
inrange - checks not only if it exists but also if it is in range (number of tiles between you and the object)
hope this clarifies :)

Sorry I was not clear, the mechanical action, I assume name == "value" to be a simple compare, I assume find/inrange to be a scan of the environment or list.
 

c0d3r

Traveler
the "bottleneck" in terms of speed would be the getfriend command (scan and filter mobs returning a friend), once it is done (and 'friend' alias is assigned) it doesnt matter.. both inrange and findobject would be super fast.
 
I think I can better state the failure to be that getfriend does NOT remove the Friend alias, if it does NOT find a Friend.

This in action is what sets the work part to produce wrong results.

Hence c0d3r's methods or my name check is required to actualy detect a not found results from the getfriend. I assume this is also true of the getenemy.

Hum, maybe I am screwed up, perhaps the issue is that system maintained alias can not be unset. That probably makes more sense.
 
Last edited:

c0d3r

Traveler
yup I just cant see any issues with findobject in that case but you can always create your own alias and set/unset as you want:
Code:
getfriend 'friend'
@setalias 'myOwnFriend' 'friend'
if @findalias 'myOwnFriend'
  // your code
  @unsetalias 'myOwnFriend'
else
  sysmsg 'not found, not set'
endif
 
Top