06 Dec, 2009, jurdendurden wrote in the 1st comment:
Votes: 0
As you probably know, I have implemented traps in my mud. If not, then you do now. Anyway, I cast detect trap, and I can suddenly see good and evil alignments. What the hell? This shouldn't even affect that part of the code since the detect traps code is in format_obj_to_char and align visibility (for npcs/pcs) is in show_char_to_char_0. This makes no sense to me and I've scoured my code for mistakes but just can't find any. Below are my full format_obj_to_char and show_char_to_char_0 funcs:
char *format_obj_to_char (OBJ_DATA * obj, CHAR_DATA * ch, bool fShort)
{
static char buf[MAX_STRING_LENGTH], message[MAX_STRING_LENGTH];
buf[0] = '\0';

if ((fShort && (obj->short_descr == NULL || obj->short_descr[0] == '\0'))
|| (obj->description == NULL || obj->description[0] == '\0'))
return buf;
if (IS_IMMORTAL(ch) && IS_SET(ch->act,PLR_HOLYLIGHT))
{
sprintf (message, "{d({x%d{d){x ", obj->pIndexData->vnum);
strcat (buf, message);
}
if (obj->item_type <= ITEM_CLOTHING)
{
if ( obj->condition >= 100 )
strcat( buf, "[{Gpfct{x] ");
else if ( obj->condition >= 85 )
strcat( buf, "[{gnear{x] " );
else if ( obj->condition >= 70 )
strcat( buf, "[{Ygood{x] " );
else if ( obj->condition >= 45 )
strcat( buf, "[{yworn{x] ");
else if ( obj->condition >= 20 )
strcat( buf, "[{rpoor{x] ");
else
strcat( buf, "[{Rbrkn{x] ");
}
if (get_skill(ch, gsn_find_trap) > 0 && !is_affected(ch, gsn_detect_traps))
{
if (number_percent() < get_skill(ch, gsn_find_trap))
{
if (is_trapped(obj))
{
strcat (buf, "({CTrapped{x) ");
check_improve (ch, gsn_find_trap, TRUE, 4);
}
}
}
if (is_affected(ch, gsn_detect_traps) && is_trapped(obj))
strcat (buf, "({CTrapped{x) ");
if (IS_OBJ_STAT (obj, ITEM_INVIS))
strcat (buf, "({DInvis{x) ");
if (IS_AFFECTED (ch, AFF_DETECT_EVIL) && IS_OBJ_STAT (obj, ITEM_EVIL))
strcat (buf, "({rRed Aura{x) ");
if (IS_AFFECTED (ch, AFF_DETECT_GOOD) && IS_OBJ_STAT (obj, ITEM_BLESS))
strcat (buf, "({yGolden Aura{x) ");
if (IS_AFFECTED (ch, AFF_DETECT_MAGIC) && IS_OBJ_STAT (obj, ITEM_MAGIC))
strcat (buf, "({bMagical{x) ");
if (IS_OBJ_STAT (obj, ITEM_GLOW))
strcat (buf, "({WGlowing{x) ");
if (IS_OBJ_STAT (obj, ITEM_HUM))
strcat (buf, "({GHumming{x) ");
if (fShort)
{
if (obj->short_descr != NULL)
strcat (buf, obj->short_descr);
}
else
{
if (obj->description != NULL)
strcat (buf, obj->description);
}
return buf;

}



