checkExtraCondition

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

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

checkExtraCondition

#1 Post by Technology »

This plugin will allow you to add more/custom conditions.

Atm all it does is adding a condition for the players level
and a condition for guildtitle, but feel free to add more conditions and share.

Got suggestions to improve the code/to add more features? Just post em up.

Code: Select all

# checkExtraCondition by Technology
#
# $Id: checkExtraCondition.pl 6603 2008-11-21 16:48:56Z Technology $
#
# This source code is licensed under the
# GNU General Public License, Version 2.
# See http://www.gnu.org/licenses/gpl.html

package checkExtraCondition;

use strict;
use Plugins;

use Globals qw(%config $char);
use Utils qw(inRange);
use Utils::DataStructures qw(existsInList);

use Log qw(message error warning debug);

Plugins::register('checkExtraCondition', 'check extra conditions', \&onUnload);
my $hooks = Plugins::addHooks(
	['checkSelfCondition', \&checkSelfCondition, undef],
	['checkPlayerCondition', \&checkPlayerCondition, undef],
	['checkMonsterCondition', \&checkMonsterCondition, undef],
);

sub onUnload {
    Plugins::delHooks($hooks);
}

sub checkSelfCondition {
	my ($self, $args) = @_;
	my $prefix = $args->{prefix};
	
	# conditions
	($args->{return} = 0) unless (
		checkActorLevel($prefix, $char) &&
		checkActorGuildTitle($prefix, $char)
	);
	debug ("self: $args->{return}\n"), "checkExtraCondition";
}

sub checkPlayerCondition {
	my ($self, $args) = @_;
	my $prefix = $args->{prefix};
	my $player = $args->{player};
	
	# conditions
	($args->{return} = 0) unless (
		checkActorLevel($prefix, $player) &&
		checkActorGuildTitle($prefix, $player)
	);
	debug ("player: $args->{return}\n"), "checkExtraCondition";
}

sub checkMonsterCondition {
	my ($self, $args) = @_;
	my $prefix = $args->{prefix};
	my $player = $args->{monster};
	
	# conditions
	debug ("monster: $args->{return}\n"), "checkExtraCondition";
}


#######################################
#######################################
### CONDITION FUNCTIONS
#######################################
#######################################

sub checkActorLevel {
	my ($prefix, $actor) = @_;
	if ($config{$prefix . "_blvl"}) { return 0 unless inRange($actor->{lv}, $config{$prefix."_blvl"}); }
	else { return 1 }
}

sub checkActorGuildTitle {
	my ($prefix, $actor) = @_;
	if ($config{$prefix."_isGuildTitle"}) { return 0 unless ($actor->{guild} && existsInList($config{$prefix . "_isGuildTitle"}, $actor->{guild}{title})); }
	else { return 1 }
}

return 1;
example:

Code: Select all

partySkill Spirit of Rebirth {
	lvl 5
	target_isJob High Novice, High Swordsman, High Magician, High Archer, High Acolyte, High Merchant, High Thief
	target_whenStatusInactive Spirit
	target_blvl <= 50
	target_isGuild guildname
	target_isGuildTitle guildtitle
}
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!

Darki
Been there done that!
Been there done that!
Posts: 143
Joined: 25 Oct 2008, 08:14
Noob?: No
Location: Spain, Madrid
Contact:

Re: checkExtraCondition

#2 Post by Darki »

Would be possible to check if there is "enough space" to do the skill?

For example: to use the skill Sprint (to get Spurt), you need a minimun space to run & stop, because if not, the bot can stomp endlessy by a wall/enemy/character till it runs out of SP.

If you were able to know if there is any obstacle in the, for example, 12 next squares in the direction you're facing, that wouldn't happen. Something like:

Code: Select all

useSelf_skill Run {
	lvl 10
	sp > 10
	freePath 12 # ---> checks if there's any non stepable ground, monster or player, in the 12 squares in front of you
	whenStatusInactive Spurt
}
It would work in Charge Attack for Knights too, I guess.

I'd love to help making it but I have no idea of how would it be, I don't know perl. I don't want to be spoonfeed, so if at least I could have any advice on how would it look like, I'd happily help making it. ^^U
ImageImageImage
ImageImageImage
ImageImageImage

Bibian
Perl Monk
Perl Monk
Posts: 416
Joined: 04 Apr 2008, 03:08

Re: checkExtraCondition

#3 Post by Bibian »

possible, simply calculate a path X tiles infront of yourself but dont actually walk there :P

you can use checkLineWalkable(Local, to, [min_obstacle_size = 5]) , min_obstacle_size would have to be 0 to ensure it doesnt route around obstacles.
then all you need to do before using this is figuring out where you're facing

Darki
Been there done that!
Been there done that!
Posts: 143
Joined: 25 Oct 2008, 08:14
Noob?: No
Location: Spain, Madrid
Contact:

