Basic Quest Examples for the KaB extensions available thus far
Create loot for NPC after spawn
The sub EVENT_SPAWN is called before we can properly instantiate random loot - it is important that you have a timer call and in the EVENT_TIMER
check and call AddLootGroup(rndlootgroupid) against the $npc pointer.
Try to use unique timer names for each quest file.
Code:
sub EVENT_SPAWN {
quest::settimer("createboneloot",1);
}
sub EVENT_TIMER {
if ( $timer eq "createboneloot" ) { quest::stoptimer("createboneloot");
$npc->AddLootGroup(16); }
}
Create a team-based guard
Quest scripts should always be created at the zone level, the name or npc id will work.
Team guards must be set on spawn and if you wish to reset any guard card statistics given to the NPC they must be reset on death. The statistics are saved in the
team_guards table in the database.
an example script would include:
Code:
sub EVENT_SPAWN
{
#teamid represents any of the created team id's (1-4 by default).
#each npc should be unique in-game that attributes an npcid
#any duplicate npc's in the world will conflict with each other.
#each team can use the npcid once and provide unique stats.
quest::loadguardtype(teamid, npcid);
}
Code:
sub EVENT_DEATH
{
#if you wish to remove any guard card stats given by players
#issue the quest command below
quest::resetguardfields(teamid, npcid);
}
Get a guard's current bonus statistic value
Code:
sub SUB_WHATEVER
{
#quest::getguardfield(teamid, npcid, fieldname)
#fieldname options: hp, mana, hpregen, manaregen, level, ac
$value = quest::getguardfield(1, 2093, "*fieldname*");
quest::say("I have $value of something!");
}
Check player's PVP value
Code:
sub SUB_WHATEVER
{
#GetPVPFlag returns a value of their team id, typically 1-4
#0 is returned if they are neutral
if ($client->GetPVPFlag() > 0) #check if they are pvp enabled
{
quest::say("Go find a fight!");
}
else
{
quest::say("You are neutral..");
}
}
Check if player is king of a team
Code:
sub SUB_WHATEVER
{
#IsKing returns a value of 1 if they are a king, 0 if not.
if ($client->IsKing() > 0) #check if they are pvp enabled
{
quest::say("You are a king!");
}
else
{
quest::say("You are peasant!");
}
}
Set player's PVP flag
Code:
sub SUB_WHATEVER
{
#0 is for neutral
#1-4 is for teams, 5 is for bandits (ffa)
quest::pvpvalue("5");
}
Get team statistics
Code:
sub SUB_WHATEVER
{
#0 is for neutral
#1-4 is for teams, 5 is for bandits (ffa)
my $qeynosBonus = quest::getteamexpbonus(1);
#team xp bonus returns a 1-100% otherwise
#0 is returned when the city npc is killed (until respawn)
my $qeynosUpkeepPaid = quest::getisupkeeppaid(1);
#returns 0 if upkeep has not been paid, 1 otherwise.
#tax rate (merchants) for visitors to the city
my $qeynosNewbTaxes = quest::getcitynewbietaxrate(1);
#citizen tax rate
my $qeynosCitTaxes = quest::getcitycitizentaxrate(1);
#get cost in copper of upkeep/day
my $qeynosUpkeepCost = quest::getcityupkeepcost(1);
}