Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Camouflage Skill issue (issue with can_see func)

Camouflage Skill issue (issue with can_see func)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Dralnu   USA  (277 posts)  Bio
Date Sat 03 Sep 2005 10:35 PM (UTC)
Message
I feel kinda stupid, but anywho:
I'm adding in a skill. Its in and everything compiles cleanly, but now I'm working on fixing it into can_see. Goal here is to make it so that only rangers can actually see people aff_camo, and there will be an image via infravision that someone is there, but looking at the can_see func, I'm kinda lost.


bool can_see( CHAR_DATA * ch, CHAR_DATA * victim )
{
   if( !victim )  /* Gorog - panicked attempt to stop crashes */
      return FALSE;
   if( !ch )
   {
      if( IS_AFFECTED( victim, AFF_INVISIBLE ) || IS_AFFECTED( victim, AFF_HIDE ) || xIS_SET( victim->act, PLR_WIZINVIS ) || IS_AFFECTED( victim, AFF_CAMO ) )
         return FALSE;
      else
         return TRUE;
   }

   if( ch == victim )
      return TRUE;

   if( !IS_NPC( victim ) && xIS_SET( victim->act, PLR_WIZINVIS ) && get_trust( ch ) < victim->pcdata->wizinvis )
      return FALSE;

   /*
    * SB 
*/
   if( IS_NPC( victim ) && xIS_SET( victim->act, ACT_MOBINVIS ) && get_trust( ch ) < victim->mobinvis )
      return FALSE;

   /*
    * Deadlies link-dead over 2 ticks aren't seen by mortals -- Blodkai
    */
   if( !IS_IMMORTAL( ch ) && !IS_NPC( ch ) && !IS_NPC( victim ) && IS_PKILL( victim ) && victim->timer > 1 && !victim->desc )
      return FALSE;

   if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_HOLYLIGHT ) )
      return TRUE;

   /*
    * The miracle cure for blindness? -- Altrag 
    */
   if( !IS_AFFECTED( ch, AFF_TRUESIGHT ) )
   {
      if( IS_AFFECTED( ch, AFF_BLIND ) )
         return FALSE;

      if( room_is_dark( ch->in_room ) && !IS_AFFECTED( ch, AFF_INFRARED ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_INVISIBLE ) && !IS_AFFECTED( ch, AFF_DETECT_INVIS ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_HIDE )
          && !IS_AFFECTED( ch, AFF_DETECT_HIDDEN )
          && !victim->fighting && ( IS_NPC( ch ) ? !IS_NPC( victim ) : IS_NPC( victim ) ) )
         return FALSE;
   }

   /*
    * Redone by Narn to let newbie council members see pre-auths. 
    */
   if( NOT_AUTHED( victim ) )
   {
      if( NOT_AUTHED( ch ) || IS_IMMORTAL( ch ) || IS_NPC( ch ) )
         return TRUE;

      if( ch->pcdata->council && !str_cmp( ch->pcdata->council->name, "Newbie Council" ) )
         return TRUE;

      return FALSE;
   }

 /* Commented out for who list purposes 
    if (!NOT_AUTHED(victim) && NOT_AUTHED(ch) && !IS_IMMORTAL(victim) 
    && !IS_NPC(victim))
   	return FALSE;*/
   return TRUE;
}


That is what I have. Its all stock pretty much cept for the first part where the bit about IS_AFFECTED( victim, AFF_CAMO ). Any hints or am I in the wrong function here?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sun 04 Sep 2005 05:09 AM (UTC)
Message
I don't understand why the first bit starts with if ( !ch ). Seems that the whole point is that you want to know if ch 'can_see' victim...

In any case you're in the right place for rangers being able to see camo, but you'll have to do the infrared somewhere else I think.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Sun 04 Sep 2005 03:49 PM (UTC)
Message
Yeah, you need to place the camo check besides the !ch check.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #3 on Sun 04 Sep 2005 04:46 PM (UTC)
Message
So I did that right?
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Sun 04 Sep 2005 04:49 PM (UTC)
Message
So far, yes. You need to add another check (or two, depending what you want) for the actual check against rangers/camo.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #5 on Sun 04 Sep 2005 04:57 PM (UTC)

