Page 1 of 1

Autopsy plugin

Posted: 05 Apr 2008, 05:33
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...

Re: Autopsy plugin

Posted: 08 Apr 2008, 10:13
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.

Re: Autopsy plugin

Posted: 17 Apr 2008, 16:23
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!

Re: Autopsy plugin

Posted: 18 Apr 2008, 06:46
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...

Re: Autopsy plugin

Posted: 27 Apr 2008, 04:08
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

Re: Autopsy plugin

Posted: 05 May 2008, 14:04
by adlp1ph
fco2783 wrote:
this is for openkore v2.0.0 lower...
is see

Re: Autopsy plugin

Posted: 18 Nov 2008, 07:51
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 <--

Re: Autopsy plugin

Posted: 24 Jun 2012, 22:13
by danzhere
is there any plugins work on SVN ? TQ