Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2010, 05:42 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,447
Default COMMITTED: Allow books to be sent in perl

Title says it all, this basically allows books to be sent via perl. Format is $client->ReadBook("text", type)

Type can be 0 or 1, 0 is a scroll, 1 is a book.

Very handy for making a library out of objects in player.pl, in pure example. Use your imagination for this one.

Code:
Index: client.cpp
===================================================================
--- client.cpp	(revision 1262)
+++ client.cpp	(working copy)
@@ -1870,6 +1870,21 @@
 	}
 }
 
+void Client::QuestReadBook(const char* text, int8 type) {
+	string booktxt2 = text;	
+	int length = booktxt2.length();
+	if (booktxt2[0] != '\0') {
+		EQApplicationPacket* outapp = new EQApplicationPacket(OP_ReadBook, length + sizeof(BookText_Struct));
+		BookText_Struct *out = (BookText_Struct *) outapp->pBuffer;
+		out->window = 0xFF;
+		out->type = type;
+		out->invslot = 0;
+		memcpy(out->booktext, booktxt2.c_str(), length);
+		QueuePacket(outapp);
+		safe_delete(outapp);
+	}
+}
+
 void Client::SendClientMoneyUpdate(int8 type,int32 amount){
 	EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeMoneyUpdate,sizeof(TradeMoneyUpdate_Struct));
 	TradeMoneyUpdate_Struct* mus= (TradeMoneyUpdate_Struct*)outapp->pBuffer;
Index: client.h
===================================================================
--- client.h	(revision 1262)
+++ client.h	(working copy)
@@ -520,6 +520,7 @@
 	void	Stun(int duration);
 	void	UnStun();
 	void	ReadBook(BookRequest_Struct *book);
+	void	QuestReadBook(const char* text, int8 type);
 	void	SendClientMoneyUpdate(int8 type,int32 amount);
 	void	SendMoneyUpdate();
 	bool	TakeMoneyFromPP(uint64 copper);
Index: perl_client.cpp
===================================================================
--- perl_client.cpp	(revision 1262)
+++ perl_client.cpp	(working copy)
@@ -4231,6 +4231,32 @@
 	XSRETURN(1);
 }
 
+XS(XS_Client_ReadBook); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Client_ReadBook)
+{
+	dXSARGS;
+	if (items != 3)
+		Perl_croak(aTHX_ "Usage: Client::ReadBook(THIS, Book Text, Type)");
+	{
+		Client *		THIS;
+		char*			in_txt = (char *)SvPV_nolen(ST(1));
+		int8			type = (int8)SvUV(ST(2));
+		dXSTARG;
+
+		if (sv_derived_from(ST(0), "Client")) {
+			IV tmp = SvIV((SV*)SvRV(ST(0)));
+			THIS = INT2PTR(Client *,tmp);
+		}
+		else
+			Perl_croak(aTHX_ "THIS is not of type Client");
+		if(THIS == NULL)
+			Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");
+
+			THIS->QuestReadBook(in_txt, type);
+	}
+XSRETURN_EMPTY;
+}
+
 #ifdef __cplusplus
 extern "C"
 #endif
@@ -4407,6 +4433,7 @@
 		newXSproto(strcpy(buf, "GetPVPPoints"), XS_Client_GetPVPPoints, file, "$");
 		newXSproto(strcpy(buf, "GetRadiantCrystals"), XS_Client_GetRadiantCrystals, file, "$");
 		newXSproto(strcpy(buf, "GetEbonCrystals"), XS_Client_GetEbonCrystals, file, "$");
+		newXSproto(strcpy(buf, "ReadBook"), XS_Client_ReadBook, file, "$$$");
 	XSRETURN_YES;
 }
Reply With Quote
  #2  
Old 02-23-2010, 05:46 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,447
Default

Here's an example script/screenshot to go with this.

Code:
sub EVENT_SAY {

if($text=~/hail/i) {
$client->ReadBook("This is not a test item! THIS IS REALLY PERL", 0);
$client->ReadBook("This is a book!", 1);
}

}
Reply With Quote
  #3  
