Log in

View Full Version : Kei Mgb


provocating
01-12-2011, 04:57 PM
I am trying to modify the already written buff bot to do a KEI mass group every so often. I have all of this scripted and it is working well, all I need now is to make the npc cast the spell which I would had thought was the easiest part. I cannot seem to find out how to give the NPC the mass group aa, then maybe take it away right after or is there a special separate list of spells for MGB ?

Caryatis
01-12-2011, 05:14 PM
Usually when you want to do something with NPCs that players can do with 1 button, you need to think behind the scenes. IE what code is run when the player uses that button, in this case MGB. That will usually give you a good idea of how to replicate it for NPCs.

In this case, I would get the client list from the entitylist, use a foreach loop to cycle through each client, do a distance check to mob and if close enough, cast the buff on the player(or make the player cast the buff on themselves).

provocating
01-12-2011, 05:16 PM
Wow, I thought it would had been simpler.

provocating
01-12-2011, 05:33 PM
It was not too bad, this did it.


my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
$ent->CastSpell(2570, $ent);
}
my @npclist = $entity_list->GetNPCList();
foreach $ent (@npclist)
{
$ent->CastSpell(2570, $ent);
}



The only downside is that it looks like they are casting it themselves, which they are. This is the only way I figured for it to work. If you think of any other way let me know.

Caryatis
01-12-2011, 05:42 PM
Keep in mind that atm you code will make every person and NPC in zone do that, might want to add some distance checks and maybe check for being a pet of a client or bot in the NPC loop. Also that doesnt work for bots(if you wanted to include them or not).

You could get the mob list and then only have to do one loop with all your logic for different cases inside that.

Also if you dont want them to actually cast the spell, use CastSpell(xxx, blah, 10, 0, 0); the 10 is slot(not really important except its not a spell gem), then its cast time and mana usage or vice versa.

provocating
01-12-2011, 05:43 PM
Yeah I just walked out of visual range of the NPC and saw that.

provocating
01-12-2011, 06:10 PM
So trying this, how I check distance ?

my @moblist = $entity_list->GetMobList();
foreach $ent (@moblist)
{
quest::shout($ent->Dist());
}

Half expected that to work, but did not.

Caryatis
01-12-2011, 06:14 PM
Get the X, Y, Z of the entry, then use $npc->CalculateDistance(x, y, z).

Not sure where you are looking for perl objects but should check this out: http://www.eqemulator.net/wiki/wikka.php?wakka=QuestObjects

provocating
01-12-2011, 06:27 PM
Okay I got it, this has been crazy so far. I have some serious code checking to do now, with so much testing my code is spaghetti now.

provocating
01-12-2011, 06:49 PM
Also if you dont want them to actually cast the spell, use CastSpell(xxx, blah, 10, 0, 0); the 10 is slot(not really important except its not a spell gem), then its cast time and mana usage or vice versa.

Not quite following you here. Are you saying

$ent->CastSpell(2570, $ent, 10, -1, -1)

or

$npc->CastSpell(2570, $ent, 10, -1, -1)

or

CastSpell(2570, $ent, 10, -1, -1)

Because the last does nothing for me.

trevius
01-13-2011, 03:30 AM
My post on the second page of this thread might have some useful script bits for what you are wanting to do:

http://www.eqemulator.org/forums/showthread.php?t=32605&page=2

An MPG would basically be the same code as in my CastOnGroup() plugin code in that thread, accept you should just have to remove all of the group check stuff.


One thing is that I believe CastSpell() can only do 1 target at a time. If the NPC is casting the spell on all of the AE targets, it is probably only going to land on 1 of them. In cases where you want multiple spells cast from the same mob at once, you should use SpellFinished():

SpellFinished(spell_id, spell_target = this, mana_cost = 0)


An example for your loop would be:

$npc->SpellFinished(1111, $ent);

provocating
01-13-2011, 11:46 PM
I somehow missed this answer to my post. Dude that works awesome, now it shows the NPC casting the spell. I went ahead and changed my other scripts to this ! You are awesome !

Update:

I notice that this works with something like Skin like Nature, but with an NPC casting KEI will not work and I have to do a $ent->CastSpell(2570, $ent, 10, -1, -1)

I am guessing this is because of what you said here.

One thing is that I believe CastSpell() can only do 1 target at a time. If the NPC is casting the spell on all of the AE targets, it is probably only going to land on 1 of them. In cases where you want multiple spells cast from the same mob at once, you should use SpellFinished():

trevius
01-14-2011, 03:50 AM
I don't know why that wouldn't work for KEI offhand. Should work fine.

Also, if you want the NPC to cast the spell, you want to use this instead:

$npc->CastSpell(2570, $ent, 10, -1, -1);

Though, doing that will limit the NPC to only being able to cast on 1 target at a time. That is why I recommended SpellFinished().

provocating
01-14-2011, 09:20 AM
Not sure but with KEI she cast it on herself, but not me.

provocating
01-14-2011, 03:14 PM
This is the block of code I am working with.

my @moblist = $entity_list->GetMobList();
foreach $ent (@moblist)
{
my $dist = $ent->CalculateDistance($npc->GetSpawnPointX(),$npc->GetSpawnPointY(),$npc->GetSpawnPointZ());
my $level = $ent->GetLevel();
if(int($dist)<100 && $level>=45 && $ent->IsClient())
{
#$npc->SpellFinished(2570, $ent);
$npc->CastSpell(2570, $ent, 10, -1, -1)
}
elsif(int($dist)<100 && $level<45 && $ent->IsClient())
{
quest::say("Sorry " . $ent->GetCleanName() . " you are too low to recieve this spell");
}
}

With either what you see, or un-remarking the other line of code, both she will cast on herself. If I change the $npc to $ent I will cast the spell on myself. If I change the spell to Skin like Nature it works fine, but KEI she will always cast on herself. My memory may be off but you had to be grouped to get KEI in Live, so I think this would make sense correct ? So essentially no matter who you have targetted it would only effect you and your group.

Chanus
01-14-2011, 04:08 PM
That was the case until Target Group Buff, in which case if you had a player in another group as your target, it would land on that group.

toggled with /tgb on/off , not an ability

TGB should probably be in the current emu code, I would think, but I don't know for sure. Not sure if this would have an effect.