deathAlert -- Notice Bot's Death!

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
Chontrad
Human
Human
Posts: 30
Joined: 23 Apr 2008, 10:11
Noob?: No
Location: Indonesia TANAH AIRKU
Contact:

deathAlert -- Notice Bot's Death!

#1 Post by Chontrad »

This is a handy plugins which will beeps as much times as you like when your bot died

Code: Select all

########################################
# deathAlert -- Notice u'r bot death!
# This is a modification of AlertSound plugins made by 
#
# ©2007 by Contrad
#
# 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.
#
# How to install :
# Just paste to PLUGINS folder inside OPENKORE root folder.
#
# How to use :
# <config.txt>
# beepOnDeath (num)			Beep when death until (num) times.
#
# Anyway I use 'Bahasa' instead of 'English' to promote INDONESIA. :D
# U'r free to translate it.

package deathAlert;

use strict;
use Plugins;
use Globals;
use Utils;
use Log qw(message);
use Network::Send;
use Utils;

Plugins::register('deathAlert', 'bip 2 kali kalo mati', \&Unload);
my $packetHook = Plugins::addHook('parseMsg/pre', \&CheckPacket);

sub Unload {
Plugins::delHook('parseMsg/pre', $packetHook);
}

sub CheckPacket {
return if (!$config{'beepOnDeath'});

my $hookName = shift;
my $args = shift;
my $switch = $args->{switch};
my $msg = $args->{msg};

if ($switch eq "0080") {
# someone disappeared here
my $ID = substr($msg, 2, 4);

if ($ID eq $accountID) {
# You are dead.
for (1..$config{'beepOnDeath'}) {$interface->beep();}
}
}
}

1;

iamanoob
Plain Yogurt
Plain Yogurt
Posts: 82
Joined: 04 Apr 2008, 09:49

Re: deathAlert -- Notice Bot's Death!

#2 Post by iamanoob »

could i use this on Wx?
or just only for console?
playsound?
Image
DARKest Ninja

Chontrad
Human
Human
Posts: 30
Joined: 23 Apr 2008, 10:11
Noob?: No
Location: Indonesia TANAH AIRKU
Contact:

Re: deathAlert -- Notice Bot's Death!

#3 Post by Chontrad »

u can use at any openkore, i think. although i haven't tested it yet.

iamanoob
Plain Yogurt
Plain Yogurt
Posts: 82
Joined: 04 Apr 2008, 09:49

Re: deathAlert -- Notice Bot's Death!

#4 Post by iamanoob »

Chontrad wrote:u can use at any openkore, i think. although i haven't tested it yet.
(but uve said "U can use it at any openkore"?)

anyways ive tested it for you
on WX and console interface

and it doesnt work at WX interface
its my old problem until now
i cant generate my own cpu generated beep
coz WX interface have this

Code: Select all

sub beep {
	Wx::Bell();
}
and its through the speakers
unless i do this on a plugin

Code: Select all

Utils::Win32::ShellExecute(1,'open','beepPm.exe') if $Settings::interface eq "Wx";
and this beepPm.exe is a dos prog generated through C++
if i only could do this on kore

Code: Select all

Utils::Win32::ShellExecute(1,'open','beepPm.exe', args, 0, SW_HIDE);
so that the dos console wont appear
coz auto\XSTools\win32\wrapper.xs only had this

Code: Select all

int
ShellExecute(handle, operation, file)
		unsigned int handle
		SV *operation
		char *file
ive done this $interface->beep(); only at Console interface
this $interface->beep() is found at Log.pm sub processMsg

Code: Select all

	$interface->beep() if existsInList($config{beepDomains}, $domain) &&
		!(existsInList($config{beepDomains_notInTown}, $domain) &&
		  $cities_lut{$field{name}.'.rsw'});
and in interface\console.pm

Code: Select all

sub beep {
	print STDOUT "\a";
	STDOUT->flush;
}
could u fix that beep to work in WX?
and it would be highly appreciated by me XD

but you could replace that $interface->beep() in your plugin with this

Code: Select all

Utils::Win32::playSound(file);
Utils::Win32::playSound(iDontWannaCloseMyEyes.wav);
Utils::Win32::playSound(BlackParade.wav);
Utils::Win32::playSound(Helena.wav); <- inspirational songs
Image
DARKest Ninja

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

Re: deathAlert -- Notice Bot's Death!

#5 Post by fco2783 »

you could add this...
sub actor_died_or_disappeared {
my ($self,$args) = @_;
return unless changeToInGameState();
my $ID = $args->{ID};
avoidList_ID($ID);

if ($ID eq $accountID) {
message T("You have died\n") if (!$char->{dead});
closeShop() unless !$shopstarted || $config{'dcOnDeath'} == -1 || !$AI;
$char->{deathCount}++;
$char->{dead} = 1;

if ($config{'beepOnDeath'}) {
$interface->beep();
$interface->beep();
}
$char->{dead_time} = time;
at the config.txt add beepOnDeath 1

Chontrad
Human
Human
Posts: 30
Joined: 23 Apr 2008, 10:11
Noob?: No
Location: Indonesia TANAH AIRKU
Contact:

Re: deathAlert -- Notice Bot's Death!

#6 Post by Chontrad »

I had already done that in my modified Receive.pm file.

For further info, see this thread http://forums.openkore.com/viewtopic.php?f=34&t=139

Post Reply