list Hooks [POST FROM OLD FORUMS]

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

Message
Author
ponty
Moderators
Moderators
Posts: 130
Joined: 07 May 2008, 20:22
Noob?: No
Location: Canada

list Hooks [POST FROM OLD FORUMS]

#1 Post by ponty »

Migrating this post here since the link on the developer's wiki doc was mislinking to the old forums.

ORIGINAL POST FOUND HERE

Original Poster: Damokles
Posted: Sun May 29, 2005 1:31 pm
Post Subject: list Hooks
I wrote this little perl prog to find all hooks in functions.pl. Maybe someone wants to use it. Feel free to improve and configure it like you want.

Perl:

Code: Select all

use strict;
my $hook;
my $temp = '';
my $line = 0;
my $count;
my $string;

open IN ,'functions.pl';
open OUT,'>hooks.txt';
while (<IN>){
        $line++;
        $temp .= $_;
        if ($temp =~ /(Plugins::callHook\(.*?\);)/isg) {
                $string = $1;
                $count = () = $string =~ /\n/g;
                print OUT 'Line:'.($line-$count)." $string\n\n";
                $temp = '';
        }
}
close IN;
close OUT;
Updated Proposed Hook Names
sli wrote:

Code: Select all

Old Hook Names					New Hook Names
-----------------------------------------------------------------------
AI/lockMap				->	AI::lockMap
AI_post					->	AI::post
AI_pre					->	AI::pre
AI_pre/manual				->	AI::pre::manual
AI_sell_done				->	AI::NPC::sell_done
AI_storage_done				->	AI::NPC::storage_done
attack_start				->	AI::attack_start
avoidGM_near				->	avoidGM::near
avoidGM_talk				->	avoidGM::talk
changed_status				->	Actor::changed_status
charNameUpdate				->	Server::charNameUpdate
charSelectScreen			->	Server::charSelectScreen
ChatQueue::add				->	Chat::Queue::add
ChatQueue::processChatResponse		->	Chat::Queue::processChatResponse
checkMonsterCondition			->	Actor::monster::checkCondition
checkPlayerCondition			->	Actor::player::checkCondition
checkSelfCondition			->	Actor::self::checkCondition
Command_post				->	Command::post
Commands::cmdConf			->	Command::conf
Commands::run/post			->	Command::run::post
Commands::run/pre			->	Command::run::pre
configModify				->	Bot::configModify
disconnected				->	Server::disconnected
FileParsers::RODescLUT			->	FileParsers::RO::DescLUT
FileParsers::ROLUT			->	FileParsers::RO::LUT
hook1					->	Bot::hook1
hook2					->	Bot::hook2
initialized				->	Bot::initialized
is_casting				->	Actor::is_casting
item_skill				->	Actor::item_skill
mainLoop_pre				->	Bot::mainLoop::pre
mainLoop_post				->	Bot::mainLoop::post
mainLoop::setTitle			->	Bot::mainLoop::setTitle
map_loaded				->	Server::map_loaded
Network::Receive/mangle			->	Network::Receive::Mangle
Network::Receive/willMangle		->	Network::Recieve::willMangle
Network::Receive::map_changed		->	Network::Recive::map_chaned
Network::clientAlive			->	Network::Client::alive
Network::clientRecv			->	Network::Client::Recv
Network::clientSend			->	Network::Client::Send
Network::connectTo			->	Network::connectTo
Network::serverConnect/char		->	Network::Server::Connect::char
Network::serverConnect/charselect	->	Network::Server::Connect::charselect
Network::serverConnect/mapserver	->	Network::Server::Connect::mapserver
Network::serverConnect/master		->	Network::Server::Connect::master
Network::serverConnect/special		->	Network::Server::Connect::special
Network::serverRecv			->	Network::Server::Recv
Network::serverSend			->	Network::Server::send
Network::serverSend/pre			->	Network::Server::send::pre
Network::stateChanged			->	Network::StateChanged
npc_talk_done				->	AI::NPC::talk_done
objectAdded				->	Actor::objectAdded
objectRemoves				->	Actor::objectRemoved
packet/sendMapLoaded			->	Packet::sendMapLoaded
packet_areaSpell			->	Packet::areaSpell
packet_attack				->	Packet::attack
packet_cart				->	Packet::cart
packet_castCancelled			->	Packet::castCancelled
packet_charSkills			->	Packet::Char::Skills
packet_charStats			->	Packet::Char::Stats
packet_guildMsg				->	Packet::Chat::Guild
packet_homunSkills			->	Packet::Homun::Skills
packet_inventory			->	Packet::Inventory
packet_item_removed			->	Packet::item_removed
packet_mapChange			->	Packet::map_changes
packet_partyMsg				->	Packet::Chat::Party
packet_pre/sendAttack			->	Packet::Pre::Attack
packet_pre/sendSit			->	Packet::Pre::Sit
packet_pre/sendSkillUse			->	Packet::Pre::SkillUse
packet_pre/sendStand			->	Packet::Pre::Stand
packet_privMsg				->	Packet::Chat::Private
packet_pubMsg				->	Packet::Chat::Public
packet_selfChat				->	Packet::Chat::Self
packet_sentPM				->	Packet::Chat::SentPM
packet_skillfail			->	Packet::Skill::Fail
packet_skilluse				->	Packet::Skill::Use
packet_storage_close			->	Packet::Storage::Close
packet_storage_open			->	Packet::Storage::Open
packet_sysMsg				->	Packet::sysMsh
packet_useitem				->	Packet::useItem
packet_vender				->	Packet::Vendor
packet_vender_store			->	Packet::Vendor::Store
packet_vender_store2			->	Packet::Vendor::Store2
parseMsg/addPrivMsgUser			->	Parse::addPrivMsgUser
parseMsg/pre				->	Parse::pre
parseMsg/recvChars			->	Parse::recvChars
perfect_hidden_player			->	Actor::Player::Hidden
player					->	Actor::Player
player_connected			->	Actor::Player::Connected
player_exist				->	Actor::Player::Exist
Poseidon/client_authenticate		->	Poseidon::Authenticate::Client
Poseidon/server_authenticate		->	Poseidon::Authenticate::Server
pvp_mode				->	Server::PvpMode
RO_sendMsg_pre				->	Server::sendMsg::pre
start					->	Bot::Start
start2					->	Bot::Start2
start3					->	Bot::Start3
teleport_sent				->	Packet::TeleportSend
sli wrote:There's a couple bugs in this (for some reason it skips a couple hooks, about 5-10), but the basic idea is there.

