PDA

View Full Version : Quest Commands for Temp Race, Texture, Size and Gender Changes


trevius
06-03-2008, 08:56 PM
As you can see in the post, this was actually submitted by Striat in this thread:

http://www.eqemulator.net/forums/showthread.php?p=147573#post147573

I take no credit for this code, but I figured that if he posted it openly on the forums that he would have no problems if it was to be added to the source. I think these quest commands could be very useful and could be used to make some creative and fun new quests and events.

As far as I know, there is no way to do any of this with the currently available commands. If so, then, there is obviously no need for this to be added, but if not, then I think this would be a great addition to quest commands.

The names of the commands and the actual way it works are probably all ok to be adjusted however needed.


It might not be a bad idea to reduce this all down into just 1 command with a few options as stated by Striat in the quote below. It could be something like this:

quest::setillusion(<$mobid or $userid>,<illusion type option>,<Illusion ID#>);

So, and example of using that format would be:

quest::setillusion($userid,race,123);

And that line would set the player to the race of Innoruuk until they zone.

A second example using this possible format would be:

quest::setillusion($mobid,texture,3);

And that would set the quest giving NPC to texture 3 so that they would be wearing plate armor, or whatever texture that race of NPC has for 3.

Also, can use SendWearChange I believe. I did add these commands to my server. I broke them down to 8 commands to keep things easier. Could also easily do it as one command. But, here is what we have:

Add to perlparser.cpp
XS(XS__npcrace);
XS(XS__npcrace)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: npcrace(race_id)");

int race_id = (int)SvIV(ST(0));

quest_manager.npcrace(race_id);

XSRETURN_EMPTY;
}

XS(XS__npcgender);
XS(XS__npcgender)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: npcgender(gender_id)");

int gender_id= (int)SvIV(ST(0));

quest_manager.npcgender(gender_id);

XSRETURN_EMPTY;
}

XS(XS__npcsize);
XS(XS__npcsize)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: npcsize(newsize)");

int newsize = (int)SvIV(ST(0));

quest_manager.npcsize(newsize);

XSRETURN_EMPTY;
}

XS(XS__npctexture);
XS(XS__npctexture)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: npctexture(newtexture)");

int newtexture = (int)SvIV(ST(0));

quest_manager.npctexture(newtexture);

XSRETURN_EMPTY;
}

XS(XS__playerrace);
XS(XS__playerrace)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: playerrace(race_id)");

int race_id = (int)SvIV(ST(0));

quest_manager.playerrace(race_id);

XSRETURN_EMPTY;
}

XS(XS__playergender);
XS(XS__playergender)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: playergender(gender_id)");

int gender_id= (int)SvIV(ST(0));

quest_manager.playergender(gender_id);

XSRETURN_EMPTY;
}

XS(XS__playersize);
XS(XS__playersize)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: playersize(newsize)");

int newsize = (int)SvIV(ST(0));

quest_manager.playersize(newsize);

XSRETURN_EMPTY;
}

XS(XS__playertexture);
XS(XS__playertexture)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: playertexture(newtexture)");

int newtexture = (int)SvIV(ST(0));

quest_manager.playertexture(newtexture);

XSRETURN_EMPTY;
}

And also add to perlparser.cpp
newXS(strcpy(buf, "npcrace"), XS__npcrace, file);
newXS(strcpy(buf, "npcgender"), XS__npcgender, file);
newXS(strcpy(buf, "npcsize"), XS__npcsize, file);
newXS(strcpy(buf, "npctexture"), XS__npctexture, file);
newXS(strcpy(buf, "playerrace"), XS__playerrace, file);
newXS(strcpy(buf, "playergender"), XS__playergender, file);
newXS(strcpy(buf, "playersize"), XS__playersize, file);
newXS(strcpy(buf, "playertexture"), XS__playertexture, file);

Now, add to questmgr.cpp
void QuestManager::npcrace(int race_id)
{
owner->SendIllusionPacket(race_id);
}

void QuestManager::npcgender(int gender_id)
{
owner->SendIllusionPacket(owner->GetRace(), gender_id);
}
void QuestManager::npcsize(int newsize)
{
owner->ChangeSize(newsize, true);
}
void QuestManager::npctexture(int newtexture)
{
owner->SendIllusionPacket(owner->GetRace(), 0xFF, newtexture);
}

void QuestManager::playerrace(int race_id)
{
initiator->SendIllusionPacket(race_id);
}