Amended on Sun 04 Sep 2005 10:34 PM (UTC) by Dralnu

Message
something along the lines of


elseif ( ( ch->class != CLASS_RANGER ) && IS_AFFECTED( victim, AFF_CAMO ) )
     return false


or would I need to make it more like


if( ch->CLASS_RANGER && IS_AFFECTED( victim, AFF_CAMO )
    return TRUE
elseif( IS_AFFECTED( victim, AFF_INVISIBLE ) || IS_AFFECTED( victim, AFF_HIDE ) || xIS_SET( victim->act, PLR_WIZINVIS ) || IS_AFFECTED( victim, AFF_CAMO ) )
         return FALSE;
      else
         return TRUE;

[Edit #1]
Fixed an error in syntax
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #6 on Sun 04 Sep 2005 07:31 PM (UTC)
Message
No... you want to work in this block of code:
   /*
    * The miracle cure for blindness? -- Altrag 
    */
   if( !IS_AFFECTED( ch, AFF_TRUESIGHT ) )
   {
      if( IS_AFFECTED( ch, AFF_BLIND ) )
         return FALSE;

      if( room_is_dark( ch->in_room ) && !IS_AFFECTED( ch, AFF_INFRARED ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_INVISIBLE ) && !IS_AFFECTED( ch, AFF_DETECT_INVIS ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_HIDE )
          && !IS_AFFECTED( ch, AFF_DETECT_HIDDEN )
          && !victim->fighting && ( IS_NPC( ch ) ? !IS_NPC( victim ) : IS_NPC( victim ) ) )
         return FALSE;
   }
This seems to be where most invisibility stuff is handled. You can add a simple check here like so:
if ( IS_AFFECTED( victim->AFF_CAMO ) && ch->class != CLASS_RANGER   )
     return false;
You would of course also add extra clauses to the ifcheck depending on what skills allow detection of camouflaged characters.

Note that you don't need to cover all cases; the function will return true by default so you only need to cover cases where ch can't see victim.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #7 on Sun 04 Sep 2005 10:31 PM (UTC)
Message
I don't want truesight to detect the character, hence my placement. Invisible is magic, and hide is a cheap version of camo the way I have it set up, and most classes wouldn't be able to see a char who has been camouflaged unless they have infravision which wouldn't tell who was there, just that something is there. Anywho, I don't want someone with Truesight to be able to detect the player w/ it, which is what that series of ifchecks is doing.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #8 on Mon 05 Sep 2005 01:48 AM (UTC)
Message
Then just put it outside of the if-check, if you don't want truesight to affect it. People in your world are badass camouflage artists, though... :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #9 on Mon 05 Sep 2005 01:52 AM (UTC)
Message
I'm planning on making additions to the skill/spell system laterm but the way I see it, true sight is something more magical then anything. Bad-ass camouflage it may be called, but way I see it, someone who is invis will have a magical aura around them, and someone who is just hiding can be found easily enough. This will, maybe later, be outdoors/forest only (I plan on making most of the world forest anyways, at least half). I'll post the changes I made later. It has compiled cleanly enough, but as is I have no way to test it since I don't have a Linux MUD client (and I won't use telnet since I have no clue how to).
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #10 on Mon 05 Sep 2005 01:53 AM (UTC)
Message
Plus this is a class-specific skill, and the class might come out peaceful only, so it won't be a problem pk-wise if that were to happen
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #11 on Mon 05 Sep 2005 07:01 AM (UTC)
Message

/*
 * True if char can see victim.
 */
bool can_see( CHAR_DATA * ch, CHAR_DATA * victim )
{
   if( !victim )  /* Gorog - panicked attempt to stop crashes */
      return FALSE;
   if( !ch )
   {
      if( ch->Class != CLASS_RANGER && IS_AFFECTED( victim, AFF_CAMO) )
         return FALSE;
else if( IS_AFFECTED( victim, AFF_INVISIBLE ) || IS_AFFECTED( victim, AFF_HIDE ) || IS_AFFECTED( victim, AFF_CAMO || xIS_SET( victim->act, PLR_WIZINVIS ) ) )
         return FALSE;
      else
         return TRUE;
   }

   if( ch == victim )
      return TRUE;

   if( !IS_NPC( victim ) && xIS_SET( victim->act, PLR_WIZINVIS ) && get_trust( ch ) < victim->pcdata->wizinvis )
      return FALSE;

   /*
    * SB 
*/
   if( IS_NPC( victim ) && xIS_SET( victim->act, ACT_MOBINVIS ) && get_trust( ch ) < victim->mobinvis )
      return FALSE;

   /*
    * Deadlies link-dead over 2 ticks aren't seen by mortals -- Blodkai
    */
   if( !IS_IMMORTAL( ch ) && !IS_NPC( ch ) && !IS_NPC( victim ) && IS_PKILL( victim ) && victim->timer > 1 && !victim->desc )
      return FALSE;

   if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_HOLYLIGHT ) )
      return TRUE;

   /*
    * The miracle cure for blindness? -- Altrag 
    */
   if( !IS_AFFECTED( ch, AFF_TRUESIGHT ) )
   {
      if( IS_AFFECTED( ch, AFF_BLIND ) )
         return FALSE;

      if( room_is_dark( ch->in_room ) && !IS_AFFECTED( ch, AFF_INFRARED ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_INVISIBLE ) && !IS_AFFECTED( ch, AFF_DETECT_INVIS ) )
         return FALSE;

      if( IS_AFFECTED( victim, AFF_HIDE )
          && !IS_AFFECTED( ch, AFF_DETECT_HIDDEN )
          && !victim->fighting && ( IS_NPC( ch ) ? !IS_NPC( victim ) : IS_NPC( victim ) ) )
         return FALSE;
   }

   /*
    * Redone by Narn to let newbie council members see pre-auths. 
    */
   if( NOT_AUTHED( victim ) )
   {
      if( NOT_AUTHED( ch ) || IS_IMMORTAL( ch ) || IS_NPC( ch ) )
         return TRUE;

      if( ch->pcdata->council && !str_cmp( ch->pcdata->council->name, "Newbie Council" ) )
         return TRUE;

      return FALSE;
   }

 /* Commented out for who list purposes 
    if (!NOT_AUTHED(victim) && NOT_AUTHED(ch) && !IS_IMMORTAL(victim) 
    && !IS_NPC(victim))
   	return FALSE;*/
   return TRUE;
}


That is the code as-is after changes. Right now I cann't test it since I'm lacking a client to connect with, If you see any problems or whatever, please let me know, and let me know if you know of a good client for Linux :)
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #12 on Mon 05 Sep 2005 07:38 AM (UTC)
Message
What's wrong with telnet? :-)

Anyhow your code won't work, because you put all that stuff under the ifcheck "if (!ch)" but then you check ch->class... basically what you're doing is saying "if ch is null, then do the following..." But that's not at all what you want to do; in fact you want to make sure that ch is NOT null before continuing.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #13 on Tue 06 Sep 2005 01:32 AM (UTC)

Amended on Tue 06 Sep 2005 01:53 AM (UTC) by Dralnu

Message
Then give me an idea what to do? I'm stumped now -.-

I did add a check into the TRUE_SIGHT bit to get part of it fixed, but in any case, and I think I'm going to leave it there for the time being. Got other things to do, and I'll fix things up later and build around it until I can think of something better
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #14 on Tue 06 Sep 2005 06:58 AM (UTC)
Message
I'm not sure I understand your question. Just put your camo ifcheck outside the truesight and after the "if ( !ch )" checks.

Is the problem that you don't know why "if ( !ch )" is there, i.e. what it does and why it's important?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


68,662 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.