- Posts: 37
- Thank you received: 3
Please Log in or Create an account to join the conversation.
wifidi wrote: Dear tbaMUDers,
I've tried coding relative north movement without suceeding. Two versions of the idea are only north moves the character forward in the direction the character has spun to (relative north) or movement in a direction becomes relative north. Here's some basic code that experiences runtime errors:
structs.h 997:
int facing; /**< Cardinal direction of ch. */
// bool relspin; /**< Char moves forward, up, down, or spins left, right or 180. */
// bool relwalk; /**< Direction char moves becomes relative north. */
struct.h 1029:
//struct char_data = {.relspin = false, .relwalk = false};
act.h 146:
/** Relative north. */
#define FACING ((ch)->facing)
//#define RELSPIN ((ch)->relspin)
//#define RELWALK ((ch)->relwalk)
act.movement.c 31:
void player_spins_char(struct char_data *ch, int dir);
act.movement.c 114:
/* Player spins character. */
void player_spins_char(struct char_data *ch, int dir)
{
switch (dir)
{
case (EAST):
{
FACING++;
if (FACING == 4) FACING = 0;
}
case (SOUTH):
{
FACING += 2;
if (FACING == 4) FACING = 0;
if (FACING == 5) FACING = 1;
}
case (WEST):
{
FACING--;
if (FACING == -1) FACING = 3;
}
}
}
act.movement.c 163:
/* ... and the room the character will move into. */
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* must check for relative north walking modes to properly designate
* the proposed room */
/* relative north walking mode 1:
* east, west and south only spin the character */
* autoexit toggle piggybacked in lieu of PRF_RELATIVE_NORTH_WALKING_MODE_1 */
if (PRF_FLAGGED(ch, PRF_AUTOEXIT)
&& (dir == EAST || dir == SOUTH || dir == WEST))
{
player_spins_char(ch, dir);
return 0;
}
/* relative north walking mode 2:
* east, west and south spin and move the char in that direction, and
* that direction becomes relative north
* autoloot toggle piggybacked in lieu of PRF_RELATIVE_NORTH_WALKING_MODE_2 */
else if (PRF_FLAGGED(ch, PRF_AUTOLOOT)
&& (dir == EAST || dir == SOUTH || dir == WEST))
player_spins_char(ch, dir);
else FACING = dir;
room_rnum going_to = EXIT(ch, FACING)->to_room;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I've got it working with a C++ version of Merc probably because I'm in a C++ course at the moment. It's a cool idea that runs the risk of not living up to how cool it is due to programmers about as skilled as me.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
tbaMUD © 2024