Log in

View Full Version : $npc->castSpell(ID,Spell); not working


trevius
08-05-2008, 11:13 PM
I don't know why, but I can't seem to get this command working. I have also tried quest::castspell(ID,Spell); but that doesn't seem to work in this quest either. I'm not quite sure what is wrong. This is an NPC that is supposed to be spawned during an event and then switch textures a few times and then depop and cause a really nasty AE if it isn't killed before the last timer finishes. It goes through all of the timers, but stops working on the last one. Though, if I remove "$npc->castSpell($client,6536);" the script completes as it should.

I have it set the variable $client to equal userid so that I am sure it is passing that info into the command. I am testing this with my GM char, but I have tried with invuln on or invuln off and with or without attacking the NPC. I can't get it to work no matter what I have tried.

#Explosive Storm

my $client;

sub EVENT_SPAWN {

quest::npctexture(3);
quest::settimer("start_storm",1);

}

sub EVENT_COMBAT {

if ($combat_state == 1) {
$client = $userid;
}

}

sub EVENT_TIMER {

if ($timer eq "start_storm") {
quest::stoptimer("start_storm");
quest::npctexture(3);
quest::settimer("change_storm1",5); }

if ($timer eq "change_storm1") {
quest::stoptimer("change_storm1");
quest::npctexture(2);
quest::emote("gains more energy and becomes less stable.");
quest::settimer("change_storm2",5); }

if ($timer eq "change_storm2") {
quest::stoptimer("change_storm2");
quest::npctexture(1);
quest::emote("gains even more energy and looks extremely dangerous.");
quest::settimer("change_storm3",5); }

if ($timer eq "change_storm3") {
quest::stoptimer("change_storm3");
$npc->castSpell($client,6536);
quest::emote("explodes and disperses.");
quest::depop(); }

}

Congdar
08-06-2008, 09:26 AM
i think you have the args swapped.

$npc->CastSpell(1948, $charid, 10, -1, -1);
args are spellid, targetid

is working in one of my scripts... maybe $charid instead of $userid? not sure if case sensitive castSpell vs CastSpell

trevius
08-06-2008, 04:21 PM
Ya, I am just going off of the wiki here:

http://www.eqemulator.net/wiki/wikka.php?wakka=QuestTutorial

Which says to do it this way:

quest::castspell(id,spellid) - Casts "spell" on entity with "id". This is buggy, if it does not work try $npc->CastSpell(id,spellid);

Though, I have tried swapping ID and Spell ID around and it didn't make any difference.

The Quest Object Wiki says to do it the way you mentioned:

http://www.eqemulator.net/wiki/wikka.php?wakka=QuestObjects

$npc->CastSpell(spellid,userid); (I found some strange bugs with quest::castspell() and all of these where resolved by using the object...)

**And later on it shows the actual format of: **

CastSpell(spell_id, target_id, slot= 10, casttime= -1, mana_cost= -1)


Once I get it working, I will update the wiki with the correct format. Do you know if the 10, -1, -1 arguments in your example are required? I will try them out and see what happens. Thanks, I think with this info I can hopefully get this working finally lol. That is what I get for fully trusting a wiki page :P

trevius
08-07-2008, 05:10 AM
Oh, it is the case sensitive issue lol. I am using GoergeS' Quest Editor Tool and it is changing this:

$npc->CastSpell(6536, $userid);

to this:

$npc->castSpell(6536, $userid);

I edited the quest manually and it started working right away lol. I am going to post that issue in his tools section so he can get it resolved.

joligario
08-07-2008, 06:48 AM
This works on TGC:

$npc->CastSpell(17,$userid); #Light Healing

Angelox
08-07-2008, 07:42 AM
It could have been related to that space in between '(6536,' and '$userid)' ; (6536, $userid).
or any other invisible character that got caught up in the script ( if you copy-pasted it). I've wasted days on scripts only to find out they were always good, just had unknown, invisible characters (usually when I copy-paste stuff).
This program;
Perl Editor by EngInSite (http://enginsite.com/Perl.htm)
is for windows (although i can run it with Wine too), is free and has an option to show all hidden characters in the script.

trevius
08-08-2008, 03:03 AM
No, it was the case sensitive issue that I already posted about 2 posts up :P It has been resolved and GeorgeS already fixed it in his quest editor. His tool was changing the case of the letter C to lowercase, which is why it wasn't working. Resolved now, thanks!