Welcome to the Builder Academy

Question Fly and Land

More
25 Jan 2013 11:31 - 25 Jan 2013 11:31 #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

Code:
/* 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: 25 Jan 2013 11:31 by zusuk. Reason: forgot code[] tag

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

More
25 Jan 2013 23:03 #1398 by Liko
Replied by Liko on topic Re: 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

Code:
/* 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.

Randian(0.0.0)
Owner/Developer

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

More
05 Feb 2013 04:28 - 05 Feb 2013 04:29 #1456 by Nerian
Replied by Nerian on topic Re: Fly and Land
This is my final outcome for my fly and land commands

Code:
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: 05 Feb 2013 04:29 by Nerian.

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

Time to create page: 0.167 seconds