Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Yandex, DotBot

Members: 0
Guests: 12
Stats
Files
Topics
Posts
Members
Newest Member
481
3,739
19,386
619
Alexander
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Pmobindex checks
Forum Rules | Mark all | Recent Posts

Pmobindex checks
< Newer Topic :: Older Topic > Searching for certain mobs

Pages:<< prev 1 next >>
Post is unread #1 Jul 29, 2002, 12:07 pm   Last edited Nov 24, 2007, 4:51 pm by Samson
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

Hey,

I am trying to figure out some code Im working on that will check to see if a mob Im standing in front of is a certain mob.
I cant use flags to do this, because I want to check through 50 different mob possiblities, and wouldn't have enough flags to use.

This is what I have tried and works except it will always do the all the actions instead of only doing what I have for 10340 vnum.

if ( pMobIndex = get_mob_index( 10340 ));
{
send_to_char("test\r\n", ch);
return;
}
if ( pMobIndex = get_mob_index( 10342 ));
{
send_to_char("test\r\n", ch);
return;
}


Any ideas will be highly appreciated.
       
Post is unread #2 Jul 29, 2002, 2:23 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Take a VERY close look at what you've done here, see those semicolons at the end of your ifcheck statements? Thats's why you're getting those results. The semicolon asks it to do nothing if the condition is met, which then proceeds to code below it. Take those off, should work. Though you may get a warning about how the check itself is being done. Try this:

if ( ( pMobIndex = get_mob_index( 10340 ) ) != NULL )
       
Post is unread #3 Jul 29, 2002, 3:43 pm
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

Samson,

Thanks for catching the semi-colons. The compiler was happier to have that. However, I might not be explaining what I want to accomplish well enough. I need it to compare mob vnums and if it is one vnum do this, if not do that. That is with 50 different mob vnums.

The way it is with your fix now, it just runs the first comparrison no matter which mob I use the command on.

I scoured the archives and I cant see where anyone tried to do this before.
       
Post is unread #4 Jul 29, 2002, 4:33 pm   Last edited Nov 24, 2007, 4:51 pm by Samson
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

Well I thought I had it, but it still wants to tell me what the first check says no matter what mob I check it at.

if ( ( pMobIndex = get_mob_index( 10340 ) ) != NULL )
/*if ( pMobIndex == get_mob_index( 10340 ));*/
 {
send_to_char("&WDomick tells you, 'I teach the following spells/skills:'\r\n",ch);
return;
}

/*if ( pMobIndex == get_mob_index( 10342 ));*/
else if ( ( pMobIndex = get_mob_index( 10342 ) ) != NULL )
{
send_to_char("&WIssac Saelan tells you, 'I teach the following spells/skills:'\r\n", ch);
return;
}
return;
       
Post is unread #5 Jul 29, 2002, 11:40 pm   Last edited Nov 24, 2007, 4:51 pm by Samson
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

Well I thought I had it, but it still wants to tell me what the first check says no matter what mob I check it at.

if ( ( pMobIndex = get_mob_index( 10340 ) ) != NULL )
/*if ( pMobIndex == get_mob_index( 10340 ));*/
 {
send_to_char("&WDomick tells you, 'I teach the following spells/skills:'\r\n",ch);
return;
}

/*if ( pMobIndex == get_mob_index( 10342 ));*/
else if ( ( pMobIndex = get_mob_index( 10342 ) ) != NULL )
{
send_to_char("&WIssac Saelan tells you, 'I teach the following spells/skills:'\r\n", ch);
return;
}
return;

Okay.. so this code checks to see if there is a mob template at vnum 10340... which there appears to be, thus you get the send_to_char() executed.

You say you want to compare vnums, compare vnums of what? With that code you are retrieving the template of the mobile using get_mob_index(), but you aren't running any comparisions.

Now if you had a CHAR_DATA* to a mobile in the room with ch which you want to check mobile->pIndexData->vnum against your constants, then you'd prolly have closer to what you've described.

Or have I totally missed the point?
       
Post is unread #6 Jul 30, 2002, 12:52 am   Last edited Nov 24, 2007, 4:52 pm by Samson
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

[code]void do_teacher( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *mob;
MOB_INDEX_DATA *pMobIndex;

for ( mob = ch->in_room->first_person; mob; mob = mob->next_in_room )
if ( IS_NPC(mob) && xIS_SET(mob->act, ACT_PRACTICE) )
break;

if ( !mob )
{
send_to_char( "You can't learn anything here.\r\n", ch );
return;
}
if ( ( pMobIndex = get_mob_index( MOB_VNUM_DOMICK ) ) != NULL )

{
send_to_char("&WDomick tells you, 'I teach the following spells/skills:'\r\n", ch);
return;
}
if (( pMobIndex = get_mob_index( MOB_VNUM_ISSAC ) ) != NULL )

{
send_to_char("&WIssac Saelan tells you, 'I teach the following spells/skills:'\r\n", ch);
return;
}
return;
}[code]

Ok this is what I am trying with the code now.

The problem is no matter what mob I stand next to and type teacher command. It always does the domick send_to_char, instead of doing just Issac's send_to_char if I type it by Issac.

Thanks!
       
Post is unread #7 Jul 30, 2002, 11:33 am   Last edited Nov 24, 2007, 4:53 pm by Samson
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)


Ok this is what I am trying with the code now.

The problem is no matter what mob I stand next to and type teacher command. It always does the domick send_to_char, instead of doing just Issac's send_to_char if I type it by Issac.

Thanks!

Okay, I think you've confused what get_mob_index() is for..

Taking from your code.

I'm assuming mob has been found and its a valid ACT_PRACTICE mobile, and you now want to check who it is.

So.... replace
if ( ( pMobIndex = get_mob_index(MOB_VNUM_DOMICK ) ) != NULL )
{
    send_to_char("&WDomick tells you, 'I teach the following spells/skills:'\r\n", ch);
    return;
}

if (( pMobIndex = get_mob_index( MOB_VNUM_ISSAC ) ) != NULL )
{
    send_to_char("&WIssac Saelan tells you, 'I teach the following spells/skills:'\r\n", ch);
    return;
}


with

if ( mob->pIndexData->vnum == MOB_VNUM_DOMICK )
{
    send_to_char("&WDomick tells you, 'I teach the following spells/skills:'\r\n", ch);
    return;
}

if ( mob->pIndexData->vnum == MOB_VNUM_ISSAC)
{
    send_to_char("&WIssac Saelan tells you, 'I teach the following spells/skills:'\r\n", ch);
    return;
}


What the second block does as opposed to the first is compare the vnum of mob with the constants you have defined, if they vnums match, hey presto you have your mob found.. otherwise it'll fall onto the next check.

And yes maybe, depending on how you finally structure the command and any checks you perform you may want to check mob->pIndexData exists before heading off and looking at mob->pIndexData->vnum... I'm assuming that field hasn't been shifted around during the development down the codebase branches

Am I getting any closer?
       
Post is unread #8 Jul 31, 2002, 10:01 am
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

Trax + Samson,

Many thanks to you guys for the help.

Remcon gave me a simular solution. You are right I was totally overlooking the mob part.

Thanks,

Vladaar
       
Pages:<< prev 1 next >>