Re: CODE: Spec_proc problem

From: Patrick Dughi (dughi@imaxx.net)
Date: 08/17/00


> Could anyone provide some example code for a mobile which will respond
> to 'tell's.

        Well, one problem is that spec_procs are local (room based) not
global.  So, if you 'tell' a mob something, and they're not in the room,
you're kinda outta luck with the current setup.  That's cause spec_procs
act on two sorts of things - commands, and an event pulse.  They don't act
on strings that they receive.  That's why you can't trigger a specproc
with a gecho, for example.

        So, your first hurdle is simply getting a mob to listen to you.

Lets say your spec_proc is the following;

SPECIAL(tell_guy) {
  ACMD(do_say);

  if(cmd != -1)
    return FALSE;

  do_say((struct char_data *)me,"I got a tell.",0,0);

  return TRUE; /* though, this shouldn't matter */

}

Now, in perform_tell(), add something like
  SPECIAL(tell_guy);

  if(IS_NPC(vict) && mob_index[GET_MOB_RNUM(vict)].func &&
        mob_index[GET_MOB_RNUM(vict)].func == tell_guy) {
    tell_guy(ch,vict,-1,arg);
  }

        There, now your mobs can receive tells.  You'll have to figure out
how to tokenize the string on your own though and look for matches.  The
string of course, is passed to the SPECIAL as 'arg'.

> So far i havent been able to get it to repond only to it's own tells,
> it either reponds to all tells or no tells.

        You want it to tell itself something?  Or .. you have been
testing, and it won't respond to itself which is what you wanted?  You
just throwing that info in for no actual reason?  Or did you mean to type
"i _have_ been able to get it to respond to only it's own tells."?  I'm
sorry, I just don't understand this.  I'll assume you want to eventually
have the mob tell itself something.

        You can't under the current code. In is_tell_ok() we see this
snip;

  if (ch == vict)
    send_to_char("You try to tell yourself something.\r\n", ch);

        The command doesn't go through.

        So, you either allow tells to self to go through, or you check and
see if it's an NPC with your spec proc telling itself something. Then, you
just check the causer (ch) vs. the triggered creature ((struct char_data
*)me).

        Though, that sounds like you're getting into dangerous waters..
I'm sure what ever you'd want to do in that case can be done more easily
in a more efficient manner.  Are you sure this is really what you want?
Maybe you have to stop taking those 'good-drugs'.

        I can't see any way in which it would have to worry about
responding to all tells or none.  Just write the code for which type of
tells you'd like it to respond to.  If you want it to only respond to
tells with 'pink bunny rabbits' in there, search for it, and if you find
it, act on it.  If not, well, don't.  You do have some sort of critera to
seperate things into groups other than 'all tells <working>' or 'no
tells<not working>' right?

        In the future, you may want to try the following when posting to
the circlemud list:

- Give a _CLEAR_ and _UNDERSTANDABLE_ description of your intended
        goal/problem, and be _SPECIFIC!_
Bad:

> Could anyone provide some example code for a mobile which will respond
> to 'tell's.  So far i havent been able to get it to repond only to it's
> own tells, it either reponds to all tells or no tells.  It also hasn't
> yet derived the theory of relativity yet based on the given values of Mu
> in an intrinsic region which is displaced from the middle of the band
> gap by a tempature dependant term based on the ratio of the charge
> neutrality condition of ionised acceptor and donor sites.... and
> it's sort of implied that it does that, from the context, don't you
> see?

(if you're curious, you can't derive it from those given values - this is
a mangled step of a proof for determining the effects of n & p type doping
for a given semiconductor.  This is just an example of being very obscure
and giving information which helps no one. Like "it can't tell to itself"
and that was never given as a goal)

Good:

  I need to know how to write a spec_proc for circle30bpl17 which will
summon a character, if someone tells it "summon me".  I can get it to
respond to a tell, but only if I am in the room, otherwise it does not
work at all.

- Include the code you wrote, examples of output, any errors, any
        patches/snippets/etc that may be affecting it.

[ This deals with the english language.  Though the FAQ says to not
discuss said language, this isn't flame-material.  It regards the ability
of the reader to comprehend what the poster was talking about.  Not
specifically directed at anyone - this is to _help_ as opposed to make
fun of.]

- Using good grammar never hurts.  If you can put forth the extra effort to
        make your post readable, more people will take the time to actually
        read it.  If english is not your primary language, I would suggest
        paying special attention to the use of negatives (can't, won't,
        doesn't, not, etc).  The phrase "I can get this to not work." is
        confusing, especially (as seen above) it doesn't appear to have
        any relation to the rest of the paragraph.  Saying "I can't get
        this to work" is immediately understandable.  When in doubt,
        provide more details so people can derive meaning from the context
        This is just for understandablity, mind you.  If you don't mind
        posting messages which are not understandable, then everyone else
        will still be happy.  You might not get many replies of any value
        though, and that would make you sad :~(

        Heh. Sorry if all that sounds bitchy, but I just realized after
typing all that mess up above that if I knew exactly what you wanted, my
reply could have been 2 lines of code, and taken me 30 seconds to write.
This isn't the first time this sort of thing has happened either...re
'crystal ball' issues from the past.

You knew the phrase "crystal ball" would have to be in there somewhere.
                                                        PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/11/01 PDT