Autopsy plugin

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
fco2783
Plain Yogurt
Plain Yogurt
Posts: 95
Joined: 05 Apr 2008, 05:15
Noob?: Yes
Location: in place where you cant go
Contact:

Autopsy plugin

#1 Post by fco2783 »

Code: Select all

##########################################################################
# This software is open source, licensed under the GNU General Public
# License, version 2.
# Basically, this means that you're allowed to modify and distribute
# this software. However, if you distribute modified versions, you MUST
# also distribute the source code.
# See http://www.gnu.org/licenses/gpl.html for the full license.
##########################################################################

#Autopsy.pl
#Plugin by: PlayingSafe, Openkore
#Revision 2
#Under Openkore 2.0.0 (SVN)
#How to use
#At your config file put 
#logDeath 1 <-- put 1 to enable logging 
#logDeathSize # <--- put your desired number of lines to save 
#deathMessage <-- put the "You have died" word on your local language if kore is set to local language
#example:
#logDeathSize 25 (this will save 25 lines of console messages)
#deathMessage You have died (Default language English)

package Autopsy;

use Utils;
use strict;
use Plugins;
use Globals;
use Settings;
use Log qw(message debug);

Plugins::register('Autopsy', 'Record console messages after bot died', \&unload);
my $cHook = Log::addHook(\&cHook, "DeathLog");

sub unload {
        Log::delHook('cHook', $cHook);
}

my @messages = ();

sub cHook {
        my $type = shift;
        my $domain = shift;
        my $level = shift;
        my $currentVerbosity = shift;
        my $message = shift;
        my $user_data = shift;
        my $logfile = shift;
        my $deathmsg = shift;
        my $location = shift;

if ($level <= $currentVerbosity && $config{'logDeath'} == 1) {

        my (undef, $microseconds) = Time::HiRes::gettimeofday;
        $microseconds = substr($microseconds, 0, 2);
        my $message2 = "[".getFormattedDate(int(time)).".$microseconds] ".$message;

        push(@messages, $message2);
        my $size = scalar @messages;
        if ($size == $config{'logDeathSize'} + 1) {
                        shift(@messages);
        }
        if ($config{logAppendUsername}) {
                $logfile = "$Settings::logs_folder/deathlog_$config{username}_$config{char}.txt";
        } else {
                $logfile = "$Settings::logs_folder/deathlog.txt";
        }
        $deathmsg = $config{'deathMessage'};
        if ($message =~ /$deathmsg/) {
                my $pos = calcPosition($char);
                $location = "\nYou died at $maps_lut{$field{name}.'.rsw'} ($field{name}) : $pos->{x}, $pos->{y}\n";
                                use encoding 'utf8';
                                open(DFILE, ">>:utf8", "$logfile"); {
                                print DFILE "\n*** Start of console death log ***\n\n";
                                print DFILE @messages;
                                print DFILE $location;
                                print DFILE "\n*** End of console death log ***\n\n";
                                close(DFILE);
                        }
                }
        }
}
return 1;
Usage
How to use
#At your config file put
#logDeath 1 <-- put 1 to enable logging
#logDeathSize # <--- put your desired number of lines to save
#deathMessage <-- put the "You have died" word on your local language if kore is set to local language
#example:
#logDeathSize 25 (this will save 25 lines of console messages)
#deathMessage You have died (Default language English)

logDeath 1
logDeathSize 50
deathMessage You have died
at the logs folder your could see how your bot die...

isieo
Kami-Sama Desu~
Kami-Sama Desu~
Posts: 195
Joined: 04 Apr 2008, 09:24
Noob?: Yes
Location: 31th Dimension
Contact:

Re: Autopsy plugin

#2 Post by isieo »

you know, this should be integrated into kore as it is one of the important information,
if you can, integrated it and post a diff in the development's corner.

adlp1ph
Noob
Noob
Posts: 6
Joined: 06 Apr 2008, 15:26

Re: Autopsy plugin

#3 Post by adlp1ph »

why it does not log my death?

i put the Autopsy.pl file on the Plugins folder right?

then i put the

logDeath something on the config.txt file right?

help thanks!

