#include <tasks.h>
// #include "/d/playtesters/effects/splints.h"
#define COST 50 /* placeholder gp cost for now */
#define SPLINT_OB "/d/guilds/witches/items/splint"
/* Which skills do we use? */
#define HEALING "magic.methods.physical.healing"
#define LEV_REQ 25
#define HEAL_DIF 120
#define WHIT "crafts.carpentry.whittling"
#define WHIT_DIF 50
#define MAX_TIME 3500 /* minus 120*6 = aprox 45 minutes */
#define MIN_TIME 600 /* 10 minutes */
#define SPLINT_EFF "dummy" // Doesn't exist.
inherit COMMAND_BASE;
varargs int cmd( object patient, string limb, string which, object
*withes, object *bandages ) {
int *bnums; /* break effect numbers */
string whose; /* for tidy messages */
object withe, bandage; /* individual wotsits */
string *breaks = ({ }); /* args of the break effects */
object splint; /* the splint item */
int time; /* time until break heals */
object *inv; /* patient's inventory */
/* Some playtesting checks - these will come out when it's in play */
if( !PLAYTESTERS_H->query_tester( this_player() ) ) {
add_failed_mess( "Here now, where'd you learn that? "
"You're not a playtester!\n" );
return 0;
}
if( !PLAYTESTERS_H->query_tester( patient ) &&
!creatorp(TP) ) {
add_failed_mess( patient->query_short() + " is not a playtester.\n" );
return 0;
}
if( patient == this_player() )
whose = "your";
else
whose = patient->query_short() + "'s";
this_player()->remove_hide_invis( "hiding" );
/* Has he really got a broken limb? */
/* Check for only the pt version of the break effects ...
*
bnums = patient->effects_matching( "body.damage." + limb +
".broken" );
*
* Use the above line once the effects are out of pt. */
bnums = patient->effects_matching( "body.damage." + limb +
".broken.pt" );
if( !sizeof( bnums ) ) {
add_failed_mess( sprintf( "%s %s doesn't need splinting.\n",
capitalize( whose ), limb ) );
return 0;
}
/* Did I specify which arm or leg I want to splint? */
foreach( int i in bnums )
breaks += ({ patient->arg_of( i ) });
if( !which )
which = breaks[ random( sizeof( breaks ) ) ];
if( member_array( which, breaks ) == -1 ) {
add_failed_mess( sprintf( "%s %s %s doesn't need splinting.\n",
capitalize( whose ), which, limb ) );
return 0;
}
/* I cannot bind a leg if my patient has things on his leg. */
if( limb == "leg" ) {
inv = all_inventory( patient );
foreach( object item in inv )
if( item->query_worn_by() && !item->id("splint") &&
member_array( item->query_type(),
({ "trousers", "garter" }) ) != -1 ) {
add_failed_mess( sprintf( "You can't splint %s leg with %s "
"in the way.\n", whose, patient == this_player() ?
item->poss_short() : patient->query_possessive() + " " +
item->query_short() ) );
return 0;
}
}
/* I cannot bind an arm if my patient has things on his arm. */
if( limb == "arm" ) {
inv = all_inventory( patient );
foreach( object item in inv )
if( item->query_worn_by() && !item->id("splint") &&
member_array( item->query_type(),
({ "shirt", "armband" }) ) != -1 ) {
add_failed_mess( sprintf( "You can't splint %s arm with %s "
"in the way.\n", whose, patient == this_player() ?
item->poss_short() : patient->query_possessive() + " " +
item->query_short() ) );
return 0;
}
}
/* Did I specify which things to use for making the splint? */
if( undefinedp( withes ) ) {
withes = match_objects_for_existence( "withes", ({this_player(), environment(this_player()) }));
}
if( undefinedp( bandages ) ) {
bandages = match_objects_for_existence( "bandages", ({this_player(), environment(this_player()) }));
}
/* Have I got enough withes and bandages? */
if( limb == "leg" ) { /* legs require 8 withes and 4 bandages */
if( sizeof( withes ) < 8 ) {
add_failed_mess( "You haven't got enough withes to fashion "
"a splint out of.\n" );
return 0;
}
withes = withes[0..7];
if( sizeof( bandages ) < 4 ) {
add_failed_mess( sprintf( "You haven't got enough bandages "
"to bind the splints to %s %s.\n", whose, limb ) );
return 0;
}
bandages = bandages[0..3];
}
if( limb == "arm" ) { /* arms require 5 withes and 3 bandages */
if( sizeof( withes ) < 5 ) {
add_failed_mess( "You haven't got enough withes to fashion "
"a splint out of.\n" );
return 0;
}
withes = withes[0..4];
if( sizeof( bandages ) < 3 ) {
add_failed_mess( sprintf( "You haven't got enough bandages "
"to bind the splints to %s %s.\n", whose, limb ) );
return 0;
}
bandages = bandages[0..2];
}
/* Have I got enough "magic" gp? */
if( this_player()->query_specific_gp( "magic" ) < COST ) {
add_failed_mess( sprintf( "You try to bind %s %s %s but can't "
"concentrate well enough.\n", whose, which, limb ) );
return 0;
}
else this_player()->adjust_gp( -COST );
/* I have a patient, the materials and the ability. Now I will
shape splints and bind them on with bandages */
/* 1) Shape splints: Whittling check (chance to tm). Some withes
may be consumed regardless of whether the command fails or
succeeds. */
foreach( withe in withes )
if( !random( 4 ) ) withe->move( "/room/rubbish" );
switch( TASKER->perform_task( this_player(), WHIT, WHIT_DIF,
TM_COMMAND ) ) {
case FAIL :
tell_room( environment( this_player() ),
this_player()->the_short() + " attempts to fashion some "
"willow withes into a useable splint but makes a mess of "
"the job.\n", ({ this_player() }) );
add_failed_mess( "You attempt to fashion the withes into a "
"useable splint but make a mess of the job.\n" );
return 0;
case AWARD :
write( "%^YELLOW%^You find yourself more able to "
"whittle.%^RESET%^\n" );
case SUCCEED :
write( "You fashion the withes into a useable splint.\n" );
}
/* 2) bind the splints to his leg with bandages - healing
check - chance to tm */
patient->remove_hide_invis( "hiding" );
patient->set_position( "sitting" );
switch( TASKER->perform_task( this_player(), HEALING, HEAL_DIF,
TM_COMMAND ) ) {
case FAIL :
tell_room( environment( this_player() ),
this_player()->the_short() + " attempts to splint and bind "
+ ( patient == this_player() ? patient->query_possessive() :
patient->the_short() + "'s" ) + " " + limb + " but makes a "
"mess of the job.\n", ({ this_player(), patient }) );
if( patient != this_player() )
tell_object( patient, this_player()->the_short() +
" attempts to splint and bind your " + limb +
" but makes a mess of the job.\n" );
add_failed_mess( sprintf( "You attempt to splint and bind "
"%s %s but make a mess of the job.\n", whose, limb ) );
return 0;
case AWARD :
write( "%^YELLOW%^You manage to grasp the principles of "
"practical healing more firmly.%^RESET%^\n" );
case SUCCEED :
write( sprintf( "You bind the splints tightly to %s %s with "
"the bandages.\n", whose, limb ) );
}
/* Get rid of all the remaining withes and bandages */
foreach( withe in withes )
withe->move( "/room/rubbish" );
foreach( bandage in bandages )
bandage->move( "/room/rubbish" );
/* Remove patient's broken limb and replace it with a splinted
one. */
/* subtract 6 * healing bonus from MAX_TIME - this is how many
seconds until break heals. If this is less than MIN_TIME,
use MIN_TIME instead */
time = this_player()->query_skill_bonus( HEALING ) * 6;
time = MAX_TIME - time;
time = time < MIN_TIME ? MIN_TIME : time;
patient->add_effect( SPLINT_EFF + limb, ({ which, time, 0 }) );
splint = clone_object( SPLINT_OB );
splint->set_limb( ({ which, limb }) );
splint->move( patient );
patient->wear_armour( splint );
/* This works because there will only ever be one effect
* per limb */
foreach( int i in bnums )
if( patient->arg_of( i ) == which )
patient->delete_effect( i );
write( sprintf( "You splint %s %s %s.\n", whose, which, limb ) );
if( patient != this_player() )
tell_object( patient, sprintf( "%s fashions a splint out of "
"willow withes and binds it to your %s %s with bandages.\n",
this_player()->the_short(), which, limb ) );
tell_room( environment( this_player() ), sprintf( "%s fashions "
"a splint out of willow withes and binds it to %s %s %s with "
"bandages.\n", this_player()->the_short(), patient ==
this_player() ? this_player()->query_possessive() :
patient->the_short() + "'s", which, limb ),
({ this_player(), patient }) );
return 1;
}
mixed *query_patterns() {
return ({
"my {leg|arm}",
(: cmd( $( this_player() ), $4[0] ) :),
"my <string'side'> {leg|arm}",
(: cmd( $( this_player() ), $4[1], $4[0] ) :),
"my {leg|arm} with <indirect:object:me-here'withes'> and "
"<indirect:object:me-here'bandages'>",
(: cmd ( $( this_player() ), $4[0], 0, $1[0], $1[1] ) :),
"my <string'side'> {leg|arm} with <indirect:object:me-here'withes'> "
"and <indirect:object:me-here'bandages'>",
(: cmd( $( this_player() ), $4[1], $4[0], $1[0], $1[1] ) :),
"<indirect:living:here'name'> {leg|arm}",
(: cmd( $1[0], $4[1] ) :),
"<indirect:living:here'name'> <string'side'> {leg|arm}",
(: cmd( $1[0], $4[2], $4[1] ) :),
"<indirect:living:here'name'> {leg|arm} with <indirect:object:me-here"
"'withes'> and <indirect:object:me-here'bandages'>",
(: cmd( $1[0][0], $4[1], 0, $1[1], $1[2] ) :),
"<indirect:living:here'name'> <string'side'> {leg|arm} with "
"<indirect:object:me-here'withes'> and <indirect:object:me-here"
"'bandages'>",
(: cmd( $1[0][0], $4[2], $4[1], $1[1], $1[2] ) :)
});
}