Plugin applySongs

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
Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Plugin applySongs

#1 Post by Historm »

The Following code hooks into kore's area_spell subroutine in receiving packets. area_spell triggers for every spell that occupies space on the ground. This plugin uses that hook to determine if the player has been effected by a bard or dancer song, and if so, adds the effect of that song to the actor->activeStatuses() hash. It checks every area spell to see if the player is standing in it, and takes into account that performers do not gain the effect unless they are soul linked. it will add the effect of the song to the list of statuses that effects the player for 20 seconds.

I wrote it by studying many other plugins and added the code that seemed to be needed to make the plugin load and run. The entire sub applySongs () routine is my own code, the remainder is what I thought I needed to make it work. Much of it might be extraneous.

# Code by historm, other openkore plugin authors
# licensed under GPL
# todo:
# eliminate unneeded code
# add support for ensemble skills
# add support for 3rd class skills
# add logic for properly applying songs based on being in party, being enemy in pvp areas
# improve logic to speed up processing
# determine how exactly song effect durations work once a player leaves the area of the song
# model said duration logic and add implement variable(s) to set the durations of the songs
# add logic to apply song statuses to the statusActive hash for all actors, not only the player
# add support for non iRO servers
# build up to standard for committing into future openkore revisions

package applySongs;

use strict;
use Plugins;

use Time::HiRes qw(time);

use Globals;
use Utils;
use Misc;
use AI;
use Network::Send;
use Commands;
use Skill;
use Log qw(debug message warning error);
use Translation;

Plugins::register('applySongs', 'Apply Status Effect for standing in Songs.', \&on_unload, \&on_reload);

my $hooks = Plugins::addHooks(
['packet_areaSpell', \&applySongs, undef]
);

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

sub on_reload {
message "applySongs plugin reloading\n";
Plugins::delHooks($hooks);
}

sub applySongs {

my (undef, $args) = @_;
my $sourceID = $args->{sourceID};
my $type = $args->{type};
my $x = $args->{x};
my $y = $args->{y};
#print "Checking for Songs. Checking skill ".getSpellName($type)." aka $type from ".getActorName($sourceID)." on ".getActorName($char->{ID}).".\n";
#if the caster is me AND I am NOT Soul link, OR if I am NOT standing on the location of the area spell, GTFO
return if (($sourceID eq $char->{ID} && !$char->statusActive('EFST_SOULLINK')) || !($char->{pos_to}{x} == $x && $char->{pos_to}{y} == $y));
#print "First if statement passed.\n";
#if this is a type of song spell, AND I am NOT under the effect of that spell, apply that spell status for 20 seconds
if ($type == 167 && !$char->statusActive('EFST_WHISTLE')) {
$char->setStatus('EFST_WHISTLE', 1, 20000);
}
elsif ($type == 168 && !$char->statusActive('EFST_ASSASSINCROSS')) {
$char->setStatus('EFST_ASSASSINCROSS', 1, 20000);
}
elsif ($type == 169 && !$char->statusActive('EFST_POEMBRAGI')) {
$char->setStatus('EFST_POEMBRAGI', 1, 20000);
print "I am now ".getSpellName($type)."!\n";
}
elsif ($type == 170 && !$char->statusActive('EFST_APPLEIDUN')) {
$char->setStatus('EFST_APPLEIDUN', 1, 20000);
}
elsif ($type == 172 && !$char->statusActive('EFST_HUMMING')) {
$char->setStatus('EFST_HUMMING', 1, 20000);
}
elsif ($type == 173 && !$char->statusActive('EFST_DONTFORGETME')) {
$char->setStatus('EFST_DONTFORGETME', 1, 20000);
}
elsif ($type == 174 && !$char->statusActive('EFST_FORTUNEKISS')) {
$char->setStatus('EFST_FORTUNEKISS', 1, 20000);
}
elsif ($type == 175 && !$char->statusActive('EFST_SERVICEFORYOU')) {
$char->setStatus('EFST_SERVICEFORYOU', 1, 20000);
}
}

return 1;

Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Re: Plugin applySongs

#2 Post by Historm »

#bug: only checks when ground spells appear. Does not take into account when the actor walks over an area with the song on it.
#todo: add hook for performing this check when a actor moves.

Post Reply