void show_char_to_char_0 (CHAR_DATA * victim, CHAR_DATA * ch)
{
char buf[MAX_STRING_LENGTH], message[MAX_STRING_LENGTH];
char holy[MSL];

buf[0] = '\0';

if ( IS_IMMORTAL(ch) && IS_SET(ch->act,PLR_HOLYLIGHT) && !IS_NPC(victim) && !IS_NPC(ch))
{
sprintf( holy, "{d({x%d{d){x ", victim->pIndexData->vnum);
strcat( buf, holy );
}
if (IS_SET (victim->comm, COMM_AFK))
strcat (buf, "{b[{xAFK{b]{x ");
if (is_affected(ch, gsn_detect_undead) && victim->race == RACE_UNDEAD)
strcat (buf, "({DUndead{x) ");
if (IS_AFFECTED (victim, AFF_INVISIBLE))
strcat (buf, "({DInvis{x) ");
if (victim->invis_level >= LEVEL_HERO)
strcat (buf, "({rWizi{x) ");
if (IS_AFFECTED (victim, AFF_HIDE))
strcat (buf, "({rHide{x) ");
if (IS_AFFECTED (victim, AFF_CHARM))
strcat (buf, "({YCharmed{x) ");
if (IS_AFFECTED (victim, AFF_PASS_DOOR))
strcat (buf, "({DTranslucent{x) ");
if (IS_AFFECTED (victim, AFF_FAERIE_FIRE))
strcat (buf, "({MPink Aura{x) ");
if (IS_EVIL (victim) && IS_AFFECTED (ch, AFF_DETECT_EVIL))
strcat (buf, "({rRed Aura{x) ");
if (IS_GOOD (victim) && IS_AFFECTED (ch, AFF_DETECT_GOOD))
strcat (buf, "({yGolden Aura{x) ");
if (IS_AFFECTED (victim, AFF_SANCTUARY))
strcat (buf, "({WWhite Aura{x) ");
if (!IS_NPC (victim) && IS_SET (victim->act, PLR_KILLER))
strcat (buf, "(KILLER) ");
if (!IS_NPC (victim) && IS_SET (victim->act, PLR_THIEF))
strcat (buf, "(THIEF) ");
if (victim->position == victim->start_pos
&& victim->long_descr[0] != '\0')
{
strcat (buf, victim->long_descr);
send_to_char (buf, ch);
return;
}

strcat (buf, PERS (victim, ch));
if (!IS_NPC (victim) && !IS_SET (ch->comm, COMM_BRIEF)
&& victim->position == POS_STANDING && ch->on == NULL)
strcat (buf, victim->pcdata->title);

switch (victim->position)
{
case POS_DEAD:
strcat (buf, " is DEAD!!");
break;
case POS_MORTAL:
strcat (buf, " is mortally wounded.");
break;
case POS_INCAP:
strcat (buf, " is incapacitated.");
break;
case POS_STUNNED:
strcat (buf, " is lying here stunned.");
break;
case POS_SLEEPING:
if (victim->on != NULL)
{
if (IS_SET (victim->on->value[2], SLEEP_AT))
{
sprintf (message, " is sleeping at %s.",
victim->on->short_descr);
strcat (buf, message);
}
else if (IS_SET (victim->on->value[2], SLEEP_ON))
{
sprintf (message, " is sleeping on %s.",
victim->on->short_descr);
strcat (buf, message);
}
else
{
sprintf (message, " is sleeping in %s.",
victim->on->short_descr);
strcat (buf, message);
}
}
else
strcat (buf, " is sleeping here.");
break;
case POS_RESTING:
if (victim->on != NULL)
{
if (IS_SET (victim->on->value[2], REST_AT))
{
sprintf (message, " is resting at %s.",
victim->on->short_descr);
strcat (buf, message);
}
else if (IS_SET (victim->on->value[2], REST_ON))
{
sprintf (message, " is resting on %s.",
victim->on->short_descr);
strcat (buf, message);
}
else
{
sprintf (message, " is resting in %s.",
victim->on->short_descr);
strcat (buf, message);
}
}
else
strcat (buf, " is resting here.");
break;
case POS_SITTING:
if (victim->on != NULL)
{
if (IS_SET (victim->on->value[2], SIT_AT))
{
sprintf (message, " is sitting at %s.",
victim->on->short_descr);
strcat (buf, message);
}
else if (IS_SET (victim->on->value[2], SIT_ON))
{
sprintf (message, " is sitting on %s.",
victim->on->short_descr);
strcat (buf, message);
}
else
{
sprintf (message, " is sitting in %s.",
victim->on->short_descr);
strcat (buf, message);
}
}
else
strcat (buf, " is sitting here.");
break;
case POS_STANDING:
if (victim->on != NULL)
{
if (IS_SET (victim->on->value[2], STAND_AT))
{
sprintf (message, " is standing at %s.",
victim->on->short_descr);
strcat (buf, message);
}
else if (IS_SET (victim->on->value[2], STAND_ON))
{
sprintf (message, " is standing on %s.",
victim->on->short_descr);
strcat (buf, message);
}
else
{
sprintf (message, " is standing in %s.",
victim->on->short_descr);
strcat (buf, message);
}
}
else
strcat (buf, " is here.");
break;
case POS_FIGHTING:
strcat (buf, " is here, fighting ");
if (victim->fighting == NULL)
strcat (buf, "thin air??");
else if (victim->fighting == ch)
strcat (buf, "YOU!");
else if (victim->in_room == victim->fighting->in_room)
{
strcat (buf, PERS (victim->fighting, ch));
strcat (buf, ".");
}
else
strcat (buf, "someone who left??");
break;
}

strcat (buf, "\n\r");
buf[0] = UPPER (buf[0]);
send_to_char (buf, ch);
return;
}
06 Dec, 2009, Davion wrote in the 2nd comment:
Votes: 0
Well, what is the difference between is_affected, and IS_AFFECTED. Also, what is AFF_DETECT_TRAP set at? Also, detecting aligns is two separate bits, which one do you see? (red or gold aura).

