Openkore homunculus check

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

saviour
Noob
Noob
Posts: 2
Joined: 11 Mar 2012, 18:44
Noob?: No

Openkore homunculus check

#1 Post by saviour »

Hello.

Today I stayed awake until 6AM trying to solve my problem with Rest (Vaporize) Skill of my Alchemist.

I made this code block:

Code: Select all

useSelf_skill Vaporize {
	lvl 1
	inMap rachel
	homunculus 1
	timeout 1
}
As can you see this skill can be only executed in map rachel (City of Rachel) and with homunculus present.

But the condition "homunculus 1" didn't work (even homunculus at my side all the time), I removed the condition and Kore the call of this skill worked properly.

So I open Misc.pm to check "homunculus" block to check "WTF is happening dude". I found the following code:

Code: Select all

	if ($config{$prefix."_homunculus"} =~ /\S/) {
		return 0 if (!!$config{$prefix."_homunculus"}) ^ (!$char->{homunculus} && !$char->{homunculus}{state});
	}
But I don't know how program in Perl ou Kore's logic. So I debugged A LOT and changed for the following code:

Code: Select all

	if ($config{$prefix."_homunculus"} =~ /\S/) {
		return 0 unless (defined($char->{homunculus}) && ($char->{homunculus}{state} == 1)) #1 means present
	}
With homunculus present, my code works. My Alch Vaporizes the homunculus correctly. But if I summon again the condition "homunculus 1" seems did not work again :(

How to fix?

Best
uPantcho
Human
Human
Posts: 42
Joined: 05 Nov 2009, 05:25
Noob?: Yes

Re: Openkore homunculus check

#2 Post by uPantcho »

try like this

Code: Select all

if ($config{$prefix."_homunculus"} =~ /\S/) {
      return 0 unless (defined($char->{homunculus}) || ($char->{homunculus}{state} == 1)); #1 means present
   }
probably one of the conditions are not being re-set after sumoning again. if that code works you can try to see which one is the problem


also, there is a semicolon missing at the end (probably a typo?) but that can affect if is in your code
saviour
Noob
Noob
Posts: 2
Joined: 11 Mar 2012, 18:44
Noob?: No

Re: Openkore homunculus check

#3 Post by saviour »

Thanks for the reply uPantcho.

But looking your code seems no logic alter the logical operator. Kore will verify if the $char->{homunculus} is defined (exists in kore instance), then check de homunculus state. If I use logical operator OR the kore will check if defined $char->{homunculus} OR check the state of the same. I think that kores will throw an error.

And the semicolon is a typo ;)

I'm trying to understand why at first moment the condition works and after vaporize and call homunculus again the same condition not works :S
uPantcho wrote:try like this

Code: Select all

if ($config{$prefix."_homunculus"} =~ /\S/) {
      return 0 unless (defined($char->{homunculus}) || ($char->{homunculus}{state} == 1)); #1 means present
   }
probably one of the conditions are not being re-set after sumoning again. if that code works you can try to see which one is the problem


also, there is a semicolon missing at the end (probably a typo?) but that can affect if is in your code
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Openkore homunculus check

#4 Post by EternalHarvest »

The problem is most probably not with that condition, but with $char->{homunculus}{state}.

Related:
http://forums.openkore.com/viewtopic.php?t=16612