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!
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!