Old 02-23-2010, 06:21 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Wow, very cool, Secrets! Kinda like a variation of a popup message that you can't get a response from lol, but still really neat. I bet that would be nice for lore type stuff.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 02-23-2010, 06:34 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Just like the last feature I discussed with you Trevius, I talked this over with Secrets and she got it to work. Yes it is very awesome and I will be using it quite a bit... Official SVN I think 8 D
Reply With Quote
  #5  
Old 02-23-2010, 11:44 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

Maybe a nicer way for the 'town criers' to spread their news than selling books that take up space for 1c or whatever.
Reply With Quote
  #6  
Old 08-24-2014, 06:04 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default EVENT_PROXIMITY_SAY with ReadBook

I love this functionality; thank you for creating it. The Perl code below was working perfectly in 2013 but when I've revisited working on my server content recently, it no longer shows the books to players. The proximity text works fine, as does resetting proximity with exit. Is the problem with proximity_say? new ReadBook format? Thanks for the help.

Code:
#The_Codices_of_Ascension in Zenith of Ascension (harbingers v.1)
#A proximity say library of lore for players to read, 10 volumes
#Set to type 11 (untargetable) after placing in database

sub EVENT_SPAWN {
	quest::npcfeature("size", 150);
	$npc->NPCSpecialAttacks(ZHfDCAB, 0);
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
}

sub EVENT_ENTER {
	$client->Message(315, "'The Codices of Ascension' by Senior Researcher Xal'Fora.  State which volume you would like to read, [volume one] to [volume nine].");
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
}

sub EVENT_EXIT {
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
}