void QuestManager::playergender(int gender_id)
{
initiator->SendIllusionPacket(initiator->GetRace(), gender_id);
}
void QuestManager::playersize(int newsize)
{
initiator->ChangeSize(newsize, true);
}
void QuestManager::playertexture(int newtexture)
{
initiator->SendIllusionPacket(initiator->GetRace(), 0xFF, newtexture);
}

And finally add to questmgr.h
void npcrace(int race_id);
void npcgender(int gender_id);
void npcsize(int newsize);
void npctexture(int newtexture);
void playerrace(int race_id);
void playergender(int gender_id);
void playersize(int newsize);
void playertexture(int newtexture);

Now, usage from our Edone.pl npc:

sub EVENT_SAY {
if($text=~/hail/i) {
quest::say("As you wish!");
}
if($text=~/race/i) {
quest::say("As you wish!");
quest::npcrace(217);
quest::playerrace(217);
}
if($text=~/gender/i) {
quest::say("As you wish!");
quest::npcgender(1);
quest::playergender(1);
}
if($text=~/size/i) {
quest::say("As you wish!");
quest::npcsize(20);
quest::playersize(20);
}
if($text=~/texture/i) {
quest::say("As you wish!");
quest::npctexture(22);
quest::playertexture(15);
}
}

If you do not know how to compile these changes, see http://www.eqemulator.net/wiki/wikka.php?wakka=DevVSExpress.
Also, if you have any questions, feel free to PM me or look for me on irc as Striat.


I will probably try to adjust this where I think it is needed and try it out on my server. I am sure I can get the commands renamed, but I am not so sure that I can figure out how to make them all do it in 1 single command like I posted above. It isn't quite necessary to have them all in 1 command, but I think it might make it cleaner and simpler to use.

And, Striat, if you have any problems with me posting this, or this going into the code, let me know. I am sure you would be credited for it 100% if so. I certainly don't deserve or want credit for it. I just thought it looked really cool and is a shame to let it go to waste!

trevius
06-08-2008, 06:56 AM
I added this into my source updates and it works great so far. I left it as-is, because after I looked it over further, it seemed great as it was. It might be nice to have them all in 1 command, but this list of commands is simple to remember and use.

I even wrote a little quest for an NPC I made at the spawn point in Nexus where everyone gates to and where all new players pop into. It sets all players that zone in to have a random illusion from the entire global race lists minus player races. It also changes textures sometimes if the race has the texture it selects randomly. Mainly just a fun little quest.

I know this isn't the quest section, but here it is if anyone is interested:

sub EVENT_SPAWN {

my $x = $npc->GetX();

my $y = $npc->GetY();

quest::set_proximity($x - 500, $x + 500, $y - 500, $y + 500);
quest::settimer("despawn",1200);

}

sub EVENT_SAY {

if ($text =~/hail/i) {
quest::say ("Would you like me to [return] you to your natural form? Or would you like me to [stop] changing your illusion when you enter the Nexus?"); }

if ($text =~/return/i) {
quest::say ("There, you are now back to your natural appearance.");
quest::playerrace(0); }

if ($text =~/stop/i) {
quest::say ("Ok, I won't change it from now on. Unless you change your mind and wish for me to [start] changing it again next time.");
quest::setglobal("illusion", 1, 1, "F"); }

if ($text =~/start/i) {
quest::say ("Sure, I will be happy to start changing your illusion again next time!");
quest::setglobal("illusion", 1, 1, "M10"); }

}

sub EVENT_ENTER {

if (defined($qglobals{illusion})) {
}
else {
quest::playerrace(quest::ChooseRandom(14,27,42,43, 46,58,60,62,63,66,75,82,85,89,95,108,120,123,141,1 50,151,153,161,209,210,211,212,240,356,367,433,436 ,454,455,456,458,464,469,470,472,473));
quest::playertexture(quest::ChooseRandom(1,2,3,4,5 ));
quest::setglobal("illusion", 1, 1, "M10");
}

}

sub EVENT_TIMER {

if ($timer eq "despawn") {
quest::say ("I am off to gather more materials to cast my illusions. See you all soon!");
quest::depop(); }

}

I figured I would post this as an example of the quest actually working. I can imagine quite a few cool uses for these quest commands. I can't wait to start playing with them for advanced events hehe.

I am going to update my source files that I posted in another section for anyone to download if they so wish. It will include all of the previous updates plus this new feature.