Re: checkExtraCondition

#4 Post by Darki »

Isn't there any function that returns the position you're facing? Also, another thing is that the plugin must check if there's anything on the path, not only if it's walkable or not. If you hit a monster/character in that way you'll stop too.

Another possibility would be (and I think it would be more "human-like"), if it's possible to determine a "sprintable path" in radius around the character. if you find any walkable path in one of the eight possible ways around you, you face that direction then run. Of course, with the proper check for the obstacles in that path.

I guess the way would be checking the avobe function eight times. xD
ImageImageImage
ImageImageImage
ImageImageImage

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: checkExtraCondition

#5 Post by kali »

I made something similar a while back:

http://bibian.ath.cx/openkore/viewtopic.php?t=15200

Although Tech's plugin has additional condition plugin hooks :)
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

Darki
Been there done that!
Been there done that!
Posts: 143
Joined: 25 Oct 2008, 08:14
Noob?: No
Location: Spain, Madrid
Contact:

Re: checkExtraCondition

#6 Post by Darki »

basically it's a "use skill when you're at this location", uh? It can be really useful for skills like that teleport or plant cultivation. xD

So, for the stepable radius, how would it be? check all eight directions, I guess with that function, then, check if there are monster/player obstacles in the "good" ones? How would that part be?
ImageImageImage
ImageImageImage
ImageImageImage

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

Re: checkExtraCondition

#7 Post by Technology »

Darki wrote:basically it's a "use skill when you're at this location", uh? It can be really useful for skills like that teleport or plant cultivation. xD

So, for the stepable radius, how would it be? check all eight directions, I guess with that function, then, check if there are monster/player obstacles in the "good" ones? How would that part be?
I've made a plugin for locationSkill a while back that allowed me to do plant cultivation (or any skill) on a square relative to (thus not an absolute fixed square location) the player on places where there are no monsters (can't overlap them)

Concept of combined skillblock conditions providing more functionality:
line_walkable 5
(code behind this checks the line in wich the player is currently facing for walkable)

line_LOS 5
(code behind this checks the line in wich the player is currenty facing for LOS (walkable or snipable)

line_walkable_obstacleNot monster, player, ... (or maybe [1|0])
line_LOS_obstacleNot monster, player, ...
(code behind this does an additional check for actors on that line)

line_walkable_obstacle monster, player, ... (or maybe [1|0]) (or maybe condition number ex. > 10)
line_LOS_obstacle monster, player, ...
(usefull for phantastic arrow mobbing?)

For the running skill you will only be using: line_walkable, line_walkable_obstacleNot monster, player, ... (or maybe [1|0])
I think we should think about better naming conventions for the current conditions (grouped etc...)

Criticism on the condition system
if ($config{$prefix."_isGuildTitle"})
Kore should NOT have to check wether to use a condition or not every single time.
(wich it currently is, causing kore to hog extra resources)

It should be more like the macro plugin,
where hooks are only used when you actually want to use them in any of the automacro's.

An improvement on that would be: using a hook (or in skillblock, a condition) dependant on the skillblock options for each skillblock.
If i'm not mistaken, this is exactly what kLabMouse wants to do with smart events.

[/braindump] ;)
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!

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: checkExtraCondition

#8 Post by kali »

We are, unfortunately, stuck with polling since that is the original design and there's not much we can do about it. Workarounds can only get you so much. That's not saying it's bad though; polling can be useful in some cases, but applied to a very dynamic environment like the Ragnarok World, it doesn't scale that much.

The range specifier of the plugin is a radius of sorts, it draws a square with the x,y coordinate at the center. I made the plugin for use in the ayothaya dungeons level 2 where there were pits that kore would sometimes walk through - i just made the whole area a teleport zone.
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

Darki
Been there done that!
Been there done that!
Posts: 143
Joined: 25 Oct 2008, 08:14
Noob?: No
Location: Spain, Madrid
Contact:

Re: checkExtraCondition

#9 Post by Darki »

Technology wrote:Stuff :shock:
I somewhat had an idea of what you say, but I still have no idea on how to make it for the new plugin part. ^^U So, it would be possible to do all stuff, like checking the path, or the radius, and the obstacles, from what I deduce, isn't it?

This plugin would be extremely useful to add conditions for "particular" skills, such as the level thing in the SL rebirth spirit skill, or this one, to make the sprint skill work. I can think of more, like, for example, would it be possible to add a condition to check the distance between a monster and a player? in that case it would be possible to make a block to use skills like Pneuma on an ally when somebody attacks him/her from long range.
ImageImageImage
ImageImageImage
ImageImageImage

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: checkExtraCondition

#10 Post by kali »

http://bibian.ath.cx/openkore/viewtopic.php?t=7398

You can probably take a few of the concepts there. Never got that one working well though, the bot would get stuck on narrow corridors.

It was great on open fields though.
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

Post Reply