nightmare3_fluffos_v2/
nightmare3_fluffos_v2/bin/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/ChangeLog.old/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/Win32/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/simuls/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/clone/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/command/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/data/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/etc/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/master/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/log/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/compiler/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/efuns/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/operators/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/u/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/tmp/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/windows/
nightmare3_fluffos_v2/lib/cmds/ambassador/
nightmare3_fluffos_v2/lib/cmds/database/
nightmare3_fluffos_v2/lib/cmds/hm/
nightmare3_fluffos_v2/lib/cmds/soul/
nightmare3_fluffos_v2/lib/daemon/cfg/
nightmare3_fluffos_v2/lib/daemon/cfg/mon_races/
nightmare3_fluffos_v2/lib/daemon/cfg/races/
nightmare3_fluffos_v2/lib/daemon/include/
nightmare3_fluffos_v2/lib/daemon/save/
nightmare3_fluffos_v2/lib/daemon/services/
nightmare3_fluffos_v2/lib/daemon/soul/
nightmare3_fluffos_v2/lib/doc/
nightmare3_fluffos_v2/lib/doc/TestPlans/
nightmare3_fluffos_v2/lib/doc/approval/
nightmare3_fluffos_v2/lib/doc/approval/QC/
nightmare3_fluffos_v2/lib/doc/approval/balance/
nightmare3_fluffos_v2/lib/doc/build/
nightmare3_fluffos_v2/lib/doc/build/armours/
nightmare3_fluffos_v2/lib/doc/build/economy/
nightmare3_fluffos_v2/lib/doc/build/etc/
nightmare3_fluffos_v2/lib/doc/build/monster/
nightmare3_fluffos_v2/lib/doc/build/room/
nightmare3_fluffos_v2/lib/doc/build/virtual/
nightmare3_fluffos_v2/lib/doc/build/weapon/
nightmare3_fluffos_v2/lib/doc/classes/
nightmare3_fluffos_v2/lib/doc/efun/
nightmare3_fluffos_v2/lib/doc/etc/
nightmare3_fluffos_v2/lib/doc/help/creator/
nightmare3_fluffos_v2/lib/doc/help/hm/
nightmare3_fluffos_v2/lib/doc/law/
nightmare3_fluffos_v2/lib/doc/lpc/basic/
nightmare3_fluffos_v2/lib/doc/lpc/data_types/
nightmare3_fluffos_v2/lib/doc/lpc/etc/
nightmare3_fluffos_v2/lib/doc/lpc/intermediate/
nightmare3_fluffos_v2/lib/doc/lpc/types/
nightmare3_fluffos_v2/lib/doc/mudlib/
nightmare3_fluffos_v2/lib/doc/mudlib/features/
nightmare3_fluffos_v2/lib/domains/Examples/etc/
nightmare3_fluffos_v2/lib/domains/Examples/room/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaA/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaB/
nightmare3_fluffos_v2/lib/domains/Examples/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/
nightmare3_fluffos_v2/lib/domains/Praxis/adm/
nightmare3_fluffos_v2/lib/domains/Praxis/attic/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/mon/
nightmare3_fluffos_v2/lib/domains/Praxis/data/
nightmare3_fluffos_v2/lib/domains/Praxis/death/
nightmare3_fluffos_v2/lib/domains/Praxis/mountains/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/armour/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/magic/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/orc_valley/
nightmare3_fluffos_v2/lib/domains/Praxis/quests/
nightmare3_fluffos_v2/lib/domains/Praxis/standardOld/
nightmare3_fluffos_v2/lib/include/
nightmare3_fluffos_v2/lib/log/
nightmare3_fluffos_v2/lib/log/errors/
nightmare3_fluffos_v2/lib/log/reports/
nightmare3_fluffos_v2/lib/log/watch/
nightmare3_fluffos_v2/lib/news/
nightmare3_fluffos_v2/lib/secure/cfg/
nightmare3_fluffos_v2/lib/secure/cmds/ambassador/
nightmare3_fluffos_v2/lib/secure/cmds/mortal/
nightmare3_fluffos_v2/lib/secure/save/users/d/
nightmare3_fluffos_v2/lib/secure/std/
nightmare3_fluffos_v2/lib/std/hm/
nightmare3_fluffos_v2/lib/std/living/
nightmare3_fluffos_v2/lib/std/room/
nightmare3_fluffos_v2/lib/std/user/
nightmare3_fluffos_v2/lib/std/virtual/
nightmare3_fluffos_v2/lib/www/
nightmare3_fluffos_v2/lib/www/errors/
nightmare3_fluffos_v2/lib/www/gateways/
nightmare3_fluffos_v2/win32/
//	/std/fish_room.c
//	from the Nightmare mudlib
//	an inheritable fishing room originally created for IgorMud
//	created and written by Descartes of Borg 03 september 1992
//	modified significantly 10 february 1993
//      minor changes 5 november 1993

#define FISH ([ "mackeral":3, "blue fish":5, "flounder":12, "marlin":20, "swordfish":30 ])

#include <std.h>

inherit ROOM;

mapping fishing, fish;
int max_catch, chance, caught, max_fishing;

int stop_fishing(string str);
void catch_anything(string who);
void still_fishing(string who);
void caught_something(string who);
void give_player_a_fish(string who, string fish_name, int strength);
int pole_breaks(int wt, string who);
void snap(string who);

void init() {
    ::init();
    add_action("go_fish", "fish");
    add_action("dropped_the_pole", "drop");
    add_action("stop_fishing", "stop");
}

