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 ➜ Issues with mob index/snippet

Issues with mob index/snippet

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


Pages: 1 2  

Posted by Zeno   USA  (2,871 posts)  Bio
Date Mon 28 Aug 2006 11:37 PM (UTC)

Amended on Mon 28 Aug 2006 11:49 PM (UTC) by Zeno

Message
This code:
     for (mcounter = 0; mcounter < 99999; mcounter ++)
       {
        mob_vnum = number_range(99, 6000);

        if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
        {
            level_diff = vsearch->level - ch->level;

                /* Level differences to search for. Moongate has 350
                   levels, so you will want to tweak these greater or
                   less than statements for yourself. - Vassago */


            if ( level_diff < 15
                && vsearch->pShop == NULL
                && vsearch->rShop == NULL
                && !xIS_SET(vsearch->act,ACT_PACIFIST)
                && !xIS_SET(vsearch->act,ACT_NOTARGET)
                && !xIS_SET(vsearch->act,ACT_PET)
                && !xIS_SET(vsearch->act,ACT_TRAIN)
                && !xIS_SET(vsearch->act,ACT_PRACTICE)
                && !xIS_SET(vsearch->act,ACT_PROTOTYPE)
                && !xIS_SET(vsearch->act,ACT_IMMORTAL)) break;
                else vsearch = NULL;
        }
    }

    if ( vsearch == NULL || ( victim = get_char_world( ch, vsearch->player_name ) ) == NULL || !IS_NPC(victim))
...


Once in a while, a pacifist mob will slip by somehow. It shouldn't, but it is. Any ideas what's wrong?

Debugging, I found this. The right mob index was selected, but in the get_char_world it selected the wrong mob due to similar mob name. "Panther Villager" was the mob index but it selected "Panther villager 2". Any ideas what I should do, to have it select the right one? Obviously getting by the mob name isn't gonna work.

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 28 Aug 2006 11:51 PM (UTC)
Message
According to the comments in get_char_world you can search by vnum. Why not use that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tzaro   USA  (41 posts)  Bio
Date Reply #2 on Mon 28 Aug 2006 11:52 PM (UTC)
Message
yeah, I had a similar problem using the same snippet.

Call the mob via vnum instead of by name. That should solve the problem :) I'm not near my MUD but I want to say it's get_char_index... something like that. If that's not it, I'll run to a machine that has SMAUG and repost with correct data :X

Implementer of Lost Prophecy,
Tzaro
Top

Posted by Tzaro   USA  (41 posts)  Bio
Date Reply #3 on Mon 28 Aug 2006 11:54 PM (UTC)
Message
heh, I post too slow :P. Anyway, I had an issue when I was calling via vnum. I dunno if stock is like this (too many mods) but get_char_world only allows you to search by vnum if the person requesting that data is a certain level or higher. Removing that little bit allowing all to search also screws it up pretty bad.

Implementer of Lost Prophecy,
Tzaro
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Mon 28 Aug 2006 11:55 PM (UTC)
Message
get_char_world takes vnums? Hrm, it must have to be a string then right?

Tzaro, anything else you found in this snippet needing fixing? I hate to install snippets, but right now it's faster than coding in my own system instead of tweaking this snippet for what I need.

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

Posted by Tzaro   USA  (41 posts)  Bio
Date Reply #5 on Tue 29 Aug 2006 12:02 AM (UTC)
Message
First, I remember what I did... I made a new function that specifically called the mobs by vnum for that piece of code. It really wasn't that much so you could probably add it in that function anyway.

That was the only real issue I had with the code. The whole checking whether or not to assign a mob or an object is a little hairy though. Might want to find a better way to divide up which one it gives.

Also, I ended up having to add an entirely new flag... I just called it no_quest. Some mobs just shouldn't be chosen as a quest mob... some of our areas shouldn't be either (we have an area that only a mage can grant access to. We left it off limits to that snippet since it's impossible to get to unless you're good friends with a mage online, ect) You might want to consider doing the same.

Implementer of Lost Prophecy,
Tzaro
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Tue 29 Aug 2006 03:36 AM (UTC)

Amended on Tue 29 Aug 2006 03:38 AM (UTC) by Zeno

Message
Well I found another issue.
    if ( ( room = find_location( ch, victim->name ) ) == NULL )


Same as above, has issues with mobs having similar names.

I would think you should just use victim->in_room instead.

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

