Openkore.com

OpenKore Forums
It is currently 15 Nov 2018, 08:19

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Reicarnate plugin. Create/delete character
PostPosted: 29 May 2017, 09:52 
Offline
Human
Human

Joined: 09 Dec 2016, 09:05
Posts: 30
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:
username YourAccountID
password YourPassword

char YourCharSlot
email your.email@gmail.com


Reicarnate.pl
Code:
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;


Top
 Profile  
 
 Post subject: Re: Reicarnate plugin. Create/delete character
PostPosted: 14 Jun 2017, 22:24 
Offline
Moderators
Moderators
User avatar

Joined: 16 Dec 2011, 02:53
Posts: 1212
Location: Brazil
Amazing plugin ! ;D

_________________
"'There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.'" :P

viewtopic.php?f=10&t=16117

Thanks for this Eternal! =D <3<3


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group