Log in

View Full Version : Passing Variables, Saving Fight Status


Hateborne
03-12-2011, 11:09 PM
Sorry to bother everyone, but I've run into a minor issue (again).

Trying to have an NPC (which we'll call Bob), spawn a small chain of npcs in waves.

Bob needs to send the target to his newly spawned friends.

Also, Bob's newly spawned friends refuse to attack. I'm conning threateningly, sitting at their feet, aggro radius is 50 and the aggro flag/trigger/etc is set to 1 (assuming 0 = off). I even tried setting a proximity in perl file to bust me in the face when I get too close...nadda.

-Hate

joligario
03-12-2011, 11:38 PM
What part do you need help with? You could have your npc waves send signals to Bob when they die. If you think the zone may shut down or you want to resume a fight, you could always use qglobals.

As for the "refuse to attack" - GM flag on?

Hateborne
03-12-2011, 11:49 PM
Specifically how does one send variables between NPCs? Can some of the prebuilt events be used? Are globals known to cause issues?

I don't need anything particularly strong, just something that can tally up random point scores at the end of each wave. Rewarding the players every 5 defeated waves.
(and of course, some way to get Bob to instruct the wave leader to attack the quest starter)

(thank you for the reply!)

-Hate

joligario
03-13-2011, 12:02 AM
You don't really send variables between NPCs, but you can use signals. You can signal a specific number and it can be like sending a variable...

NPC1 - Bob (10001)

sub EVENT_SAY {
if ($text=~/go/i) {
quest::say("Sending signal to Nancy.");
quest::signalwith(10002,1,0);
}
}

sub EVENT_SIGNAL {
if ($signal == 99) {
quest::say("Nancy replied back with 99.");
}
}

NPC2 - Nancy (10002)

sub EVENT_SIGNAL {
if ($signal == 1) {
quest::shout("Yes, Bob!");
quest::signalwith(10001,99,0);
}
}

As for qglobals, just as long as you understand the implementation, there shouldn't be anything wrong with using those. However, that would be more for something that you would need to store for a longer period of time rather than immediately.

Hateborne
03-13-2011, 03:18 PM
Made note of signals, but the information passed back and forth would primarily be a target(s).

For example: Joe(player) says "I am ready" to Bob(npc). Bob(npc) spawns Nancy(npc) and the 7 Angry Nuns.

How would I get Bob(npc) to tell Nancy(npc) and her Nuns to attack Joe(player)?

As far as I am aware, mobs cannot be spawned with a target preset.

I have rough idea of how to build small variable list for targets, not how to pass them. Basically would like to build list of the player that say "ready", the ids of his group, and then mark any of those in group as "priorities" if class = clr/dru/shm. Then Nancy(npc) could randomly tell the nuns to focus fire on one of the priority targets (chosen at random via the quest::chooserandom(id1,id2,etc) option).

And again, joligario, thank you for your time.

-Hate

Caryatis
03-13-2011, 07:42 PM
Get the ID of the target you want passed and pass that as the signal number.

joligario
03-13-2011, 09:19 PM
Exactly. Also, if your NPC is going to be up all the time, you could control everything with him. Check out the scripts in qinimi on the peq site for the BiC quest.

Jaekob
03-15-2011, 04:18 PM
http://www.eqemulator.org/forums/showthread.php?t=32774

Here's another example of a NPC selecting a random target from a hate list from Trevius. It's a bit more complicated but works very well. There's a modified version of it over at PEQ in ikkinz.

Hateborne
03-17-2011, 11:49 AM
Alright, thank you. I now have a general direction. :-D

All I have to do now is fine tune it, get the non-standard zone models to work (ex: Spectre, Gnolls, Plague Rats, etc in West Freeport), and then some cookies.


Almost there, thank you again all.

-Hate

Hateborne
03-25-2011, 05:22 PM
I am almost completely stuck. I cannot get this bugger to do anything other than stand there like a goon. I am clueless as to where this is failing as it produces no output.

Occasionally it will get an error involving "$i->AddToHateList($attackerID,100)" but I found a post leading me to believe that AddToHateList used entityID instead.

$calledIt = 0;
$markPlayer = 0;

sub EVENT_SPAWN
{

}

sub EVENT_DEATH
{
quest::signalwith(999147,999148,0);
quest::emote("yelps in pain.");
undef $calledIt;
undef $markPlayer;
}

sub EVENT_ATTACK
{
# my @NPCLIST = $entity_list->GetNPCList();
# my @victimList = $npc->GetHateList();
# my $victimCount = scalar (@victimList);
# quest::shout("DEBUG: $victimCount");

if($calledIt == 0)
{
$calledIt = 1;
charge(0, $client);
}
}

sub EVENT_AGGRO
{
if($calledIt == 0)
{
$calledIt = 1;
charge(0, $client);
}
}

sub EVENT_SIGNAL
{
if($calledIt == 0)
{
$calledIt = 1;
$markPlayer = $signal;
charge($markPlayer, 0);
}

if($signal eq "tmHT")
{
castHT();
quest::stoptimer("tmHT");
quest::settimer("tmHT", 15);
}
}

sub charge
{
my $var1 = $_[0]; ## character id storage
my $var2 = $_[1]; ## client id storage

if($var1 == 0)
{
$attacker = $var2->GetName();
$attackerID = $var2->CharacterID();
}
else
{
$var2 = $entity_list->GetClientByCharID($var1);
$attacker = $var2->GetName();
$attackerID = $var1;
}

# warn players
quest::shout("Blackburrrroooooow!");
quest::attack($attacker);



# call up lists of gnolls
my @NPCLIST = $entity_list->GetNPCList();
#my @fippy = $entity_list->GetMobByNpcTypeID(999150);
#my @tranixx = $entity_list->GetMobByNpcTypeID(999149);
my $fippy = 999150;
my $tranixx = 999149;
my $tempScalar = 0;

foreach $i (@NPCLIST){
if($i->GetNPCTypeID() == ($fippy || $tranixx)) {
$i->AddToHateList($attackerID, 1000);
}
}


# if gnoll(s) exist, set them on player
# $tempScalar = scalar (@fippy);
# quest::say("DEBUG: Fippy $tempScalar");
# if($tempScalar > 0)
# {
# foreach $i(@fippy)
# {
# $i->AddToHateList($attackerID,100);
# }
# }
#
# $tempScalar = scalar (@tranixx);
# quest::say("DEBUG: Tranixx $tempScalar");
# if($tempScalar > 0)
# {
# foreach $i(@tranixx)
# {
# $i->AddToHateList($attackerID,100);
# }
# }
quest::settimer("tmHT", 15);
}

sub castHT
{
my $victim = $mob->GetHateRandom();
quest::say("$victim");

}



The castHT also completely fails for no given reason that I can figure out. Any insight/pointers would be greatly useful!

-Hate

Caryatis
03-25-2011, 09:09 PM
I'm not sure what your coding process is but if it involves writing the entire script and then seeing if it works, its probably not a good idea until you are more confident with the code and syntax.

I see many problems with this, such as:
if($i->GetNPCTypeID() == ($fippy || $tranixx)) {

Is not valid syntax.

quest::settimer("tmHT", 15);

Yet you have no timer event.

You also pass a string in the signal event and Im not sure if that works(Im too lazy to look) but since you are not using that to pass anything useful(like say the charID so you wouldnt need a charge event), just have it pass a number.

There is probably more but I just skimmed it. I've also had problems with scripts not running if I only use a single # to comment things.

The proper way to debug this script is to back it up and delete everything except one event, then add another, then another, etc. For large events, add them in small pieces until you are sure its going to work.

Hateborne
03-25-2011, 11:44 PM
Although I appreciate insightful input, I am perfectly capable of treating myself like trash...

The $fippy || $tranixx thing was me trying to explain SQL to class mate while trying to fix perl at the same time. I clearly failed MISERABLY.

I kept getting bizarre errors in server logs. It stemmed from the $victim variable and AddToHateList, so I moved add code with the sole purpose of creating VISIBLE results. It failed, then I went all tunnel vision.

(I went back and cleaned it up. I was so determined to get it to display the $victim variable, I forgot to go back and clean it before posting.)


$calledIt = 0; ## essentially true or false variable
$markPlayer = 0; ## stores player character id

sub EVENT_SPAWN
{

}

sub EVENT_DEATH
{
quest::signalwith(999147,999148,0); ## send signal of npc being killed to battlemaster to tally points
quest::emote("yelps in pain.");
undef $calledIt;
undef $markPlayer;
}

sub EVENT_ATTACK
{

if($calledIt == 0) ## if this hasn't occured yet, then do it
{
$calledIt = 1;
charge(0, $client);
}
}

sub EVENT_AGGRO
{
if($calledIt == 0) ## if this hasn't occured yet, then do it
{
$calledIt = 1;
charge(0, $client);
}
}

sub EVENT_SIGNAL
{
if($calledIt == 0) ## if this hasn't occured yet, then do it
{
$calledIt = 1;
$markPlayer = $signal; ## setting public variable markPlayer to the passed signal (which is character id)
charge($markPlayer, 0);
}

}

sub EVENT_TIMER
{
if($timer eq "tmHT")
{
castHT();
quest::stoptimer("tmHT"); ## did this because I had issues with timers "adjusting" their length
quest::settimer("tmHT", 15); ## obviously if I want this to continue after stopping, i have to restart
}
}

sub charge
{
my $var1 = $_[0]; ## character id storage
my $var2 = $_[1]; ## client id storage

if($var1 == 0) ## if character id not found, used client id to FIND client id
{
$attacker = $var2->GetName();
$attackerID = $var2->CharacterID();
}
else
{
$var2 = $entity_list->GetClientByCharID($var1);
$attacker = $var2->GetName();
$attackerID = $var1;
}


## warn players
quest::shout("Blackburrrroooooow!");
quest::attack($attacker);


## call up lists of gnolls
my @NPCLIST = $entity_list->GetNPCList(); ## get list of all npcs
my $fippy = 999150; ## set fippy npctypeid
my $tranixx = 999149; ## set traniix npctypeid
my $tempScalar = 0; ## using as a junk variable for get scalar variables and such

## checking each npc in the npclist
foreach $i (@NPCLIST){
## if i's npctypeid is fippy's, then
if($i->GetNPCTypeID() == $fippy) {
## add the 1k threat on fippy against player
$i->AddToHateList($attackerID, 1000); ## Is this entity id?
}
}

## start tmHT
quest::settimer("tmHT", 15);
}

sub castHT
{
my $victim = $mob->GetHateRandom();
quest::say("$victim"); ## announce instead of casting atm

}



Basically:
1) NPC is aggro'ed, signal is hit, or player attacks NPC. Set the calledIt variable to 1 (preventing charge() from being called a second time).
2) If client id is passed, find the character ID. If character ID is passed, run with it.
3) Shout out and rush player.
4) Get list of all NPCs in zone.
5) Check NPCList for an npc matching Fippy's npctypeid. If one is found, set 1k threat on player that triggered the event.
6) Start timer "tmHT" with 15 seconds.
7) On 15 second mark, announce the object of the soon to be 'affection' ($victim).

$victim would NOT work even when I just put in a basic "hail" say event. I am trying to learn some of the commands by digging up the perl_mob.cpp and deciphering exactly what type of data must be passed in/out with each item.

Most of the references are coming from the EQEmu Quest Objects list, but I am still (as mentioned above) trying to find what does and doesn't work.

I have a 1200 line script for the battlemaster that works flawlessly for randomly spawning enemy groups, tallying points for those killed, and allowing a quit/continue option at fight number 5 & 10.

However a simple aggro and call-to-arms script defeats me :-\


-Hate