07 Jun, 2009, triskaledia wrote in the 1st comment:
Votes: 0
I feel more than a noob right now…
I am running a ROM 2.4 (QuickMUD version) and my players have noticed that the area attacks that I've added are targeting their pets…
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;

if ((is_safe_spell (ch, vch, TRUE)
|| IS_NPC (ch) && IS_NPC (vch)
–>>>Added this into it: || is_same_group (ch, vch))
&& (ch->fighting == vch || vch->fighting == ch))
continue;

I've tried flipping the ch and vch part together and it's still not wanting to work properly.
At one point this was working properly, but I must've gotten carried away at some point and removed the pet/follower line.
Can anyone help me get it so my area attacks no longer attack pets/group members?
–Silence Tyire of Reanimation
07 Jun, 2009, Banner wrote in the 2nd comment:
Votes: 0
triskaledia said:
I feel more than a noob right now…
I am running a ROM 2.4 (QuickMUD version) and my players have noticed that the area attacks that I've added are targeting their pets…
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;

if ((is_safe_spell (ch, vch, TRUE)
|| IS_NPC (ch) && IS_NPC (vch)
–>>>Added this into it: || is_same_group (ch, vch))
&& (ch->fighting == vch || vch->fighting == ch))
continue;

I've tried flipping the ch and vch part together and it's still not wanting to work properly.
At one point this was working properly, but I must've gotten carried away at some point and removed the pet/follower line.
Can anyone help me get it so my area attacks no longer attack pets/group members?
–Silence Tyire of Reanimation


It should work with is_same_group(vch, ch)

EDIT: On second thought, in my hitall skill (which attacks everyone in the room), it was modified to not attack the group like so:

for( vch = ch->in_room->first_person; vch; vch = vch_next )
{
vch_next = vch->next_in_room;
if( is_same_group( ch, vch ) || !is_legal_kill( ch, vch ) || !can_see( ch, vch ) || is_safe( ch, vch )
|| !IS_NPC( vch ) )
continue;


You may also want to put parentheses around:
|| IS_NPC (ch) && IS_NPC (vch)

That is, if your goal is to make it so if you don't want mobs using area spells on other mobs.
07 Jun, 2009, triskaledia wrote in the 3rd comment:
Votes: 0
Switched it back to vch, ch form, and get the same issue, still wants to target my pet.
I do get a warning about ()'s not being in the proper spot however, I think I try to get that sorted out.
–Silence Tyire of Reanimation
07 Jun, 2009, triskaledia wrote in the 4th comment:
Votes: 0
I got the parenthesis error figured out, but it's still not reading properly.
I now have it setup as:
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
int dam;
act ("You summon a blizzard.", ch, NULL, NULL, TO_CHAR);
dam = number_range(150, 250);
cold_effect (ch->in_room, level, dam, TARGET_ROOM);
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;
if ((is_safe_spell (ch, vch, TRUE)
|| (IS_NPC (ch) && IS_NPC (vch))
|| is_same_group (vch, ch))
&& (ch->fighting == vch || vch->fighting == ch))
continue;
if (saves_spell (level, vch, DAM_COLD))
{
cold_effect (vch, level / 2, dam / 4, TARGET_CHAR);
damage (ch, vch, dam / 2, sn, DAM_COLD, TRUE);
}
else
{
cold_effect (vch, level, dam, TARGET_CHAR);
damage (ch, vch, dam, sn, DAM_COLD, TRUE);
}
}
}
:I don't know if seeing the rest of that will help get this debugged… But I put as as vch first then ch, I've also tried dropping it as !is_same_group with undesirable results also. I'm hoping I'm getting closer, bug debugging by myself all day gets me down when I keep failing. :P

–Silence Tyire of Reanimation
07 Jun, 2009, Banner wrote in the 5th comment:
Votes: 0
triskaledia said:
I got the parenthesis error figured out, but it's still not reading properly.
I now have it setup as:
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
int dam;
act ("You summon a blizzard.", ch, NULL, NULL, TO_CHAR);
dam = number_range(150, 250);
cold_effect (ch->in_room, level, dam, TARGET_ROOM);
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next_in_room;
if ((is_safe_spell (ch, vch, TRUE)
|| (IS_NPC (ch) && IS_NPC (vch))
|| is_same_group (vch, ch))
&& (ch->fighting == vch || vch->fighting == ch))
continue;
if (saves_spell (level, vch, DAM_COLD))
{
cold_effect (vch, level / 2, dam / 4, TARGET_CHAR);
damage (ch, vch, dam / 2, sn, DAM_COLD, TRUE);
}
else
{
cold_effect (vch, level, dam, TARGET_CHAR);
damage (ch, vch, dam, sn, DAM_COLD, TRUE);
}
}
}
:I don't know if seeing the rest of that will help get this debugged… But I put as as vch first then ch, I've also tried dropping it as !is_same_group with undesirable results also. I'm hoping I'm getting closer, bug debugging by myself all day gets me down when I keep failing. :P

–Silence Tyire of Reanimation

Are the pets actually grouped?
07 Jun, 2009, triskaledia wrote in the 6th comment:
Votes: 0
Yes:
Master: Silence Leader: Silence Pet: (none) Mount: (none)

