image |
08-23-2012 09:44 PM |
I got the latest SVN downloaded and made this diff. I don't have any time to actually compile, setup the db and test the latest SVN right now, at your own risk for now.
Don't forget despite the diff you still need to update your plugin/check_handin.pl
Perl check_handin.pl change
Code:
sub check_handin {
my $hashref = shift;
my %required = @_;
quest::resethandin();
foreach my $req (keys %required) {
$charges = $required{$req};
if ( !quest::handleturnin($req,$charges) )
{
return(0);
}
}
quest::completehandin();
return 1;
}
Diff
Code:
Index: client.h
===================================================================
--- client.h (revision 2194)
+++ client.h (working copy)
@@ -1096,7 +1096,9 @@
char* GetRacePlural(Client* client);
char* GetClassPlural(Client* client);
-
+
+ // image: multiquest additions for eqemu diff aug 23 2012
+ bool StoreTurnInItems(Mob* with);
protected:
friend class Mob;
void CalcItemBonuses(StatBonuses* newbon);
Index: command.cpp
===================================================================
--- command.cpp (revision 2194)
+++ command.cpp (working copy)
@@ -456,7 +456,9 @@
command_add("sensetrap", "Analog for ldon sense trap for the newer clients since we still don't have it working.", 0, command_sensetrap) ||
command_add("picklock", "Analog for ldon pick lock for the newer clients since we still don't have it working.", 0, command_picklock) ||
command_add("mysql", "Mysql CLI, see 'help' for options.", 250, command_mysql) ||
- command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", 250, command_xtargets)
+ command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", 250, command_xtargets) ||
+ // image: multiquest additions for eqemu diff aug 23 2012
+ command_add("printquestitems","Returns available quest items for multiquesting currently on the target npc.",200,command_printquestitems)
)
{
command_deinit();
@@ -11529,3 +11531,16 @@
else
t->ShowXTargets(c);
}
+
+void command_printquestitems(Client *c, const Seperator *sep)
+{
+ if (c->GetTarget() != 0)
+ {
+ if ( c->GetTarget()->IsNPC() )
+ c->GetTarget()->CastToNPC()->PrintOutQuestItems(c);
+ else
+ c->Message(13,"Pick a NPC target.");
+ }
+ else
+ c->Message(13,"Pick a NPC target.");
+}
\ No newline at end of file
Index: command.h
===================================================================
--- command.h (revision 2194)
+++ command.h (working copy)
@@ -321,6 +321,10 @@
void command_mysql(Client *c, const Seperator *sep);
void command_xtargets(Client *c, const Seperator *sep);
+
+// image: multiquest additions for eqemu diff aug 23 2012
+void command_printquestitems(Client *c, const Seperator *sep);
+
#ifdef EMBPERL
void command_embperl_plugin(Client *c, const Seperator *sep);
void command_embperl_eval(Client *c, const Seperator *sep);
Index: npc.cpp
===================================================================
--- npc.cpp (revision 2194)
+++ npc.cpp (working copy)
@@ -351,6 +351,9 @@
NPC::~NPC()
{
+ // image: multiquest additions for eqemu diff aug 23 2012
+ ClearQuestLists();
+
entity_list.RemoveNPC(GetID());
AI_Stop();
@@ -2270,4 +2273,112 @@
return true;
return false;
+}
+
+
+// image: multiquest additions for eqemu diff aug 23 2012
+void NPC::ClearQuestItems(bool delete_=false)
+{
+ LinkedListIterator<ItemInst*> iterator(questItems);
+ iterator.Reset();
+ while(iterator.MoreElements())
+ {
+ ItemInst* inst = iterator.GetData();
+ iterator.RemoveCurrent(delete_);
+ }
+
+ questItems.Clear();
+}
+
+void NPC::ClearQuestDeleteItems(bool delete_=false)
+{
+ LinkedListIterator<ItemInst*> iterator(questDeletionItems);
+ iterator.Reset();
+ while(iterator.MoreElements())
+ {
+ ItemInst* inst = iterator.GetData();
+ iterator.RemoveCurrent(delete_);
+ }
+
+ questDeletionItems.Clear();
+}
+
+ItemInst* NPC::FindQuestItemByID(int32 itmID, int charges, bool flagItemForDeletion=false)
+{
+ LinkedListIterator<ItemInst*> iterator(questItems);
+ iterator.Reset();
+ int totalCharges = 0;
+ while(iterator.MoreElements())
+ {
+ if ( iterator.GetData()->GetItem()->ID == itmID )
+ {
+ totalCharges += 1;
+
+ if ( flagItemForDeletion )
+ questDeletionItems.Insert(iterator.GetData()->Clone());
+ if ( charges > totalCharges )
+ {
+ iterator.Advance();
+ continue;
+ }
+
+ return iterator.GetData();
+ }
+ iterator.Advance();
+ }
+ return NULL;
+}
+
+bool NPC::DoesQuestItemExist(int32 itmID, int charges, bool flagItemForDeletion=false) {
+ ItemInst* inst = FindQuestItemByID(itmID,charges,flagItemForDeletion);
+ if ( inst != NULL )
+ {
+ return true;
+ }
+ else
+ return false;
+}
+
+void NPC::ClearQuestItem(ItemInst* inst, bool delete_=true)
+{
+ LinkedListIterator<ItemInst*> iterator(questItems);
+ iterator.Reset();
+
+ while(iterator.MoreElements())
+ {
+ if ( iterator.GetData ()->GetItem()->ID == inst->GetItem()->ID )
+ {
+ iterator.RemoveCurrent(delete_);
+ break;
+ }
+ iterator.Advance();
+ }
+}
+
+void NPC::RemoveQuestDeleteItems()
+{
+ LinkedListIterator<ItemInst*> iterator(questDeletionItems);
+ iterator.Reset();
+ while(iterator.MoreElements())
+ {
+ ClearQuestItem(iterator.GetData(),true);
+ iterator.RemoveCurrent(true);
+ }
+
+ questDeletionItems.Clear();
+}
+
+void NPC::PrintOutQuestItems(Client* c){
+ c->Message(4,"Quest Items currently awaiting completion on %s",GetName());
+
+ LinkedListIterator<ItemInst*> iterator(questItems);
+ iterator.Reset();
+
+ while(iterator.MoreElements())
+ {
+ c->Message(5,"ItemName: %s (%d) | Charges: %i",iterator.GetData()->GetItem()->Name,iterator.GetData()->GetItem()->ID,iterator.GetData()->GetCharges());
+ iterator.Advance();
+ }
+
+ c->Message(4,"End of quest items list.");
}
\ No newline at end of file
Index: npc.h
===================================================================
--- npc.h (revision 2194)
+++ npc.h (working copy)
@@ -329,7 +329,29 @@
NPC_Emote_Struct* GetNPCEmote(int16 emoteid, int8 event_);
void DoNPCEmote(int8 event_, int16 emoteid);
bool CanTalk();
+
+ // image: multiquest additions for eqemu diff aug 23 2012
+ void AddQuestItem(ItemInst* inst) { questItems.Insert(inst); }
+ void ClearQuestLists()
+ {
+ ClearQuestItems(true);
+ ClearQuestDeleteItems(true);
+ }
+
+ void ResetQuestDeleteList()
+ {
+ ClearQuestDeleteItems(true);
+ }
+
+ void ClearQuestItems(bool delete_=false);
+ void ClearQuestDeleteItems(bool delete_=false);
+ ItemInst* FindQuestItemByID(int32 itmID, int charges, bool flagItemForDeletion=false);
+ bool DoesQuestItemExist(int32 itmID, int charges, bool flagItemForDeletion=false);
+ void ClearQuestItem(ItemInst* inst, bool delete_=true);
+ void RemoveQuestDeleteItems();
+ void PrintOutQuestItems(Client* c);
+
protected:
const NPCType* NPCTypedata;
@@ -418,7 +440,10 @@
bool ldon_trap_detected;
QGlobalCache *qGlobals;
uint32 adventure_template_id;
-
+
+ // image: multiquest additions for eqemu diff aug 23 2012
+ LinkedList<ItemInst*> questItems;
+ LinkedList<ItemInst*> questDeletionItems;
private:
int32 loottable_id;
bool p_depop;
Index: perlparser.cpp
===================================================================
--- perlparser.cpp (revision 2194)
+++ perlparser.cpp (working copy)
@@ -3335,6 +3335,48 @@
XSRETURN_UV(seconds);
}
+
+// image: multiquest additions for eqemu diff aug 23 2012
+XS(XS__handleturnin); // prototype to pass -Wmissing-prototypes
+XS(XS__handleturnin) {
+ dXSARGS;
+
+ if (items != 2)
+ Perl_croak(aTHX_ "Usage: handleturnin(itemid, itemcharges)");
+ int itemid = (int)SvIV(ST(0));
+ int charges = (int)SvIV(ST(1));
+
+ bool returnVal = quest_manager.TurnInItem(itemid,charges);
+
+ ST(0) = boolSV(returnVal);
+ sv_2mortal(ST(0));
+ XSRETURN(1);
+}
+
+XS(XS__completehandin); // prototype to pass -Wmissing-prototypes
+XS(XS__completehandin) {
+ dXSARGS;
+
+ if (items != 0)
+ Perl_croak(aTHX_ "Usage: completeturnin()");
+
+ quest_manager.CompleteHandIn();
+
+ XSRETURN_EMPTY;
+}
+
+XS(XS__resethandin); // prototype to pass -Wmissing-prototypes
+XS(XS__resethandin) {
+ dXSARGS;
+
+ if (items != 0)
+ Perl_croak(aTHX_ "Usage: resetturnin()");
+
+ quest_manager.ResetHandIn();
+
+ XSRETURN_EMPTY;
+}
+
/*
This is the callback perl will look for to setup the
quest package's XSUBs
@@ -3548,6 +3590,9 @@
newXS(strcpy(buf, "GetZoneID"), XS__GetZoneID, file);
newXS(strcpy(buf, "GetZoneLongName"), XS__GetZoneLongName, file);
newXS(strcpy(buf, "GetTimeSeconds"), XS__GetTimeSeconds, file);
+ newXS(strcpy(buf, "handleturnin"), XS__handleturnin, file);
+ newXS(strcpy(buf, "completehandin"), XS__completehandin, file);
+ newXS(strcpy(buf, "resethandin"), XS__resethandin, file);
XSRETURN_YES;
}
Index: questmgr.cpp
===================================================================
--- questmgr.cpp (revision 2194)
+++ questmgr.cpp (working copy)
@@ -2642,3 +2642,30 @@
return ln.c_str();
}
+// image: multiquest additions for eqemu diff aug 23 2012
+bool QuestManager::TurnInItem(int32 itm, int charges)
+{
+ if ( owner && owner->IsNPC() )
+ {
+ if ( owner->CastToNPC()->DoesQuestItemExist(itm, charges, true) )
+ return true;
+ }
+
+ return false;
+}
+
+void QuestManager::CompleteHandIn()
+{
+ if ( owner && owner->IsNPC() )
+ {
+ owner->CastToNPC()->RemoveQuestDeleteItems();
+ }
+}
+
+void QuestManager::ResetHandIn()
+{
+ if ( owner && owner->IsNPC() )
+ {
+ owner->CastToNPC()->ResetQuestDeleteList();
+ }
+}
\ No newline at end of file
Index: questmgr.h
===================================================================
--- questmgr.h (revision 2194)
+++ questmgr.h (working copy)
@@ -246,7 +246,11 @@
bool botquest();
bool createBot(const char *name, const char *lastname, uint8 level, uint16 race, uint8 botclass, uint8 gender);
#endif
-
+
+ // image: multiquest additions for eqemu diff aug 23 2012
+ bool TurnInItem(int32 itm, int charges);
+ void CompleteHandIn();
+ void ResetHandIn();
protected:
Mob *owner; //NPC is never NULL when functions are called.
Client *initiator; //this can be null.
Index: trading.cpp
===================================================================
--- trading.cpp (revision 2194)
+++ trading.cpp (working copy)
@@ -376,6 +376,8 @@
if(parse->HasQuestSub(tradingWith->GetNPCTypeID(), "EVENT_ITEM")) {
// This is a quest NPC
quest_npc = true;
+ // image: multiquest additions for eqemu diff aug 23 2012
+ StoreTurnInItems(tradingWith);
}
int32 items[4]={0};
@@ -2536,3 +2538,21 @@
safe_delete(outapp);
}
+// image: multiquest additions for eqemu diff aug 23 2012
+bool Client::StoreTurnInItems(Mob* tradingWith) {
+
+ if ( !tradingWith || !tradingWith->IsNPC() )
+ return false;
+
+ for (sint16 i=3000; i<=3003; i++) {
+ const ItemInst* inst = m_inv[i];
+ if (inst) {
+ database.logevents(AccountName(),AccountID(),admin,GetName(),tradingWith->GetName(),"Quest Turn In Attempt",inst->GetItem()->Name,22,GetX(),
+ GetY(),GetZ(), (char*)database.GetZoneName(GetZoneID(), GetPP().zoneInstance, true),tradingWith->GetX(),tradingWith->GetY(),tradingWith->GetZ());
+
+ tradingWith->CastToNPC()->AddQuestItem(inst->Clone());
+ }
+ }
+
+ return true;
+}
\ No newline at end of file
|