Posted by
| Dace K
Canada (169 posts) Bio
|
Message
| Jeez, what's up your ass, Gatewaysysop? I gave step by step instructions on what to do, which is far more than what I got when I was learning to code
My mistake apparently is assuming that anyone posting on a coding board knows basic coding already, so I just told him which functions to use.
Silly silly me.
Here's an example of what I was talking about. I just hacked this together in about 5 minutes, and haven't even tested if it'll compile. It's at least a nice start though, and it *should* work, unless I missed something stupid.
/*Silly little throw - Dace K*/
void do_throw( CHAR_DATA *ch, char *argument)
{
CHAR_DATA *victim, *vch;
EXIT_DATA *pexit;
ROOM_INDEX_DATA *was_in_room;
OBJ_DATA *obj;
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char temp[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
sh_int dir = -1, dist = 0, color = AT_GREY;
char *dtxt = "somewhere";
char *stxt = "thrown item";
argument = one_argument(argument, arg);
argument = one_argument(argument, arg2);
if ( arg1[0] == '\0' )
{
send_to_char( "Throw what where? At who?\n\r", ch );
return rNONE;
}
victim = NULL;
if ( ms_find_obj(ch) )
return;
if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
{
send_to_char( "You do not have that item.\n\r", ch );
return;
}
/*Insert checks for itemtypes you don't want throwable here*/
/* get an exit or a victim */
if ( (pexit = find_door(ch, arg2, TRUE)) == NULL )
{
if ( (victim=get_char_room(ch, arg2)) == NULL )
{
send_to_char( "Throw in what direction?\n\r", ch );
return rNONE;
}
else
{
/* Uncomment if you don't want people throwing at fight-engaged*
if ( who_fighting(ch) == victim )
{
send_to_char( "They are too close to release that type of attack!\n\r", ch );
return rNONE;
} */
}
}
else
dir = pexit->vdir;
/* check for ranged attacks from private rooms, etc */
if ( !victim )
{
if ( IS_SET(ch->in_room->room_flags, ROOM_PRIVATE)
|| IS_SET(ch->in_room->room_flags, ROOM_SOLITARY) )
{
send_to_char( "You cannot throw an object from a private room.\n\r", ch );
return rNONE;
}
if ( ch->in_room->tunnel > 0 )
{
count = 0;
for ( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
++count;
if ( count >= ch->in_room->tunnel )
{
send_to_char( "This room is too cramped to perform such an attack.\n\r", ch );
return rNONE;
}
}
}
if ( pexit && !pexit->to_room )
{
send_to_char( "Are you expecting to throw through a wall!?\n\r", ch );
return rNONE;
}
/* Check for obstruction */
if ( pexit && IS_SET(pexit->exit_info, EX_CLOSED) )
{
if ( IS_SET(pexit->exit_info, EX_SECRET)
|| IS_SET(pexit->exit_info, EX_DIG) )
send_to_char( "Are you expecting to throw through a wall!?\n\r", ch );
else
send_to_char( "Are you expecting to throw through a door!?\n\r", ch );
return rNONE;
}
vch = NULL;
if ( pexit && arg1[0] != '\0' )
{
if ( (vch=scan_for_victim(ch, pexit, arg1)) == NULL )
{
send_to_char( "You cannot see your target.\n\r", ch );
return rNONE;
}
/* don't allow attacks on mobs stuck in another area?
if ( IS_NPC(vch) && xIS_SET(vch->act, ACT_STAY_AREA)
&& ch->in_room->area != vch->in_room->area) )
{
}
*/
/*don't allow attacks on mobs that are in a no-missile room --Shaddai */
if ( IS_SET(vch->in_room->room_flags, ROOM_NOMISSILE) )
{
send_to_char( "You can't get a clean shot off.\n\r", ch );
return rNONE;
}
/* Taken out cause of wait state
if ( !IS_NPC(ch) && !IS_NPC(vch) )
{
send_to_char("Pkill like a real pkiller.\n\r", ch );
return rNONE;
}
*/
/* can't properly target someone heavily in battle */
if ( vch->num_fighting > max_fight(vch) )
{
send_to_char( "There is too much activity there for you to get a clear shot.\n\r", ch );
return rNONE;
}
}
if ( vch ) {
if ( !IS_NPC( vch ) && !IS_NPC( ch ) &&
xIS_SET(ch->act, PLR_NICE ) )
{
send_to_char( "Your too nice to do that!\n\r", ch );
return rNONE;
}
if ( vch && is_safe(ch, vch, TRUE) )
return rNONE;
}
was_in_room = ch->in_room;
separate_obj(obj);
if ( pexit )
{
act( AT_GREY, "You throw $p $T.", ch, obj, dir_name[dir], TO_CHAR );
act( AT_GREY, "$n throw $p $T.", ch, obj, dir_name[dir], TO_ROOM );
}
else
{
act( AT_GREY, "You throw $p at $N.", ch, obj, victim, TO_CHAR );
act( AT_GREY, "$n throws $p at $N.", ch, obj, victim, TO_NOTVICT );
act( AT_GREY, "$n throws $p at you!", ch, obj, victim, TO_VICT );
}
}
/* victim in same room */
if ( victim )
{
check_illegal_pk( ch, victim );
check_attacker( ch, victim );
ranged_got_target( ch, victim, NULL, obj,
0, TYPE_HIT, stxt, color );
}
/* assign scanned victim */
victim = vch;
/* reverse direction text from move_char */
dtxt = rev_exit(pexit->vdir);
while ( dist <= range )
{
char_from_room(ch);
char_to_room(ch, pexit->to_room);
if ( IS_SET(pexit->exit_info, EX_CLOSED) )
{
/* whadoyahknow, the door's closed */
sprintf(buf, "You see your %s hit a door in the distance to the %s.",
short_descr, dir_name[dir] );
act( color, buf, ch, NULL, NULL, TO_CHAR );
sprintf(buf, "%s flies in from %s and smashes into the %sern door.",
obj->short_descr, dtxt, dir_name[dir] );
buf[0] = UPPER(buf[0]);
act( color, buf, ch, NULL, NULL, TO_ROOM );
break;
}
|
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com | Top |
|