Silence's Group:
[Silence ] [ 66500/66500 HP] [ 66500/66500 mana] [ 66500/66500 Move] [948 TnL]
[skeletal abomination] [ 1163/1163 HP] [ 66500/66500 mana] [ 0/0 Move] [0 ExP]

It's gotta be something stupid I'm overlooking…
I tend to do that.

–Silence Tyire
07 Jun, 2009, triskaledia wrote in the 7th comment:
Votes: 0
Something is horribly wrong on how I've got this setup. I just found out that I'm hitting players as well, even ones not flagged as pk.
I'll keep at it, but any more help is appreciated.
–Silence Tyire
07 Jun, 2009, Banner wrote in the 8th comment:
Votes: 0
I believe I found the problem. Change:

|| is_same_group (vch, ch))
&& (ch->fighting == vch || vch->fighting == ch))

to:
|| is_same_group (vch, ch ) 
&& (ch->fighting == vch || vch->fighting == ch) ) )
07 Jun, 2009, triskaledia wrote in the 9th comment:
Votes: 0
Swapped that around. got this warning: magic2.c:589: warning: suggest parentheses around && within ||
and, I still bombarded my undead with a cold blast.
–Silence Tyire
07 Jun, 2009, Banner wrote in the 10th comment:
Votes: 0
Odd, because I tested the same check with my MUD and it worked flawlessly, exempting the fact that I had to replace your functions with my own.

Mine:
if(( is_same_group (vch, ch) || (IS_NPC (ch) && IS_NPC (vch))  || is_safe (ch, vch ) && (ch->fighting == vch || vch->fighting == ch) ) )
continue;


Yours:
if ((is_safe_spell (ch, vch, TRUE) || (IS_NPC (ch) && IS_NPC (vch)) || is_same_group (vch, ch)) && (ch->fighting == vch || vch->fighting == ch))
continue;





[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
cedit bob create
Log: Banner: cedit bob create
Command added.

[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
mi puff
Log: Banner: mi puff
You invoke Puff: (#1 - Puff - lvl: 151)

[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
mi cop
Log: Banner: mi cop
You invoke a street judge: (#32832 - Twi'lek police officer cop street judge - lvl: 44)

[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
force puff follow banner
Log: Banner: force puff follow banner
Puff now follows you.
Force complete.

[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
group puff
Puff joins your group.

[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
bob
You summon a blizzard
Your -( MUTILATES )- a street judge! <[112]>
A street judge has some cuts.

Enemy: [++++++++++]
[Force]: 30014/30014 [Align]: good
[Health]: 1588/1697 [Move]: 30000/30000 [$$]:[45000]|>
You dodge a street judge's attack.
You dodge a street judge's attack.
Your blast -)(- EVISCERATES -)(- a street judge! <[317]>
You critically hit a street judge!
Your blast DOES UN-GODLY THINGS to a street judge! <[853]>
a street judge is DEAD!
You gain 1470 experience in your Combat ability.
You gain 2939 experience in your Leadership ability.
You are now wanted on ryloth.
the corpse of a street judge contains:
Nothing.
07 Jun, 2009, Banner wrote in the 11th comment:
Votes: 0
What does this do?
cold_effect (ch->in_room, level, dam, TARGET_ROOM);


That is up above the actual victim find for statement, does that do any damage?
07 Jun, 2009, triskaledia wrote in the 12th comment:
Votes: 0
Awkward, as soon as I switched it to yours, (did notice the difference in your safe_check) it compiled with the parenthesis error(not a big deal), but I don't target my pet any more. Now to debug it so im not targeting players. :D
07 Jun, 2009, triskaledia wrote in the 13th comment:
Votes: 0
I commented that cold_effect target_room thing out, because I figured it was out of place.
–Silence Tyire
07 Jun, 2009, Banner wrote in the 14th comment:
Votes: 0
If you don't want it targetting players, add !IS_NPC(vch) to the continue ifcheck. That continues if the victim is not a mob.
07 Jun, 2009, triskaledia wrote in the 15th comment:
Votes: 0
Finally got it where it should be going. I'm hoping right now that my few players don't find a flaw in it.
This is the final result I landed to get the desireable results:
vch_next = vch->next_in_room;
if(((is_same_group (vch, ch)
|| (IS_NPC (ch) || !IS_NPC (vch))
|| is_safe (ch, vch))
&& (ch->fighting == vch || vch->fighting == ch)))
continue;
Hope this helps anyone else out who falls on the same issue I did.
–Silence Tyire of Reanimation
Many thanks to Banner for helping me debug this.
07 Jun, 2009, Banner wrote in the 16th comment:
Votes: 0
So the problem was the parentheses?
13 Jun, 2009, triskaledia wrote in the 17th comment:
Votes: 0
Banner said:
So the problem was the parentheses?


vch_next = vch->next_in_room;
if(((is_same_group (vch, ch)
|| (IS_NPC (ch) || [Put a ! here so:] !IS_NPC (vch))
|| [changes is_safe_spell(ch, vch, true) to:]is_safe (ch, vch))
&& (ch->fighting == vch || vch->fighting == ch)))
continue; [and added the proper parenthesis]

So, in a degree, yes setting the proper parenthesis might've helped out, but I think changing that "IS_NPC(vch)" to "!IS_NPC(vch)" is what set the final standard to allow it to do what I was originally intending.
0.0/17