PDA

View Full Version : GetRace issue


boo2
02-25-2013, 06:23 AM
Basically, I have some guards I'm messing with.

When they spawn I have them randomly set to choose between different textures (different guards from different zones.. Qeynos, Freeport, Kelethin, etc..)

The issue I'm having right now is that Qeynos guards are race 71, but texture 1.. so I'm trying to make it so that when they spawn my script checks to see if it is race 71, and if it is race 71 it will change the texture to 1.

What I have right now isn't working, and when I added a say event to see what the race was returning as I get nothing, can someone please tell me what I'm doing wrong?


sub EVENT_SPAWN {
my $random_race = quest::ChooseRandom(71,44);
my $random_weapon = quest::ChooseRandom(1,2,3,7,8,14);

quest::npcrace($random_race);
quest::wearchange(7, $random_weapon);
quest::wearchange(2, 1);
quest::settimer("qeynosguardchange", 1);

}


sub EVENT_TIMER {

my $race = $mob->GetRace();

if($timer eq "qeynosguardchange" && $race == 71) {
quest::shout2("qeynos change yo");
quest::npctexture(1);
quest::stoptimer("qeynosguardchange");
}
}

sub EVENT_SAY {

if ($text =~/hail/i)
{
my $race = $mob->GetRace();
quest::say("$race");
}
}

Drajor
02-25-2013, 07:39 AM
I can not see anything wrong with what you have and I do not have time right now to test it. Here is what I do with my guards.

sub EVENT_SPAWN {
@races = (1..12);
@weapons = (10518, 10519, 10625, 10657, 10786);
$racesNum = @races;
$weaponsNum = @weapons;
quest::npcrace($races[int(rand($racesNum))]);
quest::npctexture(3);

quest::wearchange(7, $weapons[int(rand($weaponsNum))]);
quest::wearchange(8, $weapons[int(rand($weaponsNum))]);
}

trevius
02-25-2013, 08:12 AM
There isn't a variable named $mob that is exported. You will want to use $npc instead and it should work fine.

Change both instances that you have of this:

$mob->GetRace();

to this:

$npc->GetRace();

The Mob quest objects just mean that you can use any classes under mob such as $npc or $client.

c0ncrete
02-25-2013, 08:15 AM
your logs should tell you what the issue is. $mob is not defined anywhere in your script. you want to use $npc.

edit: what trevius said.

boo2
02-25-2013, 02:28 PM
It's working now, I guess I got a bit confused when it said "Mob" in the wiki page.. Thanks guys!

c0ncrete
02-25-2013, 04:09 PM
those are interfaces to functions which are defined for mob objects in C++. both npcs and clients are derived from the mob class, so they are listed there instead of in each individual category. functions that are listed specifically for the client or npc objects are generally unique to the type of object they are listed in.