Posted by Conner   USA  (381 posts)  Bio
Date Reply #7 on Tue 29 Aug 2006 03:53 AM (UTC)
Message
Zeno, I used this same aquest snippet in my mud, and by the time we (I had help on it from Rogue, Remcon, and several others - it was a pretty frustrating snippet) got it working right (the way Dragona and I wanted it to work) it was almost completely rewritten.

I can show you what I ended up with, but as was already mentioned by another, I also ended up adding a new noquest area flag, mob flag, and several other changes to other parts of code. For example, I had to make all the travel spells (like astral, portal, etc) not work for anyone who was on a quest, and had to make it understand that dropping an object into a random room for a quest was fine, if the room was player accessible and not a death trap... and so on.

Anyway, by the time I was done with it, my quest code has bits and pieces all over the place throughout the rest of my code. ...suffice it to say, in this case, using a snippet may not be faster than writing your own. :(

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #8 on Tue 29 Aug 2006 04:05 AM (UTC)
Message
Actually I think we're just about done finishing it up for the initial system for now. We don't see any more problems right now, but if we continue to see more maybe we'll just ask to see your end result. Thanks.

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

Posted by Tzaro   USA  (41 posts)  Bio
Date Reply #9 on Tue 29 Aug 2006 03:56 PM (UTC)
Message
ah ha... I found a different snippet than the one I ended up using (and editing massively to have it work exactly how I wanted). Though the one I used didn't have too many issues other than those already listed.

I guess I'll just write a new snippet for the next batch of folks that want to use it... hmm, time for me to put up a new posting :)

Implementer of Lost Prophecy,
Tzaro
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #10 on Wed 30 Aug 2006 07:59 AM (UTC)
Message
Just let me know, Zeno. In my case, we found even after we got it to "work" that it was still really badly buggy. *shrug*

Hopefully you'll have better luck with it than I did, it was the very bane of my existance for months... :(

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #11 on Sat 02 Sep 2006 10:21 PM (UTC)
Message
Does this make any sense? This code:
void generate_quest(CHAR_DATA *ch, CHAR_DATA *questman)
{
    CHAR_DATA *victim;
    MOB_INDEX_DATA *vsearch;
    ROOM_INDEX_DATA *room;
    OBJ_DATA *questitem;
    char buf[MAX_STRING_LENGTH];
    long mcounter;
    int level_diff, mob_vnum;

    /*  Randomly selects a mob from the world mob list. If you don't
        want a mob to be selected, make sure it is immune to summon.
        Or, you could add a new mob flag called ACT_NOQUEST. The mob
        is selected for both mob and obj quests, even tho in the obj
        quest the mob is not used. This is done to assure the level
        of difficulty for the area isn't too great for the player. */

     for (mcounter = 0; mcounter < 99999; mcounter ++)
       {
        mob_vnum = number_range(99, 6000);

        if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
        {
            level_diff = vsearch->level - ch->level;

                /* Level differences to search for. Moongate has 350
                   levels, so you will want to tweak these greater or
                   less than statements for yourself. - Vassago */


            if ( level_diff < 15


Crashed:
#0  0x081ac1c9 in generate_quest (ch=0x96e2f20, questman=0x9456f38) at quest.c:596
596                 if ( level_diff < 15
(gdb) p level_diff
No symbol "level_diff" in current context.
(gdb)


How can there not be a level_diff? It was cleary defined.

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #12 on Sat 02 Sep 2006 11:48 PM (UTC)
Message
Did you change frames? (like, type "up" or "down", or something)?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #13 on Sun 03 Sep 2006 12:15 AM (UTC)
Message
(gdb) f 0
#0  0x081ac1c9 in generate_quest (ch=0x96e2f20, questman=0x9456f38)
    at quest.c:596
596                 if ( level_diff < 15
(gdb) p level_diff
No symbol "level_diff" in current context.

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #14 on Sun 03 Sep 2006 05:03 AM (UTC)

Amended on Sun 03 Sep 2006 05:05 AM (UTC) by Nick Gammon

Message
I strongly suspect in this case that you have corrupted the stack. For one thing, a statement like "if ( level_diff < 15" shouldn't fail under any circumstances, and for another, not finding the variable is suspicious.

Try doing "break generate_quest" and then stepping through the function.

Also try: 'info args' and 'info local'.

Since that is a local variable it should show up in 'info local'.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


85,484 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.