Fly and Land

  • zusuk
  • zusuk's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
5 years 8 months ago - 5 years 8 months ago #1396 by zusuk
Fly and Land was created by zusuk
Someone requested this code, so I thought I'd share it. It is for a simple fly and land command.

1) Add the ACMD(do_fly) and ACMD(do_land) into act.h
2) Add the commands into the interpreter.c master command list
3) Add the following code into act.other.c

/* a generic command to get rid of a fly flag */
ACMD(do_land)
{  
  bool msg = FALSE;

  if (affected_by_spell(ch, SPELL_FLY)) {
    affect_from_char(ch, SPELL_FLY);
    msg = TRUE;
  }

  if AFF_FLAGGED(ch, AFF_FLYING) {
    REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_FLYING);
    msg = TRUE;
  }

  if (msg) {
    send_to_char(ch, "You land on the ground.\r\n");
    act("$n lands on the ground.", TRUE, ch, 0, 0, TO_ROOM);    
  } else {
    send_to_char(ch, "You are not flying.\r\n");  
  }
}


/* The command to use your innate ability to fly */
ACMD(do_fly)
{

  /* You would add any racial/class/skill restrictions here */
  if (GET_RACE(ch) != RACE_xxx) {
    send_to_char(ch, "You don't have this ability.\r\n");
    return;
  }

  /* alternatively you could just set the AFF_FLY on */
  call_magic(ch, ch, NULL, SPELL_FLY, GET_LEVEL(ch), CAST_SPELL);
}

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100
Last edit: 5 years 8 months ago by zusuk. Reason: forgot code[] tag

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #1398 by Liko
Replied by Liko on topic Fly and Land

zusuk wrote: Someone requested this code, so I thought I'd share it. It is for a simple fly and land command.

1) Add the ACMD(do_fly) and ACMD(do_land) into act.h
2) Add the commands into the interpreter.c master command list
3) Add the following code into act.other.c

/* a generic command to get rid of a fly flag */
ACMD(do_land)
{  
  bool msg = FALSE;

  if (affected_by_spell(ch, SPELL_FLY)) {
    affect_from_char(ch, SPELL_FLY);
    msg = TRUE;
  }

  if AFF_FLAGGED(ch, AFF_FLYING) {
    REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_FLYING);
    msg = TRUE;
  }

  if (msg) {
    send_to_char(ch, "You land on the ground.\r\n");
    act("$n lands on the ground.", TRUE, ch, 0, 0, TO_ROOM);    
  } else {
    send_to_char(ch, "You are not flying.\r\n");  
  }
}


/* The command to use your innate ability to fly */
ACMD(do_fly)
{

  /* You would add any racial/class/skill restrictions here */
  if (GET_RACE(ch) != RACE_xxx) {
    send_to_char(ch, "You don't have this ability.\r\n");
    return;
  }

  /* alternatively you could just set the AFF_FLY on */
  call_magic(ch, ch, NULL, SPELL_FLY, GET_LEVEL(ch), CAST_SPELL);
}


I simply have it so they just type fly again so they land.

DragonBall: Tournament (1.2.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago - 5 years 7 months ago #1456 by Nerian
Replied by Nerian on topic Fly and Land
This is my final outcome for my fly and land commands

ACMD(do_fly) {
		if (HAS_FEAT(ch, FEAT_WINGS)) {
			if AFF_FLAGGED(ch, AFF_FLYING) {
				send_to_char(ch, "You are already flying.\r\n");
				return;
		}	else
			SET_BIT_AR(AFF_FLAGS(ch), AFF_FLYING);
			send_to_char(ch, "You launch yourself into the air. \r\n");
			act("$n launches themselves into the air. \r\n", TRUE, ch, 0, NULL, TO_ROOM);
			GET_POS(ch) = POS_FLYING;
	}
	else
		send_to_char(ch, "You don't have the ability to fly. \r\n");
		
}

ACMD(do_land) 
{
bool msg = FALSE;

	if (affected_by_spell(ch, SPELL_FLY)) 
	{
	affect_from_char(ch, SPELL_FLY);
        GET_POS(ch) = POS_STANDING;
	msg = TRUE;
	}
	
	if AFF_FLAGGED(ch, AFF_FLYING) 
	{
	REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_FLYING);
        GET_POS(ch) = POS_STANDING;
	msg = TRUE;
	}
	
	if (msg)
	{
	send_to_char(ch, "You land on the ground. \r\n");
	act("$n lands on the ground and stops flying.", TRUE, ch, 0, 0, TO_ROOM);
	}
		else
		{
		send_to_char(ch, "You are not flying.\r\n");
		}
}

in my interpreter file I had the position requirement for the land command to be POS_FLYING
Last edit: 5 years 7 months ago by Nerian.

Please Log in or Create an account to join the conversation.

Time to create page: 1.014 seconds