PDA

View Full Version : The Illusionist


trevius
06-25-2008, 04:46 AM
I haven't submitted one of my custom quests here for a while. Mainly because I haven't been doing as much content developing for the past 2 months. But, I figured I would post this fun little quest so people with custom servers can try it out or borrow parts from it to make their own quests. I am always borrowing quest code to write my quests and that is one of the main points to the custom quest section IMO. It gives people a chance to see what can be done and give ideas of something they might like to do.

So, this quest is for an NPC in Nexus on my server, which is the starting point for all new players. They all zone into 0,0,-30 of nexus, so that is where I put this NPC.

What the illusionist does is it will set a random global race to anyone that zones into nexus via gate or creates a new character. It will also randomly set a texture to add more variety. Also, it will move any character that zones in to a nearby random loc so that they don't all pile up on top of each other. This is so that the special races can all be seen even if people gate and go AFK. I figured that part would also be handy for pretty much any server admin who has a central server base. You could set an NPC with race 240 and bodytype 11 so that it was invisible with no name and untargetable. Then, set it to always move characters like this quest does.

Another feature of the quest is that it uses quest globals so that a player can only get 1 illusion every 10 minutes. This is mainly to keep the proximity from going crazy and changing textures of everyone non-stop, since I think that might be bad for the zone lol. I have the NPC set to depop after 20 minutes and the spawn timer is currently set to 1 hour. This is so she isn't up all of the time to keep it a little bit cooler (rarer things are cooler lol). Though, setting the repop even longer would give an even better effect. Maybe having it pop once a day (with a variable time length) for an hour would be nice.

The NPC also responds to hails and will set player race back to 0 (their actual race). She will also disable the auto race change if a player asks and will enable it again if they want too.

Once you load this quest, you will need to make sure your NPC has the qglobals field in the NPC_Types table set from 0 to 1. Also, you will need to restart the zone for the proximity to take effect.

Enjoy :D

The Illusionist:
#Illusion NPC and random nearby location mover

sub EVENT_SPAWN {

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

quest::set_proximity($x - 10, $x + 10, $y - 10, $y + 10);
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{nexusmove})) {
}
else {
quest::movepc(152, quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),-30);
quest::setglobal("nexusmove", 1, 1, "M10");
}

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,150,1 51,153,161,209,210,211,212,356,367,433,436,454,455 ,456,458,464,469,470,472,473));
quest::playertexture(quest::ChooseRandom(1,2,3,4,5 ));
quest::movepc(152, quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),-30);
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(); }

}

seridium
02-11-2009, 03:45 AM
A very nice job on her, works very well.

trevius
02-11-2009, 04:04 AM
Glad you like it. Here is an updated version that I use now that has some improvements:

#Illusionist Quest

my $cast;

sub EVENT_SPAWN {

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

quest::set_proximity($x - 10, $x + 10, $y - 10, $y + 10);
quest::settimer("stopcast",1200);
$cast=1;

}

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{nexusmove})) {
quest::movepc(152, quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),-30);
quest::setglobal("nexusmove", 1, 1, "M10"); }

if ($cast==1) {
if ($ulevel >= 5) {
if (!defined($qglobals{illusion})) {
quest::playerrace(quest::ChooseRandom(14,27,42,43, 46,58,60,62,63,66,75,82,85,89,95,108,120,123,150,1 51,153,161,209,210,211,212,356,367,433,436,454,455 ,456,458,464,469,470,472,473));
quest::playertexture(quest::ChooseRandom(1,2,3,4,5 ));
quest::movepc(152, quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),quest::ChooseRandom(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35),-30);
quest::setglobal("illusion", 1, 1, "M10");
}
}
}

}

sub EVENT_TIMER {

if ($timer eq "stopcast") {
$cast=0;
quest::stoptimer("stopcast");
quest::say ("I must concentrate for a while before I can cast more illusions.");
$npc->SetAppearance(1);
quest::settimer("startcast",14400);
}

if ($timer eq "startcast") {
$cast=1;
quest::stoptimer("startcast");
quest::say ("I have gathered enough energy to begin casting illusions once again!");
$npc->SetAppearance(0);
quest::settimer("stopcast",1800);
}

}

seridium
02-15-2009, 05:39 AM
Why thank you I think I will give her a go.

Lillu
05-21-2009, 06:29 PM
Trev, you simply rock! Thanks for sharing once again. :)