SRL Archive - Reflection Development

4 combat additions


Flight

2011-09-20 22:42:11

Heya,

I made these to fuel my X-Fighter script and they all seem to do the job successfully. The 2 Summoning functions I had already made in the past for Naturez but I don't think I posted them separately anywhere, so here they are.

Function R_GetNPCTarget(Null: Boolean): TNPC;

Function R_GetNPCTarget(Null: Boolean): TNPC;
Var
i: Integer;
NPCs: TNPCArray;
begin
NPCs := R_SortNPCs(R_GetInteractingNPCs(Null));
if(GetArrayLength(npcs) = 0) then
Exit;

for i := 0 to high(NPCs) do
begin
if (NPCs[i].InCombat) then
Result := NPCs[i];
end;

end;

This is handy if you need to exit your main fighting procedures (for whatever reason) and you need to grab that same NPC.

Function R_GetSpecialPercent(Who: String): Integer;

Function R_GetSpecialPercent(Who: String): Integer;
begin
Result := 0;
Case Lowercase(Who) of
'me': Result := ((R_GetSetting(300))/10);
'familiar': Result := (R_GetSetting(1177));
end;
end;

This will grab how much special attack you or your familiar has remaining.

Function R_UsingFamiliar: Boolean;

Function R_UsingFamiliar: Boolean;
Var
S: TInterfaceChild;
begin
Result := False;
S := R_GetInterfaceChild(747, 3);
Result := (S.TextureID = 1802);
end;

^ Self-explanatory

Function R_InteractFamiliar(Option: String): Boolean;

Function R_InteractFamiliar(Option: String): Boolean;
Var
O: TInterfaceChild;
begin
if R_UsingFamiliar then
begin
if (Option = '') then
begin
O := R_GetInterfaceChild(747, 8);
R_ClickInterface(O, 1);
Result := True;
end else
begin
MouseBox(695,140,740,155,2);
if ChooseOption(Option) then
Result := True
else
Writeln('Incorrect option');
end;
end else
Writeln('No familiar present!');

Wait(100 + Random(50));
end;

This will interact with your summoned familiar based on the 'Option' string you use as the parameter. It's also, obviously, not 100% Reflection. The valid options are: 'Attack','Cast','Interact,'Renew','Take','Dismiss','Call','Details','Select'

Hope others find these useful as well. :)

onilika

2011-09-21 13:36:03

Well done Flight, really well done! Yes, was pretty enlightening!
You should continue to make these small teaching lessons! Now we all can have an idea of what to write on scripts, etc..

DeSnob

2011-09-24 09:36:09

How did you manage to find the interfaces?

Flight

2011-09-24 11:54:57

The Interface Explorer; a neat little Reflection tool that comes with the include.

DeSnob

2011-09-24 12:37:24

Wow.. it's been there all this time and I never knew what it was used for..now I feel stupid.