mud/lib/verbs/items/throw.c
2020-09-06 05:43:07 -07:00

86 lines
2.4 KiB
C

/* /verbs/items/throw.c
* from the NIghtmare IVr2 Object Library
* created by Descartes of Borg 951029
* Version: @(#) throw.c 1.3@(#)
* Last modified: 96/10/20
*/
#include <lib.h>
#include <rounds.h>
inherit LIB_VERB;
mixed do_throw_obj_word_obj(object what, string word, object where);
void eventThrow(object who, object what, object where);
static void create() {
verb::create();
SetVerb("throw");
SetSynonyms("toss");
SetRules("OBJ", "OBJ at OBJ", "OBJ into OBJ");
SetErrorMessage("Throw what?");
SetHelp("Syntax: <throw OBJ>\n"
" <throw OBJ at OBJ>\n"
" <throw OBJ into OBJ>\n\n"
"Allows you to throw an object. Some object you may also "
"use offensively by throwing them. Other places may simply "
"allow you to throw objects into them, say like throwing "
"equipment down to a friend in a chasm.\n"
"Note that throwing a weapon at someone will initiate "
"combat.\n\n"
"Synonyms: toss");
}
mixed can_throw_obj() {
if( this_player()->GetParalyzed() ) {
return "You cannot do anything.";
}
if(intp(check_light())) return this_player()->CanManipulate();
else return check_light();
}
mixed can_throw_obj_word_obj() {
return can_throw_obj();
}
mixed do_throw_obj(object ob) {
return do_throw_obj_word_obj(ob, 0, 0);
}
mixed do_throw_obj_word_obj(object what, string word, object where) {
object enemy;
object env = environment(this_player());
if( where && living(where) && what->GetClass() > 1 ) {
enemy = where;
}
else {
enemy = 0;
}
if(env && env->GetProperty("no attack")){
write("A mystical force prevents your malice.");
return 1;
}
if( this_player()->GetInCombat() || enemy ) {
this_player()->eventPrint("You prepare to throw " +
what->GetShort() + ".");
this_player()->SetAttack(enemy, (: eventThrow, this_player(), what,
where :), (enemy ? ROUND_WEAPON :
ROUND_OTHER));
return 1;
}
eventThrow(this_player(), what, where);
return 1;
}
void eventThrow(object who, object what, object where) {
if( !who ) {
return;
}
if( !what || environment(what) != who ) {
who->eventPrint("You no longer have anything to throw.");
return;
}
what->eventThrow(who, where);
}