Results 1 to 4 of 4

Thread: Error finding NPCs

  1. #1
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Error finding NPCs

    I'm back again, too soon methinks.. It's a learning process!

    Simba Code:
    Procedure attackEnemy;
    var
    NPCs : TNPCArray;
    I, II : Integer;
    Begin
      if (infight) then exit;

     NPCs := SortNPCs(GetNPCs(['Tz-Kih','Tz-Kek','Tok-Xil']));
        For I:=0 to high(NPCs) do
        begin
          Writeln('[' + ToStr(I) + ']Name: ' + NPCs[I].Name + '(' + ToStr(NPCs[I].Tile.X) + ', ' + ToStr(NPCs[I].Tile.Y) + ') ID: ' + ToStr(NPCs[I].ID) + ' - Index:' + ToStr(NPCs[I].Index));
          Writeln('  Orientation: ' + ToStr(NPCs[I].Orientation) + ' - Level: ' + ToStr(NPCs[I].Level) + ' - Animation:' + ToStr(NPCs[I].Animation) + + ' - HPRatio:' + ToStr(NPCs[I].HPRatio));
          Writeln('  Moving:' + ToStr(NPCs[I].Moving) + ' - InFight:' + ToStr(NPCs[I].Fighting) + ' - Interacting:' + ToStr(NPCs[I].Interacting) + ' - Height:' + ToStr(NPCs[I].Height));
          Writeln('  Actions:');
          For II:=0 to High(NPCs[I].Actions) do
            Writeln('    ' + NPCs[I].Actions[II]);
        end;

    end;

    Why does this just give an error message of 'Error: Could not call proc at line 259'?

    And why can't I call 'MyNPC := SortNPCs(GetNPCs);' to get all of the NPCs around me?

    ~Harry

    *Remade this thread in the correct section*

    Quote Originally Posted by Zyt3x
    What line is line 259?
    It is the decleration of the proc.
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  2. #2
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I will be back in about 6 hours, I'm not just ignoring the thread
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  3. #3
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Here, just use my code.

    Simba Code:
    function InteractWithNPC(action:string;npc:TNPC):boolean;
    var t:TNPC;
    begin
      if not TileOnMS(npc.tile,30) then
      begin
        WalkToTile(npc.tile,1,1);
        R_Flag;
      end;
      MoveBox(PtToBox(TileToMS(npc.tile,30),10));
      Wait(100+random(125));
      if R_IsUpText(action+' '+npc.name) then
        ClickMouse2(true)
      else
      begin
        ClickMouse2(false);
        R_ChooseOptionMulti([action,npc.name]);
      end;
      wait(400+random(150));
      r_Flag;
      result := InteractingWithMe(npc);
    end;

    procedure FinishAnimating();
    var i:integer;
    begin
      for i := 0 to 16 do
      begin
        if CharacterAnimating then i := 0;
        wait(40);
      end;
    end;

    function FightNPC(name:string):boolean;
    var mobs:TNPCArray;
        index:integer;
    begin
      index := 0;
      mobs := SortNPCs(GetNPCs(name));
      for index := 0 to high(mobs) do
      begin

        if (mobs[index].fighting or mobs[index].moving) then
          continue;

        result := InteractWithNPC('attack',mobs[index]);

        FinishAnimating;

        break;
      end;
    end;

    Here's the mouse functions I used:
    Simba Code:
    function MouseInBox(box:TBox):boolean;
    var pt:TPoint;
    begin
      GetMousePos(pt.x,pt.y);
      result := PointInBox(pt, box);
    end;

    procedure ClickBox(box:TBox;left:boolean);
    var x,y:integer;
    begin
      x := (box.x2 - box.x1)/2;
      y := (box.y2 - box.y1)/2;
      if not MouseInBox(box) then
        MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
      ClickMouse2(left);
    end;

    procedure MoveBox(box:TBox);
    var x,y:integer;
    begin
      x := (box.x2 - box.x1)/2;
      y := (box.y2 - box.y1)/2;
      if not MouseInBox(box) then
        MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
    end;

  4. #4
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Cheers Feroc1ty.
    How can this be edited to allow for an array of enemies?

    It's for the fight caves, so the enemies aren't all called the same unless Simba allows for wildcarding? (I'm guessing it doesn't).

    Edit: nevermind, I was being silly!
    Last edited by HarryJames; 02-28-2011 at 12:38 AM.
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

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
  •