Also! Post the detect trap spell ;)
06 Dec, 2009, jurdendurden wrote in the 3rd comment:
Votes: 0
a) The difference between is_affected and IS_AFFECTED is simply gsn versus straigth MACRO. There are defines in merc.h that define AFF_BLESS, AFF_PROTECT_GOOD, etc… whereas is_affected simply looks for the gsn.

b) AFF_DETECT_TRAP is not set at all, as it goes outside the bounds of the 'bits' settable for the mud, 'ee' being the highest settable as that is all it will recognize.

c) I see red and gold auras. That's what confuses me. It shows good AND evil when I have detect traps on, i have tested.

d) spell_detect_trap:
void spell_detect_traps (int sn, int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;

if (victim != ch)
{
SEND("You can only cast that on yourself.\r\n",ch);
return;
}

if (is_affected(ch, gsn_detect_traps))
{
SEND("You already sense traps.\r\n",ch);
return;
}

af.where = TO_AFFECTS;
af.type = sn;
af.level = level;
af.duration = level;
if (is_affected (ch, gsn_extension) && victim == ch)
af.duration += number_range((af.duration * 1/5), (af.duration * 2/5));

af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = gsn_detect_traps;
affect_to_char (victim, &af);
SEND ("You feel an inner sense of traps.\r\n", victim);
return;
}
06 Dec, 2009, Davion wrote in the 4th comment:
Votes: 0
Don't set the af.bitvector to gsn_detect_traps. The 'sn' variable passed to this function will be gsn_detect_traps, and it's being set in af.type. So just set af.bitvector to 0.
06 Dec, 2009, jurdendurden wrote in the 5th comment:
Votes: 0
Well, that worked. It took a minute for me to understand what's going on there but yah, that makes sense. Though I don't understand why it has a way to pass an sn to af.type and a way to pass an af.bitvector in there, any enlightenment there?
06 Dec, 2009, Davion wrote in the 6th comment:
Votes: 0
Some things do not use a bitvector for setting affects. Grep for 'af.bitvector' and you can see others that set it to 0. I think it's kinda a bad way to do it, as you'll see things like 'affects none for 20 hours' which is useless ;).
06 Dec, 2009, jurdendurden wrote in the 7th comment:
Votes: 0
Well thank you and by the way I NEVER dreamed of getting code support for a MUD I was trying to build at 3 am (central time) so wow, THANK YOU MUDBYTES, and more importantly, THANK YOU DAVION for your devotion ;) I mean seriously. This is hands down THE BEST mud community I have ever seen.
06 Dec, 2009, Mudder wrote in the 8th comment:
Votes: 0
Mudbytes has people spanning the globe. I think we've got most timezones covered here. Besides, I swear half of you people don't sleep! :wink:
06 Dec, 2009, Davion wrote in the 9th comment:
Votes: 0
jurdendurden said:
Well thank you and by the way I NEVER dreamed of getting code support for a MUD I was trying to build at 3 am (central time) so wow, THANK YOU MUDBYTES, and more importantly, THANK YOU DAVION for your devotion ;) I mean seriously. This is hands down THE BEST mud community I have ever seen.


