Openkore.com

OpenKore Forums
It is currently 13 Dec 2017, 07:16

All times are UTC - 5 hours [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: The config key of "useSelf_skill"
PostPosted: 01 Dec 2010, 23:18 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 214
About the config key of "useSelf_skill", I make some changes in /src/AI.pm and /src/Misc.pm.
I add two attributes("nearMonsters" and "nearDist") into the config key of "useSelf_skill".

The description:
When I set the "useSelf_skill" for the "Endure" skill. I think the moment for using "Endure" on self should be before attacking or attacked (or even walking through some monsters). The conditions for using "Endure" on self should be how closed some specified monsters. So, I add the two attributes "nearMonsters" and "nearDist" into the config key of "useSelf_skill", and add some codes into /src/AI.pm and /src/Misc.pm.

the codes are:
the AI.pm:
(1) add a line before "ai_getAggressives". such as:
Code:
...........
our @EXPORT = (
    qw/
    ai_clientSuspend
    ai_drop
    ai_follow
    ai_partyfollow
    ai_getNearMonster
    ai_getAggressives
    ai_getPlayerAggressives
    ai_getMonstersAttacking
................

(2) add a subroutine "ai_getNearMonster" befor "sub ai_getNearMonster", such as:
Code:
sub ai_getNearMonster {
    my ($type, $party) = @_;
    my $dist = shift;
    my $wantArray = wantarray;
    my @agMonsters;
    $dist = 20 unless($dist);

    foreach my $monster (@{$monstersList->getItems()}) {
        my $control = Misc::mon_control($monster->name,$monster->{nameID}) if $type || !$wantArray;
        my $ID = $monster->{ID};
        if ($monster->distance() < $dist) {
            if ($wantArray) {
                # Function is called in array context
                push @agMonsters, $ID;
            }
        }
    }

    return @agMonsters;
}


the Misc.pm
Add lines with in the "checkSelfCondition" subroutime, near the line 3774 , such as:
Code:
.......
    if ($config{$prefix . "_notWhileSitting"} > 0) { return 0 if ($char->{sitting}); }
    if ($config{$prefix . "_notInTown"} > 0) { return 0 if ($field->isCity); }

    if ($config{$prefix . "_nearMonsters"} && ($prefix =~ /useSelf_skill/i)) {
        my $exists;
        foreach (ai_getNearMonster($config{$prefix . "_nearDist"})) {
            if (existsInList($config{$prefix . "_nearMonsters"}, $monsters{$_}->name)) {
                $exists = 1;
                last;
            }
        }
        return 0 unless $exists;
    }

    if ($config{$prefix . "_monsters"} && !($prefix =~ /skillSlot/i) && !($prefix =~ /ComboSlot/i)) {
        my $exists;
        foreach (ai_getAggressives()) {
.......


May be there is some other solution with plugins !


Top
 Profile  
 
 Post subject: Re: The config key of "useSelf_skill"
PostPosted: 04 Dec 2010, 16:22 
Offline
Administrator
Administrator
User avatar

Joined: 24 Apr 2008, 12:02
Posts: 1299
Nice Feature... but the Code should be moved to Plugin (is that could be done using current system), or saved for better day's.
As currently OpenKore is under heavy feature freeze before 2.1 Release.
the the Release day will be the day, when all the critical and logic bug's will be fixed. (check the list of bug reports).

Edit. Moved to Commit Queue

_________________
Join our Team. Click here.
Image


Image


Top
 Profile  
 
 Post subject: Re: The config key of "useSelf_skill"
PostPosted: 09 Dec 2010, 05:13 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 214
I am learning for writing plugins !
I will change the featrue into plugin, after I understand the plugin mechaism.


Top
 Profile  
 
 Post subject: Re: The config key of "useSelf_skill"
PostPosted: 10 Dec 2010, 17:49 
Offline
Developers
Developers

Joined: 05 Dec 2008, 05:42
Posts: 1811
Example of adding self conditions with a plugin:
http://openkore.svn.sourceforge.net/vie ... iew=markup


Top
 Profile  
 
 Post subject: Re: The config key of "useSelf_skill"
PostPosted: 10 Dec 2010, 21:03 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 214
Thank you very much !
I will try to add some plugin what like the sample !

Thanks again !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group