fco2783
Plain Yogurt
Plain Yogurt
Posts: 95
Joined: 05 Apr 2008, 05:15
Noob?: Yes
Location: in place where you cant go
Contact:

Re: Autopsy plugin

#4 Post by fco2783 »

adlp1ph wrote:why it does not log my death?

i put the Autopsy.pl file on the Plugins folder right?

then i put the

logDeath something on the config.txt file right?

help thanks!
this is for openkore v2.0.0 lower...

RBiN
Noob
Noob
Posts: 12
Joined: 07 Apr 2008, 03:31

Re: Autopsy plugin

#5 Post by RBiN »

Code: Select all

##########################################################################
# This software is open source, licensed under the GNU General Public
# License, version 2.
# Basically, this means that you're allowed to modify and distribute
# this software. However, if you distribute modified versions, you MUST
# also distribute the source code.
# See http://www.gnu.org/licenses/gpl.html for the full license.
##########################################################################

#Autopsy.pl
#Plugin by: PlayingSafe, Openkore
#Revision 3 by Rbin
#Openkore 2.0.0 (SVN) upper
#How to use
#At your config file put
#logDeath 1 <-- put 1 to enable logging
#logDeathSize # <--- put your desired number of lines to save
#deathMessage <-- put the "You have died" word on your local language if kore is set to local language
#example:
#logDeathSize 25 (this will save 25 lines of console messages)
#deathMessage You have died (Default language English)

package Autopsy;

use Utils;
use strict;
use Plugins;
use Globals;
use Settings;
use Log qw(message debug);

Plugins::register('Autopsy', 'Record console messages after bot died', \&unload);
my $cHook = Log::addHook(\&cHook, "DeathLog");

sub unload {
        Log::delHook('cHook', $cHook);
}

my @messages = ();

sub cHook {
        my $type = shift;
        my $domain = (shift or "console");
        my $level = (shift or 0);
        my $currentVerbosity = shift;
        my $message = shift;
        my $user_data = shift;
        my $logfile = shift;
        my $deathmsg = shift;
        my $location = shift;

if ($level <= $currentVerbosity && $config{'logDeath'} == 1) {

        my (undef, $microseconds) = Time::HiRes::gettimeofday;
        $microseconds = substr($microseconds, 0, 2);
        my $message2 = "[".getFormattedDate(int(time)).".$microseconds] ".$message;

        push(@messages, $message2);
        my $size = scalar @messages;
        if ($size == $config{'logDeathSize'} + 1) {
                        shift(@messages);
        }
        if ($config{logAppendUsername}) {
                $logfile = "$Settings::logs_folder/deathlog_$config{username}_$config{char}.txt";
        } else {
                $logfile = "$Settings::logs_folder/deathlog.txt";
        }
        $deathmsg = $config{'deathMessage'};
        if ($message =~ /$deathmsg/) {
                my $pos = calcPosition($char);
                $location = "\nYou died at $maps_lut{$field{name}.'.rsw'} ($field{name}) : $pos->{x}, $pos->{y}\n";
                                use encoding 'utf8';
                                open(DFILE, ">>:utf8", "$logfile"); {
                                print DFILE "\n*** Start of console death log ***\n\n";
                                print DFILE @messages;
                                print DFILE $location;
                                print DFILE "\n*** End of console death log ***\n\n";
                                close(DFILE);
                        }
                }
        }
}
return 1;
this should work on version 2.0.0 above

adlp1ph
Noob
Noob
Posts: 6
Joined: 06 Apr 2008, 15:26

Re: Autopsy plugin

#6 Post by adlp1ph »

fco2783 wrote:
this is for openkore v2.0.0 lower...
is see

Kissa2k
Human
Human
Posts: 46
Joined: 27 Apr 2008, 12:52
Noob?: No
Location: Russia

Re: Autopsy plugin

#7 Post by Kissa2k »

isieo wrote:if you can, integrated it and post a diff in the development's corner.
It has been done long time ago. --> http://forums.openkore.com/viewtopic.php?f=36&t=790 <--

danzhere
Noob
Noob
Posts: 4
Joined: 22 Nov 2011, 02:16
Noob?: Yes

Re: Autopsy plugin

#8 Post by danzhere »

is there any plugins work on SVN ? TQ

Post Reply