Added server man quest events and command parsing.

This commit is contained in:
Tabasco 2013-05-18 11:21:19 -05:00
parent 1b9647f57e
commit 7b21e3be72
3 changed files with 139 additions and 11 deletions

View File

@ -589,6 +589,9 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d
safe_delete_array(hi_decl); safe_delete_array(hi_decl);
} }
} }
mod_quest_event(event, objid, data, npcmob, iteminst, mob, extradata, global, packagename);
//do any event-specific stuff... //do any event-specific stuff...
switch (event) { switch (event) {
case EVENT_SAY: { case EVENT_SAY: {

View File

@ -144,6 +144,7 @@ public:
virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst); virtual void SendCommands(const char * pkgprefix, const char *event, uint32 npcid, Mob* other, Mob* mob, ItemInst* iteminst);
int HasQuestFile(uint32 npcid); int HasQuestFile(uint32 npcid);
void mod_quest_event(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global, std::string packagename);
#ifdef EMBPERL_COMMANDS #ifdef EMBPERL_COMMANDS
void ExecCommand(Client *c, Seperator *sep); void ExecCommand(Client *c, Seperator *sep);

View File

@ -13,6 +13,8 @@
#include "client.h" #include "client.h"
#include "worldserver.h" #include "worldserver.h"
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include "event_codes.h"
#include "embparser.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -25,8 +27,29 @@ using namespace std;
#define DW_STATBASE 70 #define DW_STATBASE 70
void Zone::mod_init() { return; } void Zone::mod_init() {
void Zone::mod_repop() { return; } const NPCType* tmp = 0;
if((tmp = database.GetNPCType(999999)))
{
NPC* npc = new NPC(tmp, 0, 0, 0, 0, 0, FlyMode3);
if(npc)
{
entity_list.AddNPC(npc);
}
}
}
void Zone::mod_repop() {
const NPCType* tmp = 0;
if((tmp = database.GetNPCType(999999)))
{
NPC* npc = new NPC(tmp, 0, 0, 0, 0, 0, FlyMode3);
if(npc)
{
entity_list.AddNPC(npc);
}
}
}
void NPC::mod_prespawn(Spawn2 *sp) { void NPC::mod_prespawn(Spawn2 *sp) {
//The spawn has to have 1 kill to qualify //The spawn has to have 1 kill to qualify
@ -85,8 +108,23 @@ int NPC::mod_npc_damage(int damage, SkillType skillinuse, int hand, const Item_S
return(damage); return(damage);
} }
void NPC::mod_npc_killed_merit(Mob* c) { return; } //Mob c has been given credit for a kill. This is called after the regular EVENT_KILLED_MERIT event.
void NPC::mod_npc_killed(Mob* oos) { return; } void NPC::mod_npc_killed_merit(Mob* c) {
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
parse->EventNPC(EVENT_KILLED_MERIT, tmpmob->CastToNPC(), c, this->GetCleanName(), this->GetNPCTypeID());
}
}
//Mob oos has been given credit for a kill. This is called after the regular EVENT_DEATH event.
void NPC::mod_npc_killed(Mob* oos) {
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
parse->EventNPC(EVENT_DEATH, tmpmob->CastToNPC(), oos, this->GetCleanName(), this->GetNPCTypeID());
}
}
//Base damage from Client::Attack - can cover myriad skill types //Base damage from Client::Attack - can cover myriad skill types
int Client::mod_client_damage(int damage, SkillType skillinuse, int hand, const ItemInst* weapon, Mob* other) { int Client::mod_client_damage(int damage, SkillType skillinuse, int hand, const ItemInst* weapon, Mob* other) {
@ -204,8 +242,23 @@ int Client::mod_client_damage(int damage, SkillType skillinuse, int hand, const
} }
//message is char[4096], don't screw it up. //message is char[4096], don't screw it up. Return true for normal behavior, false to return immediately.
bool Client::mod_client_message(char* message, uint8 chan_num) { return(true); } //Potentially dangerous string handling here bool Client::mod_client_message(char* message, uint8 chan_num) {
//!commands for serverman
if(message[0] == '!' && chan_num == 8)
{
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
parse->EventNPC(EVENT_SAY, tmpmob->CastToNPC(), this, message, 0);
return(false);
}
Message(315, "Your pants are on sideways.");
return(false);
}
return(true);
} //Potentially dangerous string handling here
//Skillup override. When this is called the regular skillup check has failed. Return false to proceed with default behavior. //Skillup override. When this is called the regular skillup check has failed. Return false to proceed with default behavior.
//This will NOT allow a client to increase skill past a cap. //This will NOT allow a client to increase skill past a cap.
@ -287,8 +340,29 @@ int Client::mod_client_haste(int h) {
return(h); return(h);
} }
void Client::mod_consider(Mob* tmob, Consider_Struct* con) { return; } //This is called when a client cons a mob
bool Client::mod_saylink(const std::string&, bool silentsaylink) { return(true); } void Client::mod_consider(Mob* tmob, Consider_Struct* con) {
if(tmob->GetLastName()[0] == '[')
{
Message(14, "%s", tmob->GetLastName());
}
}
//Return true to continue with normal behavior
bool Client::mod_saylink(const std::string& response, bool silentsaylink) {
if(silentsaylink && strlen(response.c_str()) > 1 && response[0] == '%' && response[1] == '!')
{
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
parse->EventNPC(EVENT_SAY, tmpmob->CastToNPC(), this, response, 0);
return(false);
}
Message(315, "Your pants are on sideways.");
return(false);
}
return(true);
}
//Client pet power as calculated by default formulas and bonuses //Client pet power as calculated by default formulas and bonuses
int16 Client::mod_pet_power(int16 act_power, uint16 spell_id) { int16 Client::mod_pet_power(int16 act_power, uint16 spell_id) {
@ -319,9 +393,30 @@ int32 Client::mod_tribute_item_value(int32 pts, const ItemInst* item) {
} }
//Death reporting //Death reporting
void Client::mod_client_death_npc(Mob* killerMob) { return; } void Client::mod_client_death_npc(Mob* killerMob) {
void Client::mod_client_death_duel(Mob* killerMob) { return; } Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
void Client::mod_client_death_env() { return; } if(tmpmob)
{
parse->EventNPC(EVENT_SLAY, tmpmob->CastToNPC(), this, killerMob->GetCleanName(), killerMob->GetLevel());
}
}
void Client::mod_client_death_duel(Mob* killerMob) {
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
std::string pname = std::string("PLAYER|") + killerMob->GetCleanName();
parse->EventNPC(EVENT_SLAY, tmpmob->CastToNPC(), this, pname.c_str(), killerMob->GetLevel());
}
}
void Client::mod_client_death_env() {
Mob *tmpmob = entity_list.GetMobByNpcTypeID(999999);
if(tmpmob)
{
parse->EventNPC(EVENT_SLAY, tmpmob->CastToNPC(), this, "ENVIRONMENT", 0);
}
}
//Calculated xp before consider modifier //Calculated xp before consider modifier
int32 Client::mod_client_xp(int32 in_xp, NPC *npc) { int32 Client::mod_client_xp(int32 in_xp, NPC *npc) {
@ -791,3 +886,32 @@ int Mob::mod_spell_resist(int resist_chance, int level_mod, int resist_modifier,
return(final); return(final);
} }
//This is called right before regular event processing (the switch block)
void PerlembParser::mod_quest_event(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, bool global, std::string packagename) {
NPC *tnpc = 0;
if(event == EVENT_KILLED_MERIT || event == EVENT_CAST_ON || event == EVENT_SLAY)
{
const NPCType* tmp = 0;
if((tmp = database.GetNPCType(extradata)))
{
tnpc = new NPC(tmp, 0, 0, 0, 0, 0, FlyMode3);
}
else
{
tnpc = npcmob;
}
if(tnpc)
{
ExportVar(packagename.c_str(), "npcname", tnpc->GetCleanName());
ExportVar(packagename.c_str(), "npclastname", tnpc->GetLastName());
ExportVar(packagename.c_str(), "npclevel", tnpc->GetLevel());
ExportVar(packagename.c_str(), "bodytype", tnpc->GetBodyType());
ExportVar(packagename.c_str(), "npcid", tnpc->GetNPCTypeID());
ExportVar(packagename.c_str(), "npcrace", tnpc->GetRace());
ExportVar(packagename.c_str(), "npcclass", tnpc->GetClass());
}
}
}