sub EVENT_PROXIMITY_SAY {
	my $playername = $client->GetName();
	my $playerlastname = $client->GetLastName();

	if($text=~/volume one/i && $ulevel >= 55) {
		$client->ReadBook("Volume I of The Codices of Ascension.  

The following are my thoughts and concerns on the actions of my peers concerning the discovery of this tower.  For many years our people have searched for ways to gain the favor of our gods, to learn of their plans for us, to become closer to them.  One day we discovered this cave in a most desolate land of bones.  This place evoked feelings we'd never experienced before.  Some saw this as prophetic, such as Councilmembers Atuli and Dayo.  It was Atuli who first decided to venture deeper into the cavern.  I have yet to decide if this was wise or blindly foolish.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6316); #Summons lore, no drop, temporary item Knowledge of Ascension I, needs to be turned in at top of zone for Knowledge of Ascension I
	}
	elsif($text=~/volume two/i && (plugin::check_hasitem($client, 6317))) {
		$client->ReadBook("Volume II of The Codices of Ascension.  

Atuli was quite an orator, convincing many to follow him deep into the cavern in the hopes of communing with our gods.  This seemed too good to be true, as most things of such nature tend to be.  However, I could not resist and convinced my dearest friend Boxilar to join me on this enlightening experience.  What I hope is for this to be an awakening for our people.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6318); #Summons lore, no drop, temporary item Knowledge of Ascension II, needs to be turned in at top of zone for Knowledge of Ascension II
	}
	elsif($text=~/volume three/i && (plugin::check_hasitem($client, 6374))) {
		$client->ReadBook("Volume III of The Codices of Ascension.  

It seemed simple enough.  A small, voluntary, insignificant sacrifice of life force from every member of a race would catapult one individual to godhood.  It appears this has happened before upon Norrath much to the dismay of the pantheon.  I intent to consult with one of our wisest of elders, Grand Minister Califax.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6381); #Summons lore, no drop, temporary item Knowledge of Ascension III, needs to be turned in at top of zone for Knowledge of Ascension III
	}
	elsif($text=~/volume four/i && (plugin::check_hasitem($client, 6387))) {
		$client->ReadBook("Volume IV of The Codices of Ascension.  

News from deep within the tower.  Along with Atuli, Dayo has convinced the stone masons to construct a ramp in hopes of discovering the extent of the fiery spire.  Although hesitant, the workers have undertaken the enormous task.  I fear we may anger the gods with this intrusion, but my comrads have tempered my worry with the belief that if we are true in spirit and genuinely wish to gain a deeper understanding of our relationship with and worship of our gods, they will not take offense to this action.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6389); #Summons lore, no drop, temporary item Knowledge of Ascension IV, needs to be turned in at top of zone for Knowledge of Ascension IV
	}
	elsif($text=~/volume five/i && (plugin::check_hasitem($client, 6390))) {
		$client->ReadBook("Volume V of The Codices of Ascension.  

A senior member of our governing council, Senator Pahria, has gone against the cautions of the council and ventured higher in the tower with the expressed intent to bring back proof of his communication with the gods.  Workers saw him enter the top of the spire of flame and was not seen again; they presumed him killed.  Weeks later it was discoverd that we, as a race of elves, had gained the ability to hold fire and flame in our hands and not be harmed.  Viewed as a gift of divine devotion, many embraced this ability.  It was far too late for us when it was discovered that the 'gift' was nothing of the sort, as we were being transformed into the bodies we have today, servants to a new god, Pahria, who has taken the name Osora Lynar.  A small group led by Evinna has begun desciphering the ancient heiroglyphs on the stone pillars near the pinnacle of the spire.  It will be interesting to learn what was carved into the stone there.  Could it be a warning?

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6391); #Summons lore, no drop, temporary item Knowledge of Ascension V, needs to be turned in at top of zone for Knowledge of Ascension V
	}
	elsif($text=~/volume six/i && (plugin::check_hasitem($client, 6392))) {
		$client->ReadBook("Volume VI of The Codices of Ascension.  

'An entire race must be sacrificed for one to fully achieve Ascension' is how Evinna's notes put it.  This seems quite a deterrent to the process.  One can understand my shock upon hearing her next words, 'Furthermore, the race in question must be the same as the individual seeking Ascension.'  This must not be allowed to happen.  We must find a way to stop this horror we have nurtured from idea to reality.  Evinna's top assistant Finteinar has quite the skill translating these runes.  I believe he has intrepreted a clue to help us avert our fate.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6393); #Summons lore, no drop, temporary item Knowledge of Ascension VI, needs to be turned in at top of zone for Knowledge of Ascension VI
	}
	elsif($text=~/volume seven/i && (plugin::check_hasitem($client, 6396))) {
		$client->ReadBook("Volume VII of The Codices of Ascension.  

The inscription is incomplete due to missing runes, but Finteinar has managed to translate a portion of the text, 'Veri---- S----ari V--ios.'  What our research needs is a gifted writer to fill in the blanks.  Seekers have been sent among our people to find anyone to help complete this phrase.  Personally, as a child I recall hearing a most enduring and somewhat haunting ghost story by Literist Gelash, meant to keep children from venturing too far into the Orc-occupied woods.  I shall attempt to find him and report back soon.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6399); #Summons lore, no drop, temporary item Knowledge of Ascension VII, needs to be turned in at top of zone for Knowledge of Ascension VII
	}
	elsif($text=~/volume eight/i && (plugin::check_hasitem($client, 6409))) {
		$client->ReadBook("Volume VIII of The Codices of Ascension.  

Gelash has such insight into the details of Ascension just from the ancient writing, despite it being incomplete, and has discovered a means to stop the process.  One must command the individual to show his true intentions and if selfless it will complete the rite.  However, if the person bears any selfish thoughts, the ascension will be interrupted and he can be harmed by the material world again.  I will continue my attempt to find the proper phrase in the ancient language with the assistance of Gelash to issue such a command to a nearly-ascended being.  I only hope the poor soul who follows my advice survives the encounter, for our sake.

-- Senior Researcher Xal'Fora", 1); #Contains information as to where to turn in item.
		quest::summonitem(6410); #Summons lore, no drop, temporary item Knowledge of Ascension VIII, needs to be turned in at top of zone for Knowledge of Ascension VIII
	}
	elsif($text=~/volume nine/i && (plugin::check_hasitem($client, 6412))) {
		$client->ReadBook("Volume IX of The Codices of Ascension.  

The being now called Osora Lynar must be trapped in this realm and killed to prevent the elimination of our entire race.  The process is nearly complete so we must act quickly.  With this scroll in hand, speak the words 'Veritona Spectari Visios' in his presence and break his concentration.  We who have been corrupted and engulfed in this scheme will come to assist you in whatever way we can.  We gladly give our life essence if it provides a means to stop this atrocity and save our race.  Our new-found means of controlling fire can be focused into artifacts others may use to inflict harm.  However, this can be done only once per individual and we do not survive the process.  Do not let our sacrifice be in vain.

-- Xal'Fora, Harbinger of Ascension", 1); #Explains information on how to initiate the final encounter.
		quest::summonitem(6413); #Summons lore, no drop, item Knowledge of Ascension IX, needs to be shown at top of zone to initiate the final encounter.
	}
	elsif($text=~/volume ten/i && (plugin::check_hasitem($client, 6317)) && (plugin::check_hasitem($client, 6374)) && (plugin::check_hasitem($client, 6387)) && (plugin::check_hasitem($client, 6390)) && (plugin::check_hasitem($client, 6392)) && (plugin::check_hasitem($client, 6396)) && (plugin::check_hasitem($client, 6409)) && (plugin::check_hasitem($client, 6412)) && (plugin::check_hasitem($client, 6420)) && (plugin::check_hasitem($client, 6421))) { #6421 Knowledge of Ascension X drop from Osora_Lynar
		$client->ReadBook("Volume X of The Codices of Ascension.  

Through my actions, and the actions of others, I have written my name into the pages of this history.  The efforts of those who wished to destroy an entire race for the selfish purpose of ascending a single individual have been thwarted.  May it forever be known that I played a small but significant role in these events and may these words serve to reiterate the ancient warning carved in stone above.

-- The Exalted $playername $playerlastname, Savior of Many", 1); #New volume written to explain what your actions have done.
		quest::summonitem(6424); #Summons reward Cloak of Ghostly Flames
	}
	else {
		$client->Message(315, "You yet lack the knowledge to understand that text or you have requested a volume that does not exist.");
	}
}
Reply With Quote
  #7  
Old 08-24-2014, 06:47 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,497
Default

It is probably the change to NPC Special Attacks. You can check for quest errors in game as well.
Reply With Quote
  #8  
Old 08-24-2014, 09:38 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default

Thanks for the reply. I apologize for posting this in the code submission forum, but if there really is a problem with the functionality following other changes to the database or code, we should address it.

I tried many permutations all with the same effect, the book does not appear when client->ReadBook is called. Here is the simplified code for testing and the in-game text. The same result happens whether the mob in question is set as targetable (type 1) or untargetable (type 11).

Code:
sub EVENT_SPAWN {
	quest::npcfeature("size", 150);
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
}

sub EVENT_ENTER {
	$client->Message(315, "'The Codices of Ascension' by Senior Researcher Xal'Fora.  State which volume you would like to read, [volume one] to [volume nine].");
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
}

sub EVENT_EXIT {
	quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
	quest::say("testing proximity reset");
}

sub EVENT_PROXIMITY_SAY {
	if($text =~/volume one/i) {
		quest::say("testing proximity say");
	}
}
You say, '#reloadqst'
Clearing quest memory cache.
You say, '#repop'
Zone depoped. Repoping now.

Approaching the mob...

'The Codices of Ascension' by Senior Researcher Xal'Fora. State which volume you would like to read, [volume one] to [volume nine].

Retreating from the mob...

The Codices of Ascension says, 'testing proximity reset'

Approaching the mob again...

'The Codices of Ascension' by Senior Researcher Xal'Fora. State which volume you would like to read, [volume one] to [volume nine].

You say, 'volume one'

crickets... so EVENT_PROXIMITY_SAY is not functioning.
Reply With Quote
  #9  
Old 08-24-2014, 09:55 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

Quote:
-EVENT_PROXIMITY_SAY needs to be enabled via quest before it will work, calling quest::enable_proximity_say() in EVENT_SPAWN will suffice.
It must be enabled now
Reply With Quote
  #10  
Old 08-24-2014, 10:17 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,497
Default

Ah, yeah. That too. I didn't even get that far down into the script!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 03:51 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3