SRL Archive - Reflection Help

Methods of accomplishing things


masterBB

2011-03-22 18:58:09

At this moment I'm writing an pretty complicated reflection script. It's containing walking within caves, walking outside, teleporting, using fairy rings, and fighting.

I've done some research and started developing a fast fight routine. But I've a few questions regarding fight detection.

Approaches I could use:
  1. Using the inFight var of getMe
  2. Tracking the enemy and use his inFight var
  3. using the enemies there interact var
  4. Tracking the enemy and using there animation
  5. Tracking the enemy and using the HPRatio
  6. Using XP to see if I hitted

The cons of using the inFight var is that it's updated pretty slowly, after the fight you will have to wait till the complete animation of the enemy has ended. The pros of using the inFight var is that it's pretty stable.

I could us my combat xp to count how much I've hitted, but that wouldn't work if the NPC has healed between the fight. And how long would you've to wait before you realize you probably mis clicked the NPC?

For the other options I've to use the function "AreWeInteracting" or something similar. But the problem is that sometimes If you're fast this will return the previous NPC. So I've to check that the NPC hasn't got the same index as the previous one.

Currently I use:
Click an NPC and records it index.
Waits till an NPC is interacting with me, if its different than update the index.
Waits till the NPC is playing its dying animation(HPRatio doesn't work :O).
Record the index as the old index, repeat this, but make sure the new indexes are not equal to the old index.

Is there an other reflection based way of detecting fighting I might be missing? Could I improve something?

And my second, smaller question, is: Is there an SRL/reflection function to handle fairy rings or do I've to write my own?

Gu3st...

2011-03-22 19:01:55

"For the other options I've to use the function "AreWeInteracting" or something similar. But the problem is that sometimes If you're fast this will return the previous NPC. So I've to check that the NPC hasn't got the same index as the previous one." Seems to be the safes way imo, and "Is there an SRL/reflection function to handle fairy rings or do I've to write my own?" You'd have to write those yourself

Ogre

2011-03-22 19:05:25

click npc
interacting := GetMe.Interacting;
T := GetSystemTime;
while ((Interacting = -1) and (GetSystemTime < T + (1000 + Random(500))) do
Interacting := GetMe.Interacting;
while (Interacting > -1) do
Interacting := GetMe.Interacting

repeat that^ ?

masterBB

2011-03-22 19:20:22

From: Ogre
click npc
interacting := GetMe.Interacting;
T := GetSystemTime;
while ((Interacting = -1) and (GetSystemTime < T + (1000 + Random(500))) do
Interacting := GetMe.Interacting;
while (Interacting > -1) do
Interacting := GetMe.Interacting

repeat that^ ?


So simple, but it works! Thanks a lot, how could I've missed that.

function waitKill:Boolean;
var
me:TME;
t:Integer;
begin
writeln('lets wait till in fight');
t := getSystemTime;
repeat
me := getMe;
if( t < getSystemTime -5000) then
begin
writeln('missclicked?');
Exit;
end;
wait(50+random(10));
until(me.Interacting > 0);
writeln('lets wait till kill');
t := getSystemTime;
repeat
me := getMe;
if( t < getSystemTime -50000) then
begin
writeln('missed a lot?');
Exit;
end;
wait(50+random(10));
until(me.Interacting < 1);
Result := True;
end;

And also thank you zytex for your fast reply.

Ogre

2011-03-22 19:26:30

I'm not sure, but you may be able to deal with the fairy rings by using Interfaces.simba, but I really no nothing about that.

Maybe you'll learn something in this thread

masterBB

2011-03-22 19:31:48

From: Ogre
I'm not sure, but you may be able to deal with the fairy rings by using Interfaces.simba, but I really no nothing about that.

Maybe you'll learn something in this thread


I was already aware of the interfaces. I do understand how they work as I've some knowledge of java and made multiple games. But if there was a simple SRL function, it would spare me the time to debug all interfaces to get the right parent and child interfaces IDs.

pyroryan

2011-03-22 19:38:51

Somewhat relevant, but I added R_IsPlayerInCombat by request of TomTuff.
https://github.com/SRL/srl-reflection/commit/ef8c8edd51ab3f9729be5dce951943788a2063ac

masterBB

2011-03-22 19:50:08

"A few seconds slow on determining combat status."
That would be as inFight right? Than I think Ogre his solution is faster.

pyroryan

2011-03-22 19:54:05

From: masterBB
"A few seconds slow on determining combat status."
That would be as inFight right? Than I think Ogre his solution is faster.


You're correct, Orge's way should be faster. The function is more for a method of determining if you're fighting with something rather than a specific NPC.