do_throw_at |
Discworld object help |
do_throw_at |
Name
do_throw_at - Function to calculate damage done when object is thrown.
Syntax
do_throw_at(object *in_dir, string direct, string indirect, mixed *args,
string format)
Description
If this function exists in an object, then when that object is thrown at someone, it will be called. It should calculate wether or not the object hit the target, and how much damage it did. It should return 0 if it failed to hit, or the damage done. You must NOT do the damage, it will be done be the command throw. The arguments are exactly the same as those passed from add_command, so look at the docs on add_command for a complete explaination of them, however they are not going to be that difficult. I'll give an example. Say the player type 'throw daggers at dwarf' then the function do_throw_at() is going to get called in each dagger with the arguments being as follows:
in_dir = ({ dwarf });
direct = "daggers";
indirect = "dwarf";
args = ({ "daggers", "dwarf" });
format = "%D 'at' %I";
See also
do_throw_to command_control
Example
inherit "/std/object";
void setup() {
set_name("rock");
set_short("radioactive rock");
set_adjective("radioactive");
set_long("It's a small radioactive rock.\n");
} /* setup */
do_throw_at(object *in_dir, string direct, string indirect, mixed *args,
string format) {
int skill;
skill = this_player()->query_skill_bonus("fighting.throw");
if(skill < 40)
return 0; /* throw failed, no damage done */
return skill/5 /* throw succed, skill/5 damage done */
}