Code: Select all

import os,re

ignore = []
changeNames = 0

def visit(arg,dirname,names):
    global hList,ignore,changeNames

    for f in names:
        if os.path.isdir(f): continue	#skip directories
        if f in ignore: continue	#skip ignored files

        try:
            if not f.split('.')[-1] in ['pl','pm']: continue #skip stuff that's not perl
        except: continue

        f = dirname.replace('\\','/') + '/' + f

        print f + '...',

        src = open(f).read()

        if changeNames: new = open('new_' + f,'w')
        else: new = open(f,'w')

        for h in hList:
            src = re.sub(h[0],h[1],src)

        new.write(src)
        new.close()

        print 'Done.'

hList = []

rawhList = open('newhooks.txt').read().rstrip().split('\n')
for l in rawhList:
    l = l.split('\t')
    hList.append(['^%s$' % l[0],l[-1]])

x = os.path.walk('./src/',visit,None)
x = os.path.walk('./plugins/',visit,None)

print 'All done!'
Last edited by ponty on 15 Oct 2008, 16:49, edited 1 time in total.
Follow The template in Asking Questions or Be Trashed

Openkore Documentation Editor/Writer
~Servus Servorum~

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: list Hooks [POST FROM OLD FORUMS]

#2 Post by sli »

cs : ee : realist

Cozzie
Spam Generator
Spam Generator
Posts: 499
Joined: 04 Apr 2008, 09:30
Noob?: No
Location: Melbourne, City of beer and awful sushis

Re: list Hooks [POST FROM OLD FORUMS]

#3 Post by Cozzie »

Isnt this thread is obsolete with the existence of the new one sli linked?
Make Openkore Awesome. Join the team.

ponty
Moderators
Moderators
Posts: 130
Joined: 07 May 2008, 20:22
Noob?: No
Location: Canada

Re: list Hooks [POST FROM OLD FORUMS]

#4 Post by ponty »

I didn't see sli's code until he referenced it, but ya I edited in Sli's work as well now.
Follow The template in Asking Questions or Be Trashed

Openkore Documentation Editor/Writer
~Servus Servorum~

VashTheStampede
Plain Yogurt
Plain Yogurt
Posts: 68
Joined: 11 Jun 2011, 01:47
Noob?: No

Re: list Hooks [POST FROM OLD FORUMS]

#5 Post by VashTheStampede »

Bump, because handy.

Post Reply