Thanks :).

It was like 1:30am here! :). But ya know, you really are better off setting up a proper affect. It can fill up the affect limit good though. But you're making a spell, and the usual way in RoM is to make proper affects for it. Which would be, adding to the tables in table.c, defining it in merc.h, and I believe there's some stuff in handler.c that you have to fill out. Just grep for one of the other simple affects (eg. AFF_SLOW) and follow their example.
06 Dec, 2009, jurdendurden wrote in the 10th comment:
Votes: 0
There's only a certain amount of AFFs you can have (#define ee 1073741824). But I did set up an AFF2 table I could put it in there I suppose.
06 Dec, 2009, Kayle wrote in the 11th comment:
Votes: 0
af.bitvector should be AFF_DETECT_TRAPS or whatever it is.
07 Dec, 2009, Koron wrote in the 12th comment:
Votes: 0
Davion said:
Some things do not use a bitvector for setting affects. Grep for 'af.bitvector' and you can see others that set it to 0. I think it's kinda a bad way to do it, as you'll see things like 'affects none for 20 hours' which is useless ;).

Affs with "none" as the mod shouldn't display "affects none by 0," but rather skip right to "Spell: 'Detect Traps' lasts 200 rounds" or what have you. So in my elitist wisdom, if this is the case on your mud, you should change it. :biggrin:
07 Dec, 2009, Koron wrote in the 13th comment:
Votes: 0
Kayle said:
af.bitvector should be AFF_DETECT_TRAPS or whatever it is.

It shouldn't because he's using this to find it:
if (is_affected(ch, gsn_detect_traps))

So bitvector should just be 0.
07 Dec, 2009, Scandum wrote in the 14th comment:
Votes: 0
jurdendurden said:
There's only a certain amount of AFFs you can have (#define ee 1073741824). But I did set up an AFF2 table I could put it in there I suppose.

You can go up to 64 using long long instead of int, and in the define you'd use: #define DETECT_TRAP (1LL << 31) to set the 32nd bit, (1LL << 32) for the 33rd bit, etc.
07 Dec, 2009, jurdendurden wrote in the 15th comment:
Votes: 0
Ahh thanks all and more thanks to Scandum for that last tidbit :)
07 Dec, 2009, David Haley wrote in the 16th comment:
Votes: 0
You might also want to consider creating unlimited-size bitvectors (there are several implementations out there) to be rid of these issues once and for all. The 64-bit solution only pushes off the problem to the 65th flag, after all.
07 Dec, 2009, jurdendurden wrote in the 17th comment:
Votes: 0
David Haley said:
You might also want to consider creating unlimited-size bitvectors (there are several implementations out there) to be rid of these issues once and for all. The 64-bit solution only pushes off the problem to the 65th flag, after all.


Good point. As it stands I'm pointing to gsn's for about 20-30 spell affects as is, so it wouldn't be long before I pushed over the 64-limit threshold.
07 Dec, 2009, Koron wrote in the 18th comment:
Votes: 0
To be honest, I don't know why anyone sticks with BVs at all. In my experience, they're far more bug prone and slightly more annoying to deal with than simple gsn checks. The (slightly) reduced memory footprint just doesn't feel worth it for PCs.
0.0/18