Reicarnate plugin. Create/delete character

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
Glikadin
Human
Human
Posts: 29
Joined: 09 Dec 2016, 09:05
Noob?: Yes

Reicarnate plugin. Create/delete character

#1 Post by Glikadin »

Hi. I ubdate old plugin Reicarnate (Copyright 2006 by kaliwanagan).
Use the command "remake" in order to remove the character and generate a new one.
Can be used in a macro plugin.
If the slot is empty, a new character will be generated. ("char" in config.txt)

You need to specify a parameter "email" in config.txt :

Code: Select all

username YourAccountID
password YourPassword

char YourCharSlot
email your.email@gmail.com
Reicarnate.pl

Code: Select all

package reincarnate;

#
# This plugin is licensed under the GNU GPL
# Copyright 2006 by kaliwanagan
# Ubdated by Glikadin in 2017
# --------------------------------------------------
#

my @syllables = qw(  a  i  u  e  o
               ka ki ku ke ko
               ga gi gu ge go 
               sa si su se so
               za zi zu ze zo
               ta ti tu te to
               da di du de do
               na ni nu ne no n
               ha hi hu he ho
               ba bi bu be bo
               ma mi mu me mo
               ya mi yu ye yo
               ra ri ru re ro
               wa wi wu we wo
			   la li lu le lo
			   qa qi qu qe qo
			   pa pi pu pe po
			   jo ji ju je jo
			   vo vi vu ve vo
			   xo xi xu xe xo
			   );

use strict;
use Plugins;
use Globals;
use Log qw(message warning error debug);
use AI;
use Misc;
use Network;
use Network::Send;
use Utils;

Plugins::register('reincarnate', 'automatically delete then (re)create your char', \&onUnload);
my $plugin = Plugins::addHooks(['charSelectScreen', \&charSelectScreen]);
my $command1 = Commands::register(['remake', 'delete then (re)create your char', \&reincarnate_command]);
my $command2 = Commands::register(['quitToCharSelect', 'quits to char select screen', \&quitToCharSelect_command]);

my $charPos = 2;
my $currentCharPos = $charPos;
my $newCharName;
my $job;
my ($hair_style, $hair_color, $job, $sex) = (2, 7, 'novice' , 'M');

# State holder
my $status = "ready";

sub onUnload {
   Commands::unregister($command1);
   Commands::unregister($command2);
   Plugins::delHooks($plugin);
}

sub charSelectScreen {
   my $email = $config{email};
   my ($self, $args) = @_;
   
   if (!$chars[$charPos]) {
      $config{char} = $charPos;
      $newCharName = generateName(int(rand(5)) + 2, int(rand(5)) + 2);
      print "$currentCharPos\n";
      print "$newCharName\n";
      $messageSender->sendCharCreate($charPos, $newCharName, $hair_style, $hair_color, $job, $sex);
      $timeout{'charlogin'}{'time'} = time;
      $args->{return} = 2;
      $status = "character created";
      return;
   }
   
if ($status eq "start") {
      message "$status\n";
      message "Deleting $currentCharPos: $chars[$currentCharPos]{name}, $email\n";
      $messageSender->sendBanCheck($charID);
	  $messageSender->sendCharDelete2($chars[$currentCharPos]{charID});
	  sleep(20);
	  $messageSender->sendCharDelete2Accept($chars[$currentCharPos]{charID}, $email);
	  $timeout{'charlogin'}{'time'} = time;
      $args->{return} = 2;
      $status = "character deleted";
      
   } elsif ($status eq "character deleted") {
      message "$status\n";
      message "Creating $currentCharPos: $newCharName, $email\n";
      $messageSender->sendCharCreate($charPos, $newCharName, $hair_style, $hair_color, $job, $sex);
      $timeout{'charlogin'}{'time'} = time;
      $args->{return} = 2;
      $status = "character created";
	  relog();
     
   } elsif ($status eq "character created") {
      message "$status\n";
      $messageSender->sendCharLogin($currentCharPos);
      $timeout{'charlogin'}{'time'} = time;
      $args->{return} = 2;
      configModify("char", $currentCharPos);
      $status = "ready";	
   }
}

sub reincarnate_command {
   # Save the slot position of the current character
   $currentCharPos = $config{char};

   # Alternatively, you can replace $newCharName with
   # some sort of "name generator"
   # $newCharName = $chars[$config{char}]{name};
   #$newCharName = Utils::vocalString(15);
   $newCharName = generateName(int(rand(5)) + 2, int(rand(5)) + 2);
   $hair_color = int(rand(5));
   $hair_style = int(rand(6));
   print "$hair_color, $hair_style\n";
   print "New name: $newCharName\n";

   message "Reincarnating $chars[$config{char}]{name}\n", "system";
   $status = "start";
   $messageSender->sendQuitToCharSelect();
}

sub quitToCharSelect_command {
   $messageSender->sendQuitToCharSelect();
}

# string generateName (lengthS [, lengthF])
# Generate a name with lengthS syllables as a surname.
# The second argment is optional - it will be used when
# you want a forename to be generated as well.
#
# Returns:
# A string containing the surname and the optional
# forename, separated by spaces, and the first character
# of both names capitalized.
#
# TODO:
# Implement phonological rukes as described by the wikipedia entry
# Implement vowel ellisions as described by the wikipedia entry

sub generateName {
   my $lengthS = shift;
   return "" if (!$lengthS);
   my $lengthF = shift;
   my $surname = "";
   my $forename = "";
   
   # Generate the surname
   if ($lengthS) {
      my $i;
      for ($i = 0; $i < $lengthS; $i++) {
         my $syllable = "";
         while (!$syllable) {
            my $candidate = $syllables[int(rand(@syllables))];
            # Do some testing with $candidate here
            $syllable = $candidate;
         }
         $surname .= $syllable;
      }
      $surname = ucfirst($surname);
   }
   
   # Generate the forename
   if ($lengthF) {
      my $i;
      for ($i = 0; $i < $lengthF; $i++) {
         my $syllable = "";
         while (!$syllable) {
            my $candidate = $syllables[int(rand(@syllables))];
            # Do some testing with $candidate here
            $syllable = $candidate;
         }
         $forename .= $syllable;
      }
      $forename = ucfirst($forename);
   }
   
   my $name = $surname;
   $name .= " " . $forename if ($forename);
   return $name;
}

return 1;

User avatar
SkylorD
Moderators
Moderators
Posts: 1167
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: Reicarnate plugin. Create/delete character

#2 Post by SkylorD »

Amazing plugin ! ;D
Learn rules

Post Reply