int go_fish() {
    object ob;

    if(!fishing) fishing = ([]);
    ob = present("fishing pole", this_player());
    if(!ob) {
	notify_fail("You really need something to fish with!\n");
	return 0;
    }
    if(ob->query_broken()) {
	notify_fail("You cannot fish while your "+(string)ob->query_name()+
	    " is broken!\n");
	return 0;
    }

    if(this_player()->query_current_attacker()) {
      notify_fail("You are too busy to fish right now.\n");
      return 0;
    }

    if(fishing[(string)this_player()->query_name()]) {
	notify_fail("You are already fishing!\n");
	return 0;
    }
    if(max_fishing <= sizeof(fishing)) {
	write("The area is simply too crowded with people fishing right now.");
	say(this_player()->query_cap_name()+" is unable to find a spot to fish.", this_player());
	return 1;
    }
    write("You cast your "+(string)ob->query_name()+" into the water and start fishing.");
    say(this_player()->query_cap_name()+" casts "+(string)this_player()->query_possessive()+
	" "+(string)ob->query_name()+" into the water.", this_player());
    fishing[(string)this_player()->query_name()] = ob;
    call_out("catch_anything", 10, (string)this_player()->query_name());
    return 1;
}

int dropped_the_pole(string str) {
    if(!fishing) return 0;
    if(!fishing[(string)this_player()->query_name()]) return 0;
    if(!fishing[(string)this_player()->query_name()]->id(str)) return 0;
    if(stop_fishing("fishing")) return 0;
    else {
	write("You cannot drop it!");
	return 1;                /* Why would this happen? */
    }
}

int stop_fishing(string str) {
    if(!str || str != "fishing") return 0;
    if(!fishing) {
	notify_fail("You are not fishing!\n");
	return 0;
    }
    if(!fishing[(string)this_player()->query_name()]) {
	notify_fail("You are not fishing!\n");
	return 0;
    }
    map_delete(fishing, (string)this_player()->query_name());
    write("You stand up and pull in your line.");
    say(this_player()->query_cap_name()+" gives up on fishing for now.", this_player());
    return 1;
}

void catch_anything(string who) {
    int bait, str_class;

    if(!who) return;        /* how in hell did this happen? */
    if(!present(who)) map_delete(fishing, who);
    if(!fishing[who]) return;
    bait = (int)fishing[who]->query_bait();
    str_class = (int)fishing[who]->query_pole_class();
    if( (caught == max_catch) || (random(101) > chance+str_class+bait) ) 
	still_fishing(who);
    else caught_something(who);
}

void still_fishing(string who) {
    tell_object(present(who), "You pull in your line and cast again, hoping for better luck this time.");
    tell_room(this_object(), this_player()->query_cap_name()+" pulls in "+(string)this_player()->query_possessive()+
	" line and then casts again.", ({ present(who) }));
    call_out("catch_anything", 10, who);
}

void caught_something(string who) {
    string fish_name;

    if(!fish) fish = FISH;
    fish_name = keys(fish)[random(sizeof(fish))];
    tell_object(present(who), "Suddenly you feel something tug at your "+
	(string)fishing[who]->query_name()+"!");
    tell_object(present(who), "You see a "+fish_name+" fighting on your hook!");
    tell_room(this_object(), "Something tugs at "+present(who)->query_cap_name()+"'s line!",
	({ present(who) }) );
    tell_room(this_object(), present(who)->query_cap_name()+" has hooked a "+
	fish_name+"!", ({ present(who) }) );
    give_player_a_fish(who, fish_name, fish[fish_name]);
}

void give_player_a_fish(string who, string fish_name, int strength) {
    object this_catch;

    if(!pole_breaks(strength, who)) {
	this_catch = new("std/food");
	this_catch->set_name(fish_name);
	this_catch->set_id( ({ "fish", fish_name }) );
 	this_catch->set_short(capitalize(fish_name));
	this_catch->set_long("A fish caught by a fisher of Nightmare!\n");
        this_catch->set_strength(strength);
	this_catch->set_value(0);
	this_catch->set_destroy();
        this_catch->set_weight(50);
	if(this_catch->move(present(who))) this_catch->move(this_object());
    }
    else snap(who);
    fishing[who]->unbait();
    caught ++;
    map_delete(fishing, who);
}

int pole_breaks(int wt, string who) {
    int max_wt, str_class;

    str_class = (int)fishing[who]->query_pole_class();
    max_wt = (str_class - 1) * (str_class - 1);
    if(max_wt < wt) return 1;
    else return 0;
}

void snap(string who) {
    fishing[who]->break_pole();
    tell_object(present(who), "The fish is so big, it breaks your "+
	(string)fishing[who]->query_name()+"!");
    tell_room(this_object(), present(who)->query_cap_name()+" catches a fish "+
	"so big that it breaks "+(string)present(who)->query_possessive()+
	" "+(string)fishing[who]->query_name()+"!", ({present(who)}));
}

void set_max_fishing(int x) {
    if(x>10) x=10;
    max_fishing = x;
}

int query_max_fishing() { return max_fishing; }

void set_chance(int x) { 
    if(x > 20) x=20;
    chance = x;
}

int query_chance() { return chance; }

void set_max_catch(int x) { max_catch = x; }

int query_max_catch() { return max_catch; }

void set_fish(mapping borg) { fish = borg; }

mapping query_fish() { return fish; }

void add_fish(string nom, int x) {
    if(!fish) fish = ([]);
    fish[nom] = x;
}