PDA

View Full Version : "Spell" Quest


Township EQ
10-26-2013, 01:24 AM
Hey guys.

I'm trying to make a lifetap proc that does 25% of a target's current HP with a maximum of 500. The problem I'm running into is it seems like the actual script is correct but it's not executing for some reason.

Here's what I did. I copied and existing lifetap spell, and took out the damage, so it is a blank spell. The ID of this blank spell is 8558. I then created a file called 8558 and put it in my global\spells folder. I've done a server restart and countless #reloadqst's and I can spam cast this all day on things and it still doesn't work. Here's the script.

Please note, this is my first attempt to do anything that I deem as non-simple so hopefully you guys wont tear it apart too hard :P

I uploaded a picture as well because the code thing messes up spacing.

http://gyazo.com/a5d4cd471d3a487d6947754d97494ff1.png


sub EVENT_SPELL_EFFECT_CLIENT {

my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();

if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}








sub TESTLIFETAP {
my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
my $TargetsCurrentHP = $ClientTarget->GetHP();
my $Targets25pctCurrentHP = ($TargetsCurrentHP * 0.25);

if($TargetsCurrentHP >= 500) {

$ClientTarget->SetHP($TargetsCurrentHP - 500);
$client->Emote("hit $ClientTarget for ".($TargetsCurrentHP - 500)." points of non-melee damage.");
}
elsif($TargetsCurrentHP < 500) {
$ClientTarget->SetHP($TargetsCurrentHP - $Targets25pctCurrentHP);
$client->Emote("hit $ClientTarget for ".($TargetsCurrentHP - $Targets25pctCurrentHP)." points of non-melee damage.");
}
}


my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();

if($TargetsCurrentHP >= 500) {

$ClientTarget->SetHP($TargetsCurrentHP - 500);
$client->Emote("hit $ClientTarget for ".($TargetsCurrentHP - 500)." points of non-melee damage.");
}
elsif($TargetsCurrentHP < 500) {
$ClientTarget->SetHP($TargetsCurrentHP - $Targets25pctCurrentHP);
$client->Emote("hit $ClientTarget for ".($TargetsCurrentHP - $Targets25pctCurrentHP)." points of non-melee damage.");
}
}

Fadedspirit
10-26-2013, 01:38 AM
First, why are you defining client in a client script?

$client-> literally works......


You're defining a NEW $client object with an uppercase C in Client, was this intentional? If so, why?


Also, why are you redining what $client is more than once?? Aside from the fact you don't have to do it, at all, you're doing it once in spell effects for no reason and then again for lifetap????

Township EQ
10-26-2013, 01:42 AM
First, why are you defining client in a client script?

$client-> literally works......


You're defining a NEW $client object with an uppercase C in Client, was this intentional? If so, why?


Also, why are you redining what $client is more than once?? Aside from the fact you don't have to do it, at all, you're doing it once in spell effects for no reason and then again for lifetap????

Someone I asked help with while it wasn't working gave me something to try and I just left it in there.. Either way, your post isn't very helpful.

Akkadius
10-26-2013, 01:45 AM
First, why are you defining client in a client script?

$client-> literally works......


You're defining a NEW $client object with an uppercase C in Client, was this intentional? If so, why?

First - Because it is not a client script - it's a spell script. $caster_id is the exported object of this trigger EVENT:


case EVENT_SPELL_EFFECT_CLIENT:
case EVENT_SPELL_EFFECT_NPC:
case EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT:
case EVENT_SPELL_EFFECT_BUFF_TIC_NPC:
{
ExportVar(packagename.c_str(), "caster_id", extradata);
break;
}

Second - GetTarget() is a valid mob method

Third - He made a syntax error

sub EVENT_SPELL_EFFECT_CLIENT {
my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

Should be:

sub EVENT_SPELL_EFFECT_CLIENT {
my $Client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

You're making your own client object - since client is not implied you have to fetch it through the data that is exported to the sub.

There is no need to respond in such a way - he legitimately asked for help.

Fadedspirit
10-26-2013, 01:50 AM
First - Because it is not a client script - it's a spell script. $caster_id is the exported object of this trigger EVENT:


case EVENT_SPELL_EFFECT_CLIENT:
case EVENT_SPELL_EFFECT_NPC:
case EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT:
case EVENT_SPELL_EFFECT_BUFF_TIC_NPC:
{
ExportVar(packagename.c_str(), "caster_id", extradata);
break;
}

Second - GetTarget() is a valid mob method

Third - He made a syntax error

sub EVENT_SPELL_EFFECT_CLIENT {
my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

Should be:

sub EVENT_SPELL_EFFECT_CLIENT {
my $Client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

You're making your own client object - since client is not implied you have to fetch it through the data that is exported to the sub.

There is no need to respond in such a way - he legitimately asked for help.

Sorry, didn't see it was a spell script.

Also, the way I replied wasn't any different than what many would reply. There are only a few people whom are actually nice when it comes to code :shock:. Doesn't excuse me, but just saying.

:)

Township EQ
10-26-2013, 01:51 AM
First - Because it is not a client script - it's a spell script. $caster_id is the exported object of this trigger EVENT:


case EVENT_SPELL_EFFECT_CLIENT:
case EVENT_SPELL_EFFECT_NPC:
case EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT:
case EVENT_SPELL_EFFECT_BUFF_TIC_NPC:
{
ExportVar(packagename.c_str(), "caster_id", extradata);
break;
}

Second - GetTarget() is a valid mob method

Third - He made a syntax error

sub EVENT_SPELL_EFFECT_CLIENT {
my $client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

Should be:

sub EVENT_SPELL_EFFECT_CLIENT {
my $Client = $entity_list->GetClientByID($caster_id);
my $ClientTarget = $Client->GetTarget();
if($ClientTarget->IsNPC()) {
TESTLIFETAP();
}
}

You're making your own client object - since client is not implied you have to fetch it through the data that is exported to the sub.

There is no need to respond in such a way - he legitimately asked for help.

Fixed the syntax error.

Sorry, didn't see it was a spell script.

Also, the way I replied wasn't any different than what many would reply. There are only a few people whom are actually nice when it comes to code :shock:. Doesn't excuse me, but just saying.

:)

And your post seemed pretty rude.. I've come across many people in this community who can be knowledgeable and nice at the same time. I am posting in the correct forum, which is a support forum. Either way, I just want to get this to work. I'm new at this, sorry for the syntax error.

Kingly_Krab
10-26-2013, 02:02 AM
Merry Christmas, this works 100%, if the NPC is at 1 health it will hit for 0, keep that in mind.

I fixed your issue, shouting the target doesn't return the target's name, also, re-defining things is unnecessary the way you did it.

Also, I put in 'int' in order to keep you from hitting for decimals and keep the health from becoming decimals.
sub EVENT_SPELL_EFFECT_CLIENT
{
my $client = $entity_list->GetClientByID($caster_id);
if($client->GetTarget()->IsNPC())
{
TESTLIFETAP();
}
}

sub TESTLIFETAP
{
my $client = $entity_list->GetClientByID($caster_id);
if($client->GetTarget()->GetHP() >= 500)
{
$client->GetTarget()->SetHP(int($client->GetTarget()->GetHP() - 500));
$client->Emote("hit " . $client->GetTarget()->GetCleanName() . " for " . int($client->GetTarget()->GetHP() - 500) . " points of non-melee damage.");
}
elsif($client->GetTarget()->GetHP() < 500)
{
$client->GetTarget()->SetHP(int($client->GetTarget()->GetHP() - ($client->GetTarget()->GetHP() * .25)));
$client->Emote("hit " . $client->GetTarget()->GetCleanName() . " for " . int($client->GetTarget()->GetHP() - ($client->GetTarget()->GetHP() * .25)) . " points of non-melee damage.");
}
}

Township EQ
10-26-2013, 02:11 AM
Thanks a lot KK.

I didn't even think about adding int.. definitely something I'll keep in mind for future scripts I make. Huge help.

Kingly_Krab
10-26-2013, 02:17 AM
No problem, int just keeps it from going to a decimal and making everything ugly and annoying, also keep in mind it's really not necessary to even define anything, you could do this.

if($entity_list->GetClientByID($caster_id)->GetTarget->GetHP() >= 500)

But people refer definitions because it's shorter and easier to interpret, I myself like to break away and define as little as possible, the coder logic of, "Do it in less lines."

Also, call me Kingly. :P

Township EQ
10-26-2013, 02:25 AM
No problem, int just keeps it from going to a decimal and making everything ugly and annoying, also keep in mind it's really not necessary to even define anything, you could do this.

if($entity_list->GetClientByID($caster_id)->GetTarget->GetHP() >= 500)

But people refer definitions because it's shorter and easier to interpret, I myself like to break away and define as little as possible, the coder logic of, "Do it in less lines."

Also, call me Kingly. :P

I wasn't aware it was unnecessary to define things like that.

Unfortunately even though the code is correct this still doesn't work and for the life of me I don't know why. It's in the correct folder with the correct name and everything.

NatedogEZ
10-26-2013, 03:20 AM
The way you have it the spell would have to be self only. If you have it as targettype 5 it will not work correctly.

The spell goes off (self only) and hits the client and triggers that event "EVENT_SPELL_EFFECT_CLIENT".

If you aren't doing it that way is why it could possibly not be working.

Guessing you have it as targettype 13 which is "lifetap"... but the way you are doing it with this quest it would need to be targettype 6.

If you change the event to.. "EVENT_SPELL_EFFECT_NPC" it would trigger when the spell lands on a NPC.. and it should function correctly still with the way KK wrote it.


(sorry if this is confusing I am a little tired)

Kingly_Krab
10-26-2013, 12:15 PM
The way you have it the spell would have to be self only. If you have it as targettype 5 it will not work correctly.

The spell goes off (self only) and hits the client and triggers that event "EVENT_SPELL_EFFECT_CLIENT".

If you aren't doing it that way is why it could possibly not be working.

Guessing you have it as targettype 13 which is "lifetap"... but the way you are doing it with this quest it would need to be targettype 6.

If you change the event to.. "EVENT_SPELL_EFFECT_NPC" it would trigger when the spell lands on a NPC.. and it should function correctly still with the way KK wrote it.


(sorry if this is confusing I am a little tired)
I didn't test this with a lifetap, I tested it with a different spell and it worked, however, Natedog is right, if you want to do this with a lifetap it needs to be EVENT_SPELL_EFFECT_NPC, not EVENT_SPELL_EFFECT_CLIENT. :P

Township EQ
10-27-2013, 02:22 PM
Ah yes, got everything working now as it should be. Thanks a lot everyone!