Please check out Winter

Member Discussions

terms



[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]


1. Code prob Mon Jun 28, 2004 [12:33 PM]
Oldtimer
Email not supplied
member since: Jun 28, 2004
Reply
Hello coders

I wonder if you kind code folk could help me, I am using Envy Diku Mud, and have taken some advice from these boards got myself some C books (they cost an arm and a leg - and are eating up my pension!)

Anyway cut a long story short - in my mud i liked setmin and setmout for players - but was bored with the arrive leaves for mobs. So I managed to do a new command in medit called mobmvemsg which let the builder set the decriptor for the mobile and it saves and loads fine with the areas, i even managed to get it to show on medit_show! (takes a slow bow) and set the extra stuff in mobiles const table etc so the command works saves and loads in areas etc.But i have a problem getting the descritor to output . ie the snake SLITHERS west. Here is my code below:

Now in void move_char I have

{
CHAR_DATA *fch;
CHAR_DATA *fch_next;
CHAR_DATA *vmob, *vnext;
OBJ_DATA *obj, *objnext;
EXIT_DATA *pexit;
/* MOB_INDEX_DATA *pMob; SHOULD THIS BE HERE?*/
ROOM_INDEX_DATA *in_room;
ROOM_INDEX_DATA *to_room;
int moved = PLR_MOVED;
bool stumble = FALSE;

***edit - snip not gonna paste whole command***


then at the end of this I have done :

{
if( stumble )
act( '&g$n staggers $T.', ch, NULL, dir_name[door], TO_ROOM );
if( !IS_NPC( ch ) && ch->pcdata->setmout
&& ch->pcdata->setmout[0] != '\0' )
act( '&g$n $t $T.', ch, ch->pcdata->setmout,
dir_name[door], TO_ROOM );

/* if ( IS_NPC( ch ) && pMob->mobmvemsg
&& pMob->mobmvemsg[0] != '\0' )
act( '&g $n $t $T.',ch,pMob>mobmvemsg,
dir_name[door], TO_ROOM ); */
else
act( '&g$n leaves $T.', ch, NULL, dir_name
[door],TO_ROOM );
}
}

***************************

The part rem'd out /* is my code, It does not work well in fact, it pulls up some mobiles extra desc, when the mobile moves! Please forgive my ignorance if it is bad coding, but I have searched everywhere before I asked. Although it all compiles it certainly does not do what i expected. Any help or pointers would be greatly appreciated.

Thanks
Oldtimer :)

Sorry for the formating - gonna have to learn html now!


2. RE: Code prob Mon Jun 28, 2004 [1:34 PM]
TheReader
Email not supplied
member since: Jan 1, 2004
In Reply To
Reply
Could you please post where you set mobmvemsg? The problem doesn't appear to be in what you wrote above. (Although, should the 2 if()'s after the if(stumble) be else if()'s?)

The tags you put around your code are '<code>' and '</code>'.

TheReader


3. RE: Code prob Mon Jun 28, 2004 [1:41 PM]
Manteiv
Email not supplied
member since: Dec 12, 2003
In Reply To
Reply
/* MOB_INDEX_DATA *pMob; SHOULD THIS BE HERE?*/

Leave pMob defined, but in the code (I assume you've done this in the part you omited), you have to determine which mob pMob is. I believe if you didn't do this, it would of crashed, rather then just give you a different description. Yet sometimes things work strangely.
- Owner/Coder for SWRotS
- Still updating SWRPG v.3


4. RE: Code prob Mon Jun 28, 2004 [5:05 PM]
Oldtimer
Email not supplied
member since: Jun 28, 2004
In Reply To
Reply
Hi
Firstly thanks for replying, here is the full move_char code, I have only set the enter room part as i figured if i got this correct then I could do the leave room message.

Many thanks
Oldtimer

void move_char( CHAR_DATA *ch, int door )
{
CHAR_DATA *fch;
CHAR_DATA *fch_next;
CHAR_DATA *vmob, *vnext;
OBJ_DATA *obj, *objnext;
EXIT_DATA *pexit;
/* MOB_INDEX_DATA *pMob; MY CODE*/
ROOM_INDEX_DATA *in_room;
ROOM_INDEX_DATA *to_room;
int moved = PLR_MOVED; /* Same for both ACT & PLR bits */
bool stumble = FALSE;

if( door < 0 || door > 5 )
{
bug( 'Do_move: bad door %d.', door );
return;
}

/*
* Prevents infinite move loop in
* maze zone when group has 2 leaders - Kahn
*/
if( xIS_SET( ch->act, moved ) )
return;

for( vmob = ch->in_room->people; vmob; vmob = vmob->next_in_room )
{
if( !vmob->deleted && vmob->fighting == ch )
{
send_to_char( 'Not while someone here want's to kill you.\n\r', ch );
return;
}
}

if( IS_AFFECTED( ch, AFF_HOLD ) )
{
AFFECT_DATA *af;
char buf[100];

send_to_char( 'You are stuck in a snare! You can't move!\n\r', ch );
WAIT_STATE( ch, PULSE_VIOLENCE / 2 );
web_update( ch );
for( af = ch->affected; af; af = af->next )
{
if( af->deleted || !xIS_SET( af->bitvector, AFF_HOLD )
|| af->duration < 0 )
continue;

if( --af->duration == 0 )
{
affect_remove( ch, af );
sprintf( buf, 'You are no longer held back by '%s'.\n\r',
skill_table[af->type].name );
send_to_char( buf, ch );
}
}
return;
}

in_room = ch->in_room;
if( IS_AFFECTED( ch, AFF_CONFUSION )
|| ( !IS_NPC( ch ) && number_bits( 7 )
< UMIN( 55, ch->pcdata->condition[COND_DRUNK] / 10 - 27 ) ) )
{
stumble = TRUE;
act( '&y$n stumbles and staggers wildly about.',
ch, NULL, NULL, TO_ROOM );
send_to_char( 'You trip over your own fool feet.\n\r', ch );
door = number_range( 0, 5 );
}

if( !( pexit = in_room->exit[door] ) || !( to_room = pexit->to_room ) )
{
if( stumble )
{
act( '$n whacks into a wall.', ch, NULL, NULL, TO_ROOM );
send_to_char( 'You run into a wall... Ow that hurt!\n\r', ch );
}
else
send_to_char( 'Alas, you cannot go that way.\n\r', ch );
return;
}

if( IS_SET( pexit->exit_info, EX_NOPLYR )
&& !IS_IMMORTAL( ch ) )
{
act( '$n hits a magical barrier.', ch, NULL, NULL, TO_ROOM );
send_to_char( 'You slam into a magical barrier... Ow that hurt!\n\r', ch );
return;
}

if( IS_SET( pexit->exit_info, EX_CLOSED ) )
{
if( !IS_AFFECTED( ch, AFF_PASS_DOOR )
&& !IS_SET( race_table[ch->race].race_abilities,
RACE_PASSDOOR ) )
{
if( stumble )
{
act( '$n whacks into a closed door.', ch, NULL, NULL, TO_ROOM );
send_to_char( 'You run into a door... Ow that hurt!\n\r', ch );
}

act( 'The $d is closed.',
ch, NULL, pexit->keyword, TO_CHAR );
return;
}

if( IS_SET( pexit->exit_info, EX_PASSPROOF )
&& !IS_IMMORTAL( ch ) )
{
if( stumble )
act( '$n whacks into a closed door.', ch, NULL, NULL, TO_ROOM );
act( 'You are unable to pass through the $d. Ouch!',
ch, NULL, pexit->keyword, TO_CHAR );
return;
}
}

if( IS_AFFECTED( ch, AFF_CHARM ) && ch->master
&& in_room == ch->master->in_room )
{
send_to_char( 'What? And leave your beloved master?\n\r', ch );
return;
}

if( ( to_room->area->plane->min_level > get_trust( ch )
|| ( !IS_NPC( ch ) && to_room->area != in_room->area
&& IS_SET( to_room->area->area_flags, AREA_HIDE ) ) )
&& !IS_BUILDER( ch, to_room->area ) )
{
send_to_char( '&rSomething holds you back from going there.&n\n\r', ch );
return;
}

if( room_is_private( to_room ) )
{
send_to_char( 'That room is private right now.\n\r', ch );
return;
}

if( !IS_NPC( ch ) )
{
int move;

if( door == DIR_UP && ( to_room->sector_type == SECT_AIR
|| in_room->sector_type == SECT_AIR )
&& !IS_SET( ch->body_parts, BODY_PART_WINGS )
&& !xIS_SET( ch->affected_by, AFF_FLYING )
&& !IS_SET( to_room->room_flags, ROOM_FALL ) )
{
send_to_char( 'You can't fly.\n\r', ch );
return;
}
if( to_room->sector_type == SECT_SPACE
&& !xIS_SET( ch->affected_by, AFF_FLYING )
&& !IS_SET( to_room->room_flags, ROOM_FALL ) )
{
send_to_char( 'You can't fly there.\n\r', ch );
return;
}

if( to_room->sector_type != SECT_WATER_NOSWIM
&& to_room->sector_type != SECT_UNDERWATER
&& !IS_SET( to_room->room_flags, ROOM_FLOODED )
&& !xIS_SET( ch->affected_by, AFF_FLYING )
&& !IS_SET( ch->body_parts, BODY_PART_TAIL )
&& !IS_SET( ch->body_parts, BODY_PART_WINGS )
&& !IS_SET( ch->body_parts, BODY_PART_LEGS ) )
{
send_to_char( 'You flap around but you cant move!\n\r', ch );
return;
}

if( in_room->sector_type == SECT_WATER_NOSWIM
|| to_room->sector_type == SECT_WATER_NOSWIM )
{
for( obj = ch->carrying; obj; obj = obj->next_content )
if( obj->item_type == ITEM_BOAT )
break;

/*
* Suggestion for flying above water by Sludge
*/
if( !obj && !IS_SET( ch->body_parts, BODY_PART_WINGS )
&& !xIS_SET( ch->affected_by, AFF_FLYING )
&& !IS_SET( race_table[ch->race].race_abilities, RACE_SWIM ) )
{
send_to_char( 'You need a boat to go there.\n\r', ch );
return;
}
}

if( ( in_room->sector_type == SECT_UNDERWATER
|| to_room->sector_type == SECT_UNDERWATER
|| IS_SET( in_room->room_flags, ROOM_FLOODED )
|| IS_SET( to_room->room_flags, ROOM_FLOODED ) )
&& !IS_SET( race_table[ch->race].race_abilities, RACE_SWIM )
&& !IS_AFFECTED( ch, AFF_BREATHING )
&& !IS_IMMORTAL( ch ) )
{
send_to_char( 'You need to be able to swim to go there.\n\r', ch );
return;
}

move = movement_loss[UMIN( SECT_MAX - 1, in_room->sector_type )]
+ movement_loss[UMIN( SECT_MAX - 1, to_room->sector_type )];
/*
* Flying persons lose constant minimum movement.
*/
if( IS_SET( ch->body_parts, BODY_PART_WINGS )
|| xIS_SET( ch->affected_by, AFF_FLYING ) )
move = 2;

if( ch->move < move )
{
if( !get_success( ch, gsn_stamina, 100 ) )
{
send_to_char( 'You are too exhausted.\n\r', ch );
return;
}
if( ch->hit < ch->max_hit / 3 )
{
send_to_char(
'Your body is too exhausted, '
'your tired muscles will move no more.\n\r', ch );
return;
}
send_to_char( 'You push your tired body past it's limits.\n\r', ch );
move -= ch->move;
ch->move = 0;
ch->hit -= move;
WAIT_STATE( ch, skill_table[gsn_stamina].beats );
}
else
{
if( IS_AFFECTED( ch, AFF_HASTE ) )
WAIT_STATE( ch, PULSE_PER_SECOND / 2 );
else
WAIT_STATE( ch, PULSE_PER_SECOND );
ch->move -= move;
}
}

if( !IS_AFFECTED( ch, AFF_SNEAK )
&& ( IS_NPC( ch ) || !xIS_SET( ch->act, PLR_WIZINVIS ) ) )
{
if( IS_NPC( ch ) )
REMOVE_BIT( SysInfo.flags, SYSINFO_ACT_TRIGGER );
if( ( ( in_room->sector_type == SECT_WATER_SWIM )
|| ( in_room->sector_type == SECT_UNDERWATER )
|| IS_SET( in_room->room_flags, ROOM_FLOODED ) )
&& ( ( to_room->sector_type == SECT_WATER_SWIM )
|| ( to_room->sector_type == SECT_UNDERWATER )
|| IS_SET( to_room->room_flags, ROOM_FLOODED ) ) )
act( '&g$n swims $T.', ch, NULL, dir_name[door], TO_ROOM );
else
{
if( stumble )
act( '&g$n staggers $T.', ch, NULL, dir_name[door], TO_ROOM );
if( !IS_NPC( ch ) && ch->pcdata->setmout
&& ch->pcdata->setmout[0] != '\0' )
act( '&g$n $t $T.', ch, ch->pcdata->setmout,
dir_name[door], TO_ROOM );
/* if ( IS_NPC( ch ) && pMob->mobmvemsg

&& pMob->mobmvemsg
[0] != '\0' )
act( '&g$n $t $T.', ch, pMob->mobmvemsg
,
dir_name[door], TO_ROOM ); MY CODE THAT PROB IS WRONG*/
else
act( '&g$n leaves $T.', ch, NULL, dir_name[door], TO_ROOM );
}
}

/*
* Leave program
*/
if( ch->in_room == in_room
&& xIS_SET( in_room->progtypes, LEAVE_PROG ) )
greet_leave_trigger( ch, NULL, in_room, NULL,
door, LEAVE_PROG );

for( vmob = in_room->people;
ch->in_room == in_room && vmob != NULL; vmob = vnext )
{
vnext = vmob->next_in_room;

if( !vmob->deleted && IS_NPC( vmob ) && ch != vmob
&& vmob->fighting == NULL && IS_AWAKE( vmob )
&& xIS_SET( vmob->pIndexData->progtypes, LEAVE_PROG ) )
greet_leave_trigger( ch, vmob, NULL, NULL, door,
LEAVE_PROG );
}

for( obj = in_room->contents;
ch->in_room == in_room && obj != NULL; obj = objnext )
{
objnext = obj->next_content;

if( !obj->deleted && !ch->deleted
&& xIS_SET( obj->pIndexData->progtypes, LEAVE_PROG ) )
greet_leave_trigger( ch, NULL, NULL, obj, door,
LEAVE_PROG );
}

/* Safety check, the character may have been deleted or moved by
the program. */
if( ch->deleted || ch->in_room != in_room )
return;

char_from_room( ch );
char_to_room( ch, to_room );

if( !IS_AFFECTED( ch, AFF_SNEAK )
&& ( IS_NPC( ch ) || !xIS_SET( ch->act, PLR_WIZINVIS ) ) )
{
if( IS_NPC( ch ) )
REMOVE_BIT( SysInfo.flags, SYSINFO_ACT_TRIGGER );
if( stumble )
act( '&g$n staggers in from the $T.',
ch, NULL, dir_name[rev_dir[door]], TO_ROOM );
else if( !IS_NPC( ch ) && ch->pcdata->setmin &&
ch->pcdata->setmin[0] != '\0' )
act( '&g$n $t $T.', ch, ch->pcdata->setmin,
dir_name[rev_dir[door]], TO_ROOM );
else
act( '&g$n has arrived from $t.', ch,
from_dir[rev_dir[door]], NULL, TO_ROOM );
}

/*
* Because of the addition of the deleted flag, we can do this -Kahn
*/
if( !IS_NPC( ch ) && !IS_IMMORTAL( ch ) )
{
if( to_room->sector_type == SECT_UNDERWATER
&& ch->race == race_lookup( 'vampire' ) )
{
send_to_char( 'Arrgh! Large body of water!\n\r', ch );
act( '$n thrashes underwater!', ch, NULL, NULL, TO_ROOM );
damage( ch, ch, 20, TYPE_UNDEFINED, WEAR_NONE );
}
else if( !IS_AFFECTED( ch, AFF_BREATHING )
&& to_room->sector_type == SECT_UNDERWATER
&& !IS_SET( ch->body_parts, BODY_PART_GILLS ) )
{
send_to_char( 'You can't breathe!\n\r', ch );
act( '$n sputters and chokes!', ch, NULL, NULL, TO_ROOM );
damage( ch, ch, ch->level + 5, gsn_breathing, WEAR_NONE );
}
else if( ch->in_room->sector_type == SECT_SPACE
&& !IS_AFFECTED( ch, AFF_BREATHING ) )
{
send_to_char( 'You can't breathe!\n\r', ch );
act( '$n can't breathe, $e is turning red!',
ch, NULL, NULL, TO_ROOM );
damage( ch, ch, ch->hit / 20 + 5,
gsn_breathing, WEAR_NONE );
}
}

/*
* Suggested by D'Sai from A Moment in Tyme Mud. Why have mobiles
* see the room? -Kahn
*/
if( ch->desc )
do_look( ch, AUTOLOOK );

/*
* Greet and Entry programs.
*/
if( IS_NPC( ch )
&& xIS_SET( ch->pIndexData->progtypes, ENTRY_PROG ) )
mprog_percent_check( ch, NULL, NULL, NULL, ENTRY_PROG );

if( ch->in_room == to_room )
{
if( ( xIS_SET( to_room->progtypes, ALL_GREET_PROG )
&& greet_leave_trigger( ch, NULL, to_room, NULL,
rev_dir[door], ALL_GREET_PROG ) == 0 )
|| ( xIS_SET( to_room->progtypes, GREET_PROG )
&& !IS_AFFECTED( ch, AFF_SNEAK )
&& greet_leave_trigger( ch, NULL, to_room, NULL,
rev_dir[door], GREET_PROG ) == 0 ) )
{
char_from_room( ch );
char_to_room( ch, in_room );
return;
}
}

for( vmob = to_room->people;
ch->in_room == to_room && vmob != NULL; vmob = vnext )
{
vnext = vmob->next_in_room;
if( vmob->deleted || !IS_NPC( vmob ) || ch == vmob )
continue;

if( IS_SET( spec_table[vmob->spec_fun].usage, SPEC_ENTER )
&& ( *spec_table[vmob->spec_fun].spec_fun )
( vmob, ch, SPEC_ENTER, NULL ) )
continue;

if( vmob->fighting == NULL && IS_AWAKE( vmob ) )
{
if( xIS_SET( vmob->pIndexData->progtypes, ALL_GREET_PROG ) )
greet_leave_trigger( ch, vmob, NULL, NULL, rev_dir[door],
ALL_GREET_PROG );
if( xIS_SET( vmob->pIndexData->progtypes, GREET_PROG )
&& !IS_AFFECTED( ch, AFF_SNEAK ) && can_see( vmob, ch ) )
greet_leave_trigger( ch, vmob, NULL, NULL, rev_dir[door],
GREET_PROG );
}
}

for( obj = to_room->contents;
ch->in_room == to_room && obj != NULL; obj = objnext )
{
objnext = obj->next_content;

if( obj->deleted || ch->deleted )
continue;

if( xIS_SET( obj->pIndexData->progtypes, ALL_GREET_PROG ) )
greet_leave_trigger( ch, NULL, NULL, obj, rev_dir[door],
ALL_GREET_PROG );
if( xIS_SET( obj->pIndexData->progtypes, GREET_PROG )
&& !IS_AFFECTED( ch, AFF_SNEAK ) )
greet_leave_trigger( ch, NULL, NULL, obj, rev_dir[door],
GREET_PROG );
}

/*
* Following.
*/
xSET_BIT( ch->act, moved );

for( fch = in_room->people; fch; fch = fch_next )
{
fch_next = fch->next_in_room;

if( fch->deleted )
continue;

if( fch->master == ch && fch->position > POS_RESTING )
{
if( fch->fighting )
act( '&rYou can't leave while you are still fighting.',
fch, NULL, NULL, TO_CHAR );
else
{
if( fch->position == POS_SITTING )
fch->position = POS_STANDING;

act( 'You follow $N.', fch, NULL, ch, TO_CHAR );
move_char( fch, door );
}
}
}

xREMOVE_BIT( ch->act, moved );
return;
}



5. RE: Code prob Mon Jun 28, 2004 [6:14 PM]
Jindrak
Email not supplied
member since: Jun 9, 2002
In Reply To
Reply
> for( af = ch->affected; af; af = af->next )
> {
> if( af->deleted || !xIS_SET( af->bitvector, AFF_HOLD )
> || af->duration < 0 ) continue;
> if( --af->duration == 0 )
> {
> affect_remove( ch, af );
> sprintf( buf, 'You are no longer held back by '%s'.\n\r',
> skill_table[af->type].name );
> send_to_char( buf, ch );
> }
> }
> return;
> }


Maybe it's just me, but it seems to me that having an affect handled like that in move_char() is a bit...stupid.
Legends of Hatred:
telnet://www.godwars.net:3500

GodWars: Legends (Upcoming GodWars 1996 Pure-PK):
http://www.facebook.com/CoC.Mud


6. RE: Code prob Mon Jun 28, 2004 [6:29 PM]
breck
Email not supplied
member since: Oct 8, 2003
In Reply To
Reply
if ( IS_NPC( ch ) && pMob->mobmvemsg &&
pMob->mobmvemsg[0] != '\0' )
act( '&g$n $t $T.', ch, pMob->mobmvemsg,
dir_name[door], TO_ROOM );


To me it looks like you'd want to still reference the mob usin ch. You're checking IS_NPC(ch)... So maybe try changing the refences to pMob to ch?

if ( IS_NPC(ch) && ch->mobmvemsg && ch->mobmvemsg[0] != '\0')

??

Good luck.




[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]