Page 16 of 32 FirstFirst ... 6141516171826 ... LastLast
Results 376 to 400 of 792

Thread: [OSR]Reflection Include

  1. #376
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Tickyy View Post
    indeed, and it does false detections, it says that it has detected the frog random, without actually happening or frog being near, meaning that the last changes you've made @Krazy_Meerkat about the npc's wasn't a good idea..
    Tickyy, I'm not sure you understand what I changed..
    I too got a false detection relating to the frog random.
    What I changed was to allow R_GetAllNpcs (which is called in r_findnormalrandoms and r_findcombatrandoms) to refresh the array everytime it's called.. The problem is, if I don't allow it to do this, any random events won't be listed as Npc's.
    The problem lies with very inefficient functions (R_FindTalk, R_SolveTalk, R_Findcombatrandoms) which call R_GetAllNpcs many many times.

    I am working hard to fix the problem, but don't tell me that the last changes I made were a bad idea when you don't even know what I did.
    Edit: Here's a quick fix which should have everything working fast for you again while I fix all this crap..
    Simba Code:
    client_npcIndices                                 =   'client.bv';
    Last edited by Krazy_Meerkat; 07-03-2014 at 12:19 PM.

  2. #377
    Join Date
    Oct 2008
    Location
    behind you!
    Posts
    1,688
    Mentioned
    2 Post(s)
    Quoted
    40 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    I am working hard to fix the problem, but don't tell me that the last changes I made were a bad idea when you don't even know what I did.
    I Apologize, i am willing to help, so you are trying to find an alternative way of finding randoms, without calling R_GetAllNpcs?

  3. #378
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Tickyy View Post
    I Apologize, i am willing to help, so you are trying to find an alternative way of finding randoms, without calling R_GetAllNpcs?
    I'm also sorry if I was rude.

    @Cov I think that functions could be added to SMART to invoke methods using reflection, but I feel that they've been left out for a good reason.. Looking over some examples, there could be issues if properties of the method are changed (public or non-public method call, number of parameters, etc.)..
    It's a good suggestion, but TransformIds should be enough for our purposes

    Latest Update:
    Major edits to remove lag-bombs from Antirandoms..
    NpcIndex Hook re-added.
    Last edited by Krazy_Meerkat; 07-03-2014 at 03:25 PM.

  4. #379
    Join Date
    Oct 2008
    Location
    behind you!
    Posts
    1,688
    Mentioned
    2 Post(s)
    Quoted
    40 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    I'm also sorry if I was rude.

    @Cov I think that functions could be added to SMART to invoke methods using reflection, but I feel that they've been left out for a good reason.. Looking over some examples, there could be issues if properties of the method are changed (public or non-public method call, number of parameters, etc.)..
    It's a good suggestion, but TransformIds should be enough for our purposes

    Latest Update:
    Major edits to remove lag-bombs from Antirandoms..
    NpcIndex Hook re-added.
    Thank you for your hard work! I wasn't really paying attention to the reason why you did all this and said something i shouldn't have said. I am willing to learn more about reflection and how it works, i hang around irc sometimes, just in case you need a second hand.

  5. #380
    Join Date
    Jun 2014
    Location
    England
    Posts
    17
    Mentioned
    2 Post(s)
    Quoted
    10 Post(s)

    Default

    EDIT: Oops double post

  6. #381
    Join Date
    Jun 2014
    Location
    England
    Posts
    17
    Mentioned
    2 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    @Cov I think that functions could be added to SMART to invoke methods using reflection, but I feel that they've been left out for a good reason.. Looking over some examples, there could be issues if properties of the method are changed (public or non-public method call, number of parameters, etc.)..
    It's a good suggestion, but TransformIds should be enough for our purposes
    The modifiers that a method has wouldn't matter (other than it being static or not). Only problem you would have from what I can see and my limited knowledge of c++ is providing the new invoke method you would add in Client object of SMART with the objects to go in the varag array of Method#invoke. Other than that it would work in the exact same way as SmartGetFieldObject. Adding something like this in would mean you're able to us the clients tileToScreen and tileToMinimap, as well as loading object/npc/item definitions from the cache.

  7. #382
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    I'm also sorry if I was rude.

    @Cov I think that functions could be added to SMART to invoke methods using reflection, but I feel that they've been left out for a good reason.. Looking over some examples, there could be issues if properties of the method are changed (public or non-public method call, number of parameters, etc.)..
    It's a good suggestion, but TransformIds should be enough for our purposes

    Latest Update:
    Major edits to remove lag-bombs from Antirandoms..
    NpcIndex Hook re-added.
    Thank you very much! Works great now!

    EDIT: I got an Out of Range error at line 300 of antirandoms include when antirandom finds that I'm in combat. @Krazy_Meerkat

  8. #383
    Join Date
    Aug 2013
    Posts
    82
    Mentioned
    0 Post(s)
    Quoted
    35 Post(s)

    Default

    Hey look I'm no pro with this at all and I'm just messing around with my third script, but thought I'd share this for the ppl working on it. I tried to open a door, and it moves the mouse very close but then stops and says succesfully executed. Here's my code (yes, no failsafes but I'm assuming we're not supposed to need that).

    Simba Code:
    function IsDoorOpen: Boolean;
    var
      Door: TRSObject;

    begin
      //WriteLn(R_GetObjectAt(1, Point(3204, 3432)));
      If R_FindObjectNearTile(Door, 25720, 1, 3, Point(3204, 3432)) then
        WriteLn('Door found');
        R_OpenDoor(Point(3204, 3432), 'E');
    end;

  9. #384
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    Quote Originally Posted by Athylus View Post
    Hey look I'm no pro with this at all and I'm just messing around with my third script, but thought I'd share this for the ppl working on it. I tried to open a door, and it moves the mouse very close but then stops and says succesfully executed. Here's my code (yes, no failsafes but I'm assuming we're not supposed to need that).

    Simba Code:
    function IsDoorOpen: Boolean;
    var
      Door: TRSObject;

    begin
      //WriteLn(R_GetObjectAt(1, Point(3204, 3432)));
      If R_FindObjectNearTile(Door, 25720, 1, 3, Point(3204, 3432)) then
        WriteLn('Door found');
        R_OpenDoor(Point(3204, 3432), 'E');
    end;
    Try using a if and writeln with your opendoor function, pretty sure it will not write out anything because it failed.

    EDIT: I tried opening a door to the East and South, works fine for me though.

  10. #385
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Athylus View Post
    Hey look I'm no pro with this at all and I'm just messing around with my third script, but thought I'd share this for the ppl working on it. I tried to open a door, and it moves the mouse very close but then stops and says succesfully executed. Here's my code (yes, no failsafes but I'm assuming we're not supposed to need that).

    Simba Code:
    function IsDoorOpen: Boolean;
    var
      Door: TRSObject;

    begin
      //WriteLn(R_GetObjectAt(1, Point(3204, 3432)));
      If R_FindObjectNearTile(Door, 25720, 1, 3, Point(3204, 3432)) then
        WriteLn('Door found');
        R_OpenDoor(Point(3204, 3432), 'E');
    end;
    You need begin and end; if there are multiple things after a if [...] then statement.

  11. #386
    Join Date
    Aug 2013
    Posts
    82
    Mentioned
    0 Post(s)
    Quoted
    35 Post(s)

    Default

    Quote Originally Posted by Dervish View Post
    You need begin and end; if there are multiple things after a if [...] then statement.
    I'm such a newfag, but at least I don't leech and make my own scripts. Btw, it works like 50% of the time. It works better when I change the angle of the camera to a low pitch. Edit: It does say Door Found every time though, lemme try repeating this. LoL game first tho.

  12. #387
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    Quote Originally Posted by Athylus View Post
    I'm such a newfag, but at least I don't leech and make my own scripts. Btw, it works like 50% of the time. It works better when I change the angle of the camera to a low pitch. Edit: It does say Door Found every time though, lemme try repeating this. LoL game first tho.
    Maybe you can try make compass to East when you're trying to open the door.

  13. #388
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Haxz View Post
    Maybe you can try make compass to East when you're trying to open the door.
    @Haxz, I modified line 300 and updated the include. Can you let me know if you're still getting an out-of-range error?

    @Athylus, The function R_OpenDoor will return true if it opened the door. Sometimes it can't find the uptext and it will return false that it didn't open the door.
    Last edited by Krazy_Meerkat; 07-04-2014 at 11:37 AM.

  14. #389
    Join Date
    May 2014
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    there still somethings wrong with AntiRandoms.simba
    [Hint] E:\Simba\Includes\SRL-OSR\SRL\Reflection\AntiRandoms\AntiRandoms.simba(2 52:3): Variable 'FOUNDNPC' never used at line 251
    [Error] E:\Simba\Includes\SRL-OSR\SRL\Reflection\AntiRandoms\AntiRandoms.simba(2 95:5): Identifier expected at line 295
    Compiling failed.

  15. #390
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by snsgold View Post
    there still somethings wrong with AntiRandoms.simba
    Oh I'm sorry about that :3 here's the two functions you need to replace to fix your problem:
    Simba Code:
    function R_FindCombatRandom: boolean;
    var
      Names: TStringArray;
      Temp: TNPCArray;
      i: integer;
    begin
      Result := False;
      if (not R_UnderAttack) then
        exit;
      if (R_PrayerRandoms) then
      begin
        Names := ['security guard', 'evil chicken', 'river troll', 'rock golem', 'shade', 'swarm', 'tree spirit', 'ent', 'zombie'];
      end else
        Names := ['security guard', 'evil chicken', 'river troll', 'rock golem', 'shade', 'swarm', 'tree spirit', 'ent'];
      Temp := R_GetAllNpcs;
      for i := 0 to high(Temp) do
      if (ExactStrInArr(Lowercase(Temp[i].Name), Names)) then
      begin
        if (not R_NearTile(Temp[i].Tile, 10)) then
          Continue;
        Result := True;
        Break;
      end;
      if Result then
        writeln('[Reflection Anti-Randoms] ''' + (Temp[i].Name) + ''' Combat random detected! Running away...');
    end;

    function R_FindCombatRandomEx: boolean;
    var
      Names: TStringArray;
      i: integer;
    begin
      Result := False;
      if ((not R_UnderAttack) or (length(R_FoundNpcs) < 1)) then
        exit;
      if (R_PrayerRandoms) then
      begin
        Names := ['security guard', 'evil chicken', 'river troll', 'rock golem', 'shade', 'swarm', 'tree spirit', 'ent', 'zombie'];
      end else
        Names := ['security guard', 'evil chicken', 'river troll', 'rock golem', 'shade', 'swarm', 'tree spirit', 'ent'];
      for i := 0 to high(R_FoundNpcs) do
      if (ExactStrInArr(Lowercase(R_FoundNpcs[i].Name), Names)) then
      begin
        R_FoundNpcs[i]:= R_GetTNPC(R_FoundNpcs[i].Index);
        if (not R_NearTile(R_FoundNpcs[i].Tile, 10)) then
          continue;
        Result := True;
        Break;
      end;
      if Result then
        writeln('[Reflection Anti-Randoms] ''' + (R_FoundNpcs[i].Name) + ''' Combat random detected! Running away...');
    end;
    Everyone else should be fine, the problem has been fixed, if you auto-update to #72 it will be ok. If you can't compile the include, remember you can always download a new copy from the GC and it should fix any broken files.
    Last edited by Krazy_Meerkat; 07-04-2014 at 11:31 AM.

  16. #391
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    @Haxz, I modified line 300 and updated the include. Can you let me know if you're still getting an out-of-range error?

    @Athylus, The function R_OpenDoor will return true if it opened the door. Sometimes it can't find the uptext and it will return false that it didn't open the door.
    Not getting the error anymore, script running fine for 4 hours straight now. Good work and thanks!

  17. #392
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Haxz View Post
    Not getting the error anymore, script running fine for 4 hours straight now. Good work and thanks!
    That's good Haxz, I found a problem with Talking randoms but it should be fixed now. It's hard to test randoms stuff b/c it can take up to an hour to test the solver..
    Last edited by Krazy_Meerkat; 07-05-2014 at 06:16 AM.

  18. #393
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    If you use GroundItems a lot, you could possibly have memory issues.. Not sure, but I know this can't be right:

    https://code.google.com/p/osrreflect...Items.simba#64

    Leaks _Next and free's _Node when it is unassigned.

    Should most likely be:
    Simba Code:
    _Node := _Next;
    _Next := SmartGetFieldObject(SmartCurrentTarget, _Next, Node_next);
    SmartFreeObject(SmartCurrentTarget, _Node);


    As for the issue of not being able to call methods, why not modify SMART and add it?
    Last edited by Brandon; 07-05-2014 at 06:47 AM.
    I am Ggzz..
    Hackintosher

  19. #394
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    If you use GroundItems a lot, you could possibly have memory issues.. Not sure, but I know this can't be right:

    https://code.google.com/p/osrreflect...Items.simba#64

    Leaks _Next and free's _Node when it is unassigned.

    Should most likely be:
    Simba Code:
    _Node := _Next;
    _Next := SmartGetFieldObject(SmartCurrentTarget, _Next, Node_next);
    SmartFreeObject(SmartCurrentTarget, _Node);


    As for the issue of not being able to call methods, why not modify SMART and add it?
    Thanks for finding that Brandon, I added your fix into the function. Everything has been pushed to update 75
    Last edited by Krazy_Meerkat; 07-05-2014 at 08:14 AM.

  20. #395
    Join Date
    May 2014
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    after update to 75
    got this errorr
    D:\Simba\Includes\SRL-OSR\SRL\Reflection\AntiRandoms\AntiRandoms.simba(1 16:39): Unknown identifier 'R_FindFrog' at line 116

  21. #396
    Join Date
    Mar 2012
    Posts
    201
    Mentioned
    8 Post(s)
    Quoted
    74 Post(s)

    Default

    The problem with invoking methods is that you can corrupt the stream causing the game to crash as it would be out of sync. I could never master it with reflection. It will be interesting to see how you guys do it :-D

  22. #397
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by snsgold View Post
    after update to 75
    got this errorr
    Oh I forgot there might be a conflict with the old R_FrogSolve.simba b/c it isn't listed in the files list for some reason.. So I'm adding it now so that it will be updated with the rest of the files.
    If you download a fresh copy of the include from https://code.google.com/p/osrreflection/source/browse/ and replace your current version it will work. Everything is working fine for me.. Pushing to update 76.

  23. #398
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by fish1328 View Post
    The problem with invoking methods is that you can corrupt the stream causing the game to crash as it would be out of sync. I could never master it with reflection. It will be interesting to see how you guys do it :-D
    Well.. I didn't think about that at all. Either way, I couldn't get the player model..

    Java Code:
    public static void run() throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, Exception {    
            ClassLoader loader = applet.getClassLoader();
           
            Object[] players = getPlayers(loader);
            for (Object player : players) {
                if (player != null) {
                    System.out.println(getPlayerName(loader, player));
                    System.out.println(getPlayerModel(loader, player));
                    System.out.println();
                }
            }
        }
       
        static String getPlayerName(ClassLoader loader, Object player) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("y").getDeclaredField("j");
            f.setAccessible(true);
            return (String)f.get(player);
        }
       
        static Object getPlayerModel(ClassLoader loader, Object player) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("y").getDeclaredField("f");
            f.setAccessible(true);
            return f.get(player);
        }
       
        static Object[] getPlayers(ClassLoader loader) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("client").getDeclaredField("gd");
            f.setAccessible(true);
            return (Object[])f.get(null);
        }


    Prints:

    Code:
    Miss*Ail
    null
    
    Mosinyan
    null
    
    a3-seperate
    null
    
    Stanley*Mole
    null
    
    Vertikaali
    null
    
    I*XII*I
    null
    
    Wrangiw
    null
    Not sure why models are null.. It's definitely a field and not a method..
    I am Ggzz..
    Hackintosher

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

    Default

    Quote Originally Posted by Brandon View Post
    Well.. I didn't think about that at all. Either way, I couldn't get the player model..

    Java Code:
    public static void run() throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, Exception {    
            ClassLoader loader = applet.getClassLoader();
           
            Object[] players = getPlayers(loader);
            for (Object player : players) {
                if (player != null) {
                    System.out.println(getPlayerName(loader, player));
                    System.out.println(getPlayerModel(loader, player));
                    System.out.println();
                }
            }
        }
       
        static String getPlayerName(ClassLoader loader, Object player) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("y").getDeclaredField("j");
            f.setAccessible(true);
            return (String)f.get(player);
        }
       
        static Object getPlayerModel(ClassLoader loader, Object player) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("y").getDeclaredField("f");
            f.setAccessible(true);
            return f.get(player);
        }
       
        static Object[] getPlayers(ClassLoader loader) throws ClassNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
            Field f = loader.loadClass("client").getDeclaredField("gd");
            f.setAccessible(true);
            return (Object[])f.get(null);
        }


    Prints:

    Code:
    Miss*Ail
    null
    
    Mosinyan
    null
    
    a3-seperate
    null
    
    Stanley*Mole
    null
    
    Vertikaali
    null
    
    I*XII*I
    null
    
    Wrangiw
    null
    Not sure why models are null.. It's definitely a field and not a method..
    f.y is a field "cl f;", but this is for getting the players model, not NPC's models.

    EDIT: NPC methods "n", "a" and "z" return a model, method z takes in one integer as parameter.
    Last edited by Frement; 07-05-2014 at 10:06 AM.
    There used to be something meaningful here.

  25. #400
    Join Date
    Mar 2012
    Posts
    201
    Mentioned
    8 Post(s)
    Quoted
    74 Post(s)

    Default

    Pretty sure the model return methods have funky parameters. I've always done it by adding a field to the class and setting that. That's injection though :/

Page 16 of 32 FirstFirst ... 6141516171826 ... LastLast

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
  •