Results 1 to 10 of 10

Thread: [Reflection] Detecting other players

  1. #1
    Join Date
    Apr 2007
    Location
    Estonia
    Posts
    156
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default [Reflection] Detecting other players

    Looked through the reflection functions didn't find anything that could help me.
    How can I detect other players near me? say 10 tile radius?
    ROCK IS NOT A DEVILS WORK, ITS MAGICAL AND RAD!

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    As always, hooks needs updating, have a read here: https://villavu.com/forum/showthread.php?t=108798
    There used to be something meaningful here.

  3. #3
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    As always, hooks needs updating, have a read here: https://villavu.com/forum/showthread.php?t=108798
    I love you right now. Thank you for that link!





  4. #4
    Join Date
    Apr 2007
    Location
    Estonia
    Posts
    156
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Thank you, got it to work, now how can I add a tile radius to filter only those who are for example 10 tiles away from me?

    Simba Code:
    program R_GetPlayers_TEST;
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.Simba}
    {$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}
    {$I SRL-OSR/SRL/reflection/Reflection.simba}

    var
      amount: Integer;

    type
      TPlayer = record
        Name: String;
        Level: Integer;
      end;

      TPlayerArray = Array of TPlayer;

    function R_GetPlayers: TPlayerArray;
    var
      I, J, _Count, _Player, _Name, _Level: Integer;
    begin
      _Count := SmartGetFieldArraySize(SmartCurrentTarget, 0, 'client.ga', 0);
      SetLength(Result, J);
      for I := 0 to _Count - 1 do begin
        _Player := SmartGetFieldArrayObject(SmartCurrentTarget, 0, 'client.ga', I);
        if (_Player <= 0) then
          Continue;
        Inc(J);
        SetLength(Result, J);
      end;
        amount := J-1; // subtract yourslef
    end;

    begin
      SetupSRL;
      SetupReflection;
      repeat
        R_GetPlayers();
        Writeln('There are currently '+tostr(amount)+' players');
        wait(1000);
      until(false);
    end.
    ROCK IS NOT A DEVILS WORK, ITS MAGICAL AND RAD!

  5. #5
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by neeger View Post
    Thank you, got it to work, now how can I add a tile radius to filter only those who are for example 10 tiles away from me?
    you need to get their location, then you just use distance(your loc, their loc)

  6. #6
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    I'm surprised the class is the same after all these revisions.
    There used to be something meaningful here.

  7. #7
    Join Date
    Apr 2007
    Location
    Estonia
    Posts
    156
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Oke, something like this?
    Simba Code:
    if R_DistanceFromTile(PlayerLocation) > 5 then
    ....
    How can I get "PlayerLocation"?
    ROCK IS NOT A DEVILS WORK, ITS MAGICAL AND RAD!

  8. #8
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    From a quick glance I didn't see the hooks for player position in the updater logs when I looked, and I don't have an OSR account to test any values.

    You can test these like shown in the thread I linked:
    Progress Report:
    v * -207467453
    f * 708620417
    There used to be something meaningful here.

  9. #9
    Join Date
    Apr 2007
    Location
    Estonia
    Posts
    156
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Hmm I'm lost now :/
    ROCK IS NOT A DEVILS WORK, ITS MAGICAL AND RAD!

  10. #10
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by neeger View Post
    Hmm I'm lost now :/
    You can PM me an account and I can then confirm the new hooks.
    There used to be something meaningful here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •