processAutoStatsRaise/processAutoSkillsRaise & teleport

This place is for Closed bug reports only. NOT for asking help!

Moderators: Moderators, Developers

User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#11 Post by kLabMouse »

Technology wrote:note: the check in 3 is necessary, not only because we don't want to spam packets but also because we need control over exactly how many skillpoints we want to invest in a skill.
The Only Thing we need to check, is skill point's Left. Nothing more. Because On Teleport, we do not Level Up.
Only IF we Level Up before skill rise, we get a new skill point. But that could be easily detected? because server send data in one big soup of stat packets.
mhelmajo16
Noob
Noob
Posts: 1
Joined: 03 Jan 2010, 22:13
Noob?: Yes

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#12 Post by mhelmajo16 »

can anyone please do repost the step on how to fix the error in auto stat add. thanks
Shadow7
Human
Human
Posts: 25
Joined: 03 Dec 2009, 12:30
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#13 Post by Shadow7 »

Sorry, it's been a while.

The solution i was thinking of more or less goes like this:
but first some terms :D

Let statType be (agi dex vit luk str int)
Let statValue be any integer from 2 to 99 representing the value of the said statType (at the time of invoking it)

For processAutoStatsRaise
processAutoStatsRaise(!$statChanged)
var st1 = statType to be raised
var stVal = st1.statValue
$receivedStatChangePacket = 0;
$receivedSoupOfStatPackets = 0;
$statChanged = 1;

#Note: stVal+1 target statValue after processAutoStatsRaise is finished

For $statChanged
If (($receivedStatChangePacket || $receivedSoupOfStatPackets) && st1.stVal+1 == st1.statValue )
$statChanged = 0;

This solution assumes that the stat variables in openkore are updated whenever: the statChanged Packet (00BC?) is received and whenever we receive the soup of packets klabMouse mentioned
if they are not as assumed, code it to do so? :P

Questions, Clarifications and Criticisms are welcomed.
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#14 Post by kLabMouse »

I think. The best solution is to move Stat's rise into Task. so we do not add additional var's, or anythin that grow useless code.
Shadow7
Human
Human
Posts: 25
Joined: 03 Dec 2009, 12:30
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#15 Post by Shadow7 »

For processAutoSkillsRaise

How else can skills be updated without the 010E [Skill Level Changed] packet? Is there a way of requesting the 010F [Skills List] packet from the server?

From what I've noticed [Skills List] is only received when the character logs in to the map server. (unlike stat_info2, the soup of packets klabMouse mentioned, which is on map change and other events)
Any changes to the skills then would have to solely rely on [Skill Level Changed].
But as mentioned we are unable to receive [Skill Level Changed] while in the said teleport phase.

Edit: I am testing a cleaner fix thant that I originally mentioned for processAutoStatsRaise. It consists of setting $statChanged to 0 when we receive stat_info2 as well as checking if the stat was properly added. I added 2 global variables though which saves that stat to be added as well as its value. Will post results later after testing.

EDIT2: Fix for processAutoStatsRaise (After testing with 3 characters with ai_teleport_idle 0.5;)
Need someone else to double check via testing

Declare 2 new global Variables in globals.pm namely $statChanged2 and $statVal
Initialize those variables to 0 in functions.pl

In Receive.pm

Code: Select all

sub stat_info2 {
	my ($self, $args) = @_;
	return unless changeToInGameState();
	my ($type, $val, $val2) = @{$args}{qw(type val val2)};
	if ($type == 13) {
		$char->{str} = $val;
		$char->{str_bonus} = $val2;
		debug "Strength: $val + $val2\n", "parseMsg";
	} elsif ($type == 14) {
		$char->{agi} = $val;
		$char->{agi_bonus} = $val2;
		debug "Agility: $val + $val2\n", "parseMsg";
	} elsif ($type == 15) {
		$char->{vit} = $val;
		$char->{vit_bonus} = $val2;
		debug "Vitality: $val + $val2\n", "parseMsg";
	} elsif ($type == 16) {
		$char->{int} = $val;
		$char->{int_bonus} = $val2;
		debug "Intelligence: $val + $val2\n", "parseMsg";
	} elsif ($type == 17) {
		$char->{dex} = $val;
		$char->{dex_bonus} = $val2;
		debug "Dexterity: $val + $val2\n", "parseMsg";
	} elsif ($type == 18) {
		$char->{luk} = $val;
		$char->{luk_bonus} = $val2;
		debug "Luck: $val + $val2\n", "parseMsg";
	}
	$statChanged = 0;
}
In CoreLogic.pm

Code: Select all

##### AUTO STATS RAISE #####
sub processAutoStatsRaise {
	if (!$statChanged && ($char->{$statChanged2} == $statVal+1 || !$statVal) && $config{statsAddAuto}) {
		# Split list of stats/values
		my @list = split(/ *,+ */, $config{"statsAddAuto_list"});
		my $statAmount;
		my ($num, $st);

		foreach my $item (@list) {
			# Split each stat/value pair
			($num, $st) = $item =~ /(\d+) (str|vit|dex|int|luk|agi)/i;
			$st = lc $st;
			# If stat needs to be raised to match desired amount
			$statAmount = $char->{$st};
			$statAmount += $char->{"${st}_bonus"} if (!$config{statsAddAuto_dontUseBonus});

			if ($statAmount < $num && ($char->{$st} < 99 || $config{statsAdd_over_99})) {
				# If char has enough stat points free to raise stat
				if ($char->{points_free} &&
				    $char->{points_free} >= $char->{"points_$st"}) {
					my $ID;
					if ($st eq "str") {
						$ID = 0x0D;
					} elsif ($st eq "agi") {
						$ID = 0x0E;
					} elsif ($st eq "vit") {
						$ID = 0x0F;
					} elsif ($st eq "int") {
						$ID = 0x10;
					} elsif ($st eq "dex") {
						$ID = 0x11;
					} elsif ($st eq "luk") {
						$ID = 0x12;
					}

					message TF("Auto-adding stat %s\n", $st);
					$messageSender->sendAddStatusPoint($ID);
					$statChanged = $st;
					$statChanged2 = $st;
					$statVal = $char->{$st}; 
					last;
				}
				last;
			}
		}
	}
}
Sorry I deleted the comments on processAutoStatsRaise to make it shorter :D

As for processAutoSkillsRaise I believe that yes, we have to have a task for it so as to pause the AI. Although, there will be the (hopefully) rare occurence of it teleporting because of an attack from a monster while it receives the skillChanged packet that will cause the bug. The only solution to this I believe is to relog.(Unless there is a way for us to request the skill list and or skill points remaining from the server)
Shadow7
Human
Human
Posts: 25
Joined: 03 Dec 2009, 12:30
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#16 Post by Shadow7 »

Bump?
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#17 Post by Technology »

Made an attempt to fix skill raising with a task.
I suspect that there might be bugs tho...
So, if you want to test, try revision: r7150
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
Shadow7
Human
Human
Posts: 25
Joined: 03 Dec 2009, 12:30
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#18 Post by Shadow7 »

Ok, will do so in a while. I've been trying another solution for raising skills. It makes use of assuming the skill was successfully added if ever it gets stuck. However I will make it go to the next skill to be added if the skill at present is 1 less of the target level. Also, I'm happy to report that out of the 30 characters I made (x2 mod exp this week) all of them were able to add stats properly with the above fix. ^_^
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#19 Post by Technology »

hey shadow, could you provide a diff patch?

As for the skill upgrade, i've ran several tests, teleporting + upgrading and there didn't seem to be any trouble with it,
however, it still needs to be tested thoroughly.
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
Shadow7
Human
Human
Posts: 25
Joined: 03 Dec 2009, 12:30
Noob?: No

Re: processAutoStatsRaise/processAutoSkillsRaise & teleport

#20 Post by Shadow7 »

Sure, no idea how to but will learn how to :)) As for the stuff I edited, I was observing one of my bots yesterday and it had not used 69 stat points. I realized that the dependency of the fix I made on stat_info2. My hypothesis for what happened was the bug occurred and after that it was able to kill monsters in succession without tele searching. It went back to normal when I made it teleport though.

P.S. Haven't tested revision r7150 yet, will do so by tonight.