ds3.0/bin/
ds3.0/extra/
ds3.0/extra/crat/
ds3.0/extra/creremote/
ds3.0/extra/mingw/
ds3.0/extra/wolfpaw/
ds3.0/fluffos-2.18-ds07/
ds3.0/fluffos-2.18-ds07/Win32/
ds3.0/fluffos-2.18-ds07/compat/
ds3.0/fluffos-2.18-ds07/compat/simuls/
ds3.0/fluffos-2.18-ds07/testsuite/
ds3.0/fluffos-2.18-ds07/testsuite/clone/
ds3.0/fluffos-2.18-ds07/testsuite/command/
ds3.0/fluffos-2.18-ds07/testsuite/data/
ds3.0/fluffos-2.18-ds07/testsuite/etc/
ds3.0/fluffos-2.18-ds07/testsuite/include/
ds3.0/fluffos-2.18-ds07/testsuite/inherit/
ds3.0/fluffos-2.18-ds07/testsuite/inherit/master/
ds3.0/fluffos-2.18-ds07/testsuite/log/
ds3.0/fluffos-2.18-ds07/testsuite/single/
ds3.0/fluffos-2.18-ds07/testsuite/single/tests/compiler/
ds3.0/fluffos-2.18-ds07/testsuite/single/tests/efuns/
ds3.0/fluffos-2.18-ds07/testsuite/single/tests/operators/
ds3.0/fluffos-2.18-ds07/testsuite/u/
ds3.0/fluffos-2.18-ds07/tmp/
ds3.0/lib/cmds/admins/
ds3.0/lib/cmds/common/
ds3.0/lib/cmds/creators/include/
ds3.0/lib/daemon/services/
ds3.0/lib/daemon/tmp/
ds3.0/lib/doc/
ds3.0/lib/doc/bguide/
ds3.0/lib/doc/efun/all/
ds3.0/lib/doc/efun/arrays/
ds3.0/lib/doc/efun/buffers/
ds3.0/lib/doc/efun/compile/
ds3.0/lib/doc/efun/floats/
ds3.0/lib/doc/efun/functions/
ds3.0/lib/doc/efun/mixed/
ds3.0/lib/doc/efun/numbers/
ds3.0/lib/doc/efun/parsing/
ds3.0/lib/doc/help/classes/
ds3.0/lib/doc/help/races/
ds3.0/lib/doc/lfun/
ds3.0/lib/doc/lfun/all/
ds3.0/lib/doc/lfun/lib/abilities/
ds3.0/lib/doc/lfun/lib/armor/
ds3.0/lib/doc/lfun/lib/bank/
ds3.0/lib/doc/lfun/lib/bot/
ds3.0/lib/doc/lfun/lib/clay/
ds3.0/lib/doc/lfun/lib/clean/
ds3.0/lib/doc/lfun/lib/clerk/
ds3.0/lib/doc/lfun/lib/client/
ds3.0/lib/doc/lfun/lib/combat/
ds3.0/lib/doc/lfun/lib/connect/
ds3.0/lib/doc/lfun/lib/container/
ds3.0/lib/doc/lfun/lib/corpse/
ds3.0/lib/doc/lfun/lib/creator/
ds3.0/lib/doc/lfun/lib/daemon/
ds3.0/lib/doc/lfun/lib/damage/
ds3.0/lib/doc/lfun/lib/deterioration/
ds3.0/lib/doc/lfun/lib/donate/
ds3.0/lib/doc/lfun/lib/door/
ds3.0/lib/doc/lfun/lib/equip/
ds3.0/lib/doc/lfun/lib/file/
ds3.0/lib/doc/lfun/lib/fish/
ds3.0/lib/doc/lfun/lib/fishing/
ds3.0/lib/doc/lfun/lib/flashlight/
ds3.0/lib/doc/lfun/lib/follow/
ds3.0/lib/doc/lfun/lib/ftp_client/
ds3.0/lib/doc/lfun/lib/ftp_data_connection/
ds3.0/lib/doc/lfun/lib/fuel/
ds3.0/lib/doc/lfun/lib/furnace/
ds3.0/lib/doc/lfun/lib/genetics/
ds3.0/lib/doc/lfun/lib/holder/
ds3.0/lib/doc/lfun/lib/id/
ds3.0/lib/doc/lfun/lib/interactive/
ds3.0/lib/doc/lfun/lib/lamp/
ds3.0/lib/doc/lfun/lib/leader/
ds3.0/lib/doc/lfun/lib/light/
ds3.0/lib/doc/lfun/lib/limb/
ds3.0/lib/doc/lfun/lib/living/
ds3.0/lib/doc/lfun/lib/load/
ds3.0/lib/doc/lfun/lib/look/
ds3.0/lib/doc/lfun/lib/manipulate/
ds3.0/lib/doc/lfun/lib/meal/
ds3.0/lib/doc/lfun/lib/messages/
ds3.0/lib/doc/lfun/lib/player/
ds3.0/lib/doc/lfun/lib/poison/
ds3.0/lib/doc/lfun/lib/position/
ds3.0/lib/doc/lfun/lib/post_office/
ds3.0/lib/doc/lfun/lib/potion/
ds3.0/lib/doc/lfun/lib/room/
ds3.0/lib/doc/lfun/lib/server/
ds3.0/lib/doc/lfun/lib/spell/
ds3.0/lib/doc/lfun/lib/torch/
ds3.0/lib/doc/lfun/lib/vendor/
ds3.0/lib/doc/lfun/lib/virt_sky/
ds3.0/lib/doc/lfun/lib/weapon/
ds3.0/lib/doc/lfun/lib/worn_storage/
ds3.0/lib/doc/lpc/constructs/
ds3.0/lib/doc/lpc/etc/
ds3.0/lib/doc/lpc/intermediate/
ds3.0/lib/doc/lpc/types/
ds3.0/lib/doc/misc/
ds3.0/lib/doc/old/
ds3.0/lib/doc/phints/
ds3.0/lib/domains/
ds3.0/lib/domains/Praxis/adm/
ds3.0/lib/domains/Praxis/attic/
ds3.0/lib/domains/Praxis/cemetery/mon/
ds3.0/lib/domains/Praxis/data/
ds3.0/lib/domains/Praxis/death/
ds3.0/lib/domains/Praxis/mountains/
ds3.0/lib/domains/Praxis/obj/armour/
ds3.0/lib/domains/Praxis/obj/magic/
ds3.0/lib/domains/Praxis/obj/weapon/
ds3.0/lib/domains/Praxis/orc_valley/
ds3.0/lib/domains/Ylsrim/
ds3.0/lib/domains/Ylsrim/adm/
ds3.0/lib/domains/Ylsrim/armor/
ds3.0/lib/domains/Ylsrim/broken/
ds3.0/lib/domains/Ylsrim/fish/
ds3.0/lib/domains/Ylsrim/meal/
ds3.0/lib/domains/Ylsrim/npc/
ds3.0/lib/domains/Ylsrim/obj/
ds3.0/lib/domains/Ylsrim/virtual/
ds3.0/lib/domains/Ylsrim/weapon/
ds3.0/lib/domains/campus/adm/
ds3.0/lib/domains/campus/chamber/
ds3.0/lib/domains/campus/etc/
ds3.0/lib/domains/campus/meals/
ds3.0/lib/domains/campus/txt/ai/charles/
ds3.0/lib/domains/campus/txt/ai/charles/bak2/
ds3.0/lib/domains/campus/txt/ai/charles/bak2/bak1/
ds3.0/lib/domains/campus/txt/ai/charly/
ds3.0/lib/domains/campus/txt/ai/charly/bak/
ds3.0/lib/domains/campus/txt/jenny/
ds3.0/lib/domains/cave/doors/
ds3.0/lib/domains/cave/etc/
ds3.0/lib/domains/cave/meals/
ds3.0/lib/domains/cave/weap/
ds3.0/lib/domains/default/chamber/
ds3.0/lib/domains/default/creator/
ds3.0/lib/domains/default/doors/
ds3.0/lib/domains/default/etc/
ds3.0/lib/domains/default/vehicle/
ds3.0/lib/domains/default/virtual/
ds3.0/lib/domains/town/save/
ds3.0/lib/domains/town/txt/shame/
ds3.0/lib/domains/town/virtual/
ds3.0/lib/domains/town/virtual/bottom/
ds3.0/lib/domains/town/virtual/space/
ds3.0/lib/estates/
ds3.0/lib/ftp/
ds3.0/lib/lib/comp/
ds3.0/lib/lib/daemons/
ds3.0/lib/lib/daemons/include/
ds3.0/lib/lib/lvs/
ds3.0/lib/lib/user/
ds3.0/lib/lib/virtual/
ds3.0/lib/log/
ds3.0/lib/log/adm/
ds3.0/lib/log/archive/
ds3.0/lib/log/chan/
ds3.0/lib/log/errors/
ds3.0/lib/log/law/adm/
ds3.0/lib/log/law/email/
ds3.0/lib/log/law/names/
ds3.0/lib/log/law/sites-misc/
ds3.0/lib/log/law/sites-register/
ds3.0/lib/log/law/sites-tempban/
ds3.0/lib/log/law/sites-watch/
ds3.0/lib/log/open/
ds3.0/lib/log/reports/
ds3.0/lib/log/router/
ds3.0/lib/log/secure/
ds3.0/lib/log/watch/
ds3.0/lib/obj/book_source/
ds3.0/lib/obj/include/
ds3.0/lib/powers/prayers/
ds3.0/lib/powers/spells/
ds3.0/lib/realms/template/
ds3.0/lib/realms/template/adm/
ds3.0/lib/realms/template/area/
ds3.0/lib/realms/template/area/armor/
ds3.0/lib/realms/template/area/npc/
ds3.0/lib/realms/template/area/obj/
ds3.0/lib/realms/template/area/room/
ds3.0/lib/realms/template/area/weap/
ds3.0/lib/realms/template/bak/
ds3.0/lib/realms/template/cmds/
ds3.0/lib/save/kills/o/
ds3.0/lib/secure/cfg/classes/
ds3.0/lib/secure/cmds/builders/
ds3.0/lib/secure/cmds/creators/include/
ds3.0/lib/secure/cmds/players/
ds3.0/lib/secure/cmds/players/include/
ds3.0/lib/secure/daemon/imc2server/
ds3.0/lib/secure/daemon/include/
ds3.0/lib/secure/lib/
ds3.0/lib/secure/lib/include/
ds3.0/lib/secure/lib/net/include/
ds3.0/lib/secure/lib/std/
ds3.0/lib/secure/log/adm/
ds3.0/lib/secure/log/bak/
ds3.0/lib/secure/log/intermud/
ds3.0/lib/secure/log/network/
ds3.0/lib/secure/modules/
ds3.0/lib/secure/npc/
ds3.0/lib/secure/obj/include/
ds3.0/lib/secure/room/
ds3.0/lib/secure/save/
ds3.0/lib/secure/save/backup/
ds3.0/lib/secure/save/boards/
ds3.0/lib/secure/save/players/g/
ds3.0/lib/secure/tmp/
ds3.0/lib/secure/upgrades/files/
ds3.0/lib/secure/verbs/creators/
ds3.0/lib/std/board/
ds3.0/lib/std/lib/
ds3.0/lib/verbs/admins/include/
ds3.0/lib/verbs/builders/
ds3.0/lib/verbs/common/
ds3.0/lib/verbs/common/include/
ds3.0/lib/verbs/creators/
ds3.0/lib/verbs/creators/include/
ds3.0/lib/verbs/rooms/
ds3.0/lib/verbs/rooms/include/
ds3.0/lib/www/client/
ds3.0/lib/www/errors/
ds3.0/lib/www/images/
ds3.0/win32/
#include <lib.h>
#include <daemons.h>
#include <talk_type.h>
#include <damage_types.h>
#include <vendor_types.h>
#include <armor_types.h>

inherit LIB_ARMOR;
inherit LIB_SHOOT;
inherit LIB_ACTIVATE;
int tracking, debugging, active, cache, maxcache = 100;
mapping Prey = ([]);
object myroom;

varargs mixed DoWear(object who, mixed where);

string LongDesc(){
    string ret = "A highly advanced weapon of Poleepkwa design, "+
        "meant to be worn.";
    if(!active) return ret;
    if(cache < percent_of(10, maxcache)) ret += " A %^RED%^red%^RESET%^ light is illuminated on it.";
    else if(cache < percent_of(50, maxcache)) ret += " A %^YELLOW%^yellow%^RESET%^ light is illuminated on it.";
    else if(cache < percent_of(80, maxcache)) ret += " A %^GREEN%^green%^RESET%^ light is illuminated on it.";
    else ret += " A %^BLUE%^blue%^RESET%^ light is illuminated on it.";
    return ret;
}

static void create() {
    ::create();
    SetKeyName("plasma cannon");
    SetId(({"cannon"}));
    AddSave(({"cache","Prey"}));
    SetAdjectives(({"shoulder","poleepkwa","plasma"}));
    SetShort("a plasma shoulder cannon");
    SetLong((:LongDesc:));
    SetMass(400);
    SetDollarCost(15000);
    SetVendorType(VT_WEAPON|VT_ARMOR);
    SetArmorType(A_CUSTOM);
    SetRestrictLimbs(({"torso"}));
    SetWear( (: DoWear :) );
    AddItem( ({"light","status light"}), "A status light.");
    set_heart_beat(2);
    Prey = ([]);
}

varargs int OperateThing(object who, mixed what){
    object env;
    string this;
    if(!who) who = this_player();
    env = environment(this_player());
    this = remove_article(GetShort());
    tell_player(who, "You operate your "+this+".");
    tell_object(env, who->GetName() + " operates " + possessive(who) +
            " " + this + ".", ({who}));
    if(what && stringp(what) && !active){
        tell_player(who, "The "+this+" is not activated.");
        return 0;
    }
    return 1;
}

varargs mixed eventShoot(object who, mixed target, string dir, string whom){
    string name, patsy;
    object bolt, killer, env, room = room_environment();
    int fuel, dam;
    killer = (who || this_player());
    fuel = killer->GetMagicPoints();
    name = killer->GetName();
    env = environment(killer);
    if(target) patsy = target->GetName();

    if(creatorp(who)){
        cache = maxcache;
        fuel = 800;
        who->AddMagicPoints(800);
    }

    dam = cache + random(maxcache);

    if(!active){
        write("The cannon clicks.");
        say(name+"'s cannon emits a click.");
        return 1;
    }

    if(cache < 5){
        cache = 0;
        write("The cannon clicks.");
        say(name+"'s cannon emits a click.");
        if(room) room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                "Power cache too low.", "poleepkwa");
        return 1;
    }

    if(fuel < maxcache){
        cache = 0;
        write("The cannon emits a harsh buzzing noise.");
        say(name+"'s cannon emits a harsh buzzing noise.");
        if(room) room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                "Operator essence too low.", "poleepkwa");
        return 1;
    }

    if(dir){
        if(!env){
            write("No environment.");
            return 1;
        }
        if(!env->GetExit(dir)){
            write("You can't shoot in that direction.");
            return 1;
        }
        bolt = new("/domains/default/weap/plasma");
        if(!bolt){
            write("There appears to be some sort of malfunction.");
            return 1;
        }
        write("You fire your plasma cannon "+dir+"!");
        tell_room(env, name+" fires "+possessive(killer)+
                " plasma cannon "+dir+"!", ({killer}));

        if(debugging) bolt->SetDebugging(1);
        bolt->SetOwner(who);
        bolt->SetOwnerOb(this_object());
        bolt->SetDamage(dam);
        bolt->eventMove(env);
        bolt->SetArmed(1);
        bolt->eventDeploy(dir);
        killer->AddMagicPoints(-maxcache);
        cache = 0;
        return 1;
    }

    write("You blast "+patsy+" with your plasma cannon!");
    tell_room(env, name+" blasts "+patsy+" with "+possessive(killer)+
            " plasma cannon!", ({killer, target}));
    target->eventPrint(name+" blasts you with "+possessive(killer)+
            " plasma cannon!");

    dam = cache + random(maxcache);
    cache = 0;

    target->eventReceiveDamage(killer, HEAT, dam);
    killer->AddMagicPoints(-maxcache);
    target->AddEnemy(killer);

    if(tracking){
        if(room && (!Prey["ob"] || Prey["ob"] != target)){
            room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                    "New prey being tracked.", "poleepkwa");
        }
        Prey = ([ "ob" : target, "name" : patsy, "room" : environment(target),
                "player" : userp(target) ]);
    }

    return 1;
}

int ReportHit(object target){
    object here, room;
    string name;
    int player;
    if(!tracking || !active) return 0;
    //if(!inherits(LIB_MISSILE, previous_object())) return 0;
    here = environment(environment());
    if(Prey["ob"] && target == Prey["ob"]){
        here->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                "Hit scored on target.", "poleepkwa");
        return 1;
    }
    room = environment(target);
    name = target->GetName();
    player = userp(target);
    Prey = (["ob" : target, "name" : name, "room" : room, "player" : player]); 
    here->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
            "New prey being tracked.", "poleepkwa");
    return 1;
}

void heart_beat(){
    int notify;
    string str;
    object env = environment();
    object room = room_environment();
    if(active && !GetWorn()){
        if(env) tell_room(env, "The "+remove_article(GetShort())+
                " whines and clicks off.");
        active = 0;
    }
    else if(active){
        int fuel = env->GetMagicPoints();
        if(!fuel){
            active = 0;
            if(environment(env)){
                tell_room(environment(env), env->GetName()+"'s "+
                        "plasma cannon whines and clicks off.", ({env}));
                env->eventPrint("Your plasma cannon whines and clicks off.");
            }
        }
        else if(cache < maxcache){
            env->AddMagicPoints(-1);
            cache++;
        }
    }
    if(active){
        object tmp;
        object penv, menv;
        if(Prey["name"] && !Prey["ob"]){
            if(Prey["player"] && tmp = find_player(Prey["name"])){
                Prey["ob"] = tmp;
                Prey["room"] = environment(tmp);
                Prey["lost"] = 0;
                if(tracking && room){
                    room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                            "Contact with prey re-established.", "poleepkwa");
                }
                return;
            }
            else if(!Prey["player"]) Prey = ([]);
            if(room && !Prey["lost"]){
                if(tracking){
                    room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                            "Contact with prey lost.", "poleepkwa");
                }
                Prey["lost"] = 1;
            }
            return;
        }
        penv = room_environment(Prey["ob"]);
        menv = room_environment(this_object());
        if(Prey["ob"] && (!Prey["room"] || penv != Prey["room"])){
            if(room) room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                    "Prey on the move.", "poleepkwa");
            Prey["room"] = penv;
            notify = 1;
        }
        if(menv != myroom && Prey["ob"]){
            myroom = menv;
            notify = 1;
        }
        if(tracking && notify && room){
            string mycords = ROOMS_D->GetCoordinates(menv);
            string theircords = ROOMS_D->GetCoordinates(penv);
            int i, j, x1, y1, x2, y2, bearing;
            i = sscanf(mycords, "%d,%d,%*s", x1, y1);
            j = sscanf(theircords, "%d,%d,%*s", x2, y2);
            if(i < 2 || j < 2){
                return; 
            }
            bearing = bearing(x2, y2, x1, y1, 1);
            if(bearing != -1) str = "Prey's bearing currently: "+bearing;
            else str = "Prey is in the immediate environment.";
            room->eventHearTalk(this_object(),0,TALK_LOCAL,"say",
                    str, "poleepkwa");
        }
    }
}

void init(){
    object env = environment();
    ::init();
    if(active && !GetWorn()){
        if(env) tell_room(env, "The "+remove_article(GetShort())+
                " whines and clicks off.");
        active = 0;
    }
}

varargs mixed DoWear(object who, mixed where){
    string extra;
    object env = environment(who);
    if(creatorp(who) || who->GetRace() == "poleepkwa"){
        active = 1; 
        if(creatorp(who)) cache = maxcache;
    }
    if(active) extra = " and it beeps and clicks on.";
    else extra = ".";
    who->eventPrint("You wear "+GetShort()+extra);
    if(env) tell_room(env, who->GetName()+" wears "+
            GetShort()+extra, ({who}));
    return 1;
}

mixed eventUnequip(object who){
    mixed ret = ::eventUnequip(who);
    object env = environment(who);
    if(ret && active){
        who->eventPrint("The cannon whines and clicks off.");
        if(env) tell_room(env, who->GetName()+"'s cannon "+
                "whines and clicks off.", ({who}));
        active = 0;
    }
    return ret;
}

int eventTurnOn(mixed str){
    if(!OperateThing(this_player(), str)) return 1;
    if(str && stringp(str)){
        if(str == "debugging" && creatorp(this_player())){
            write("Debugging enabled.");
            debugging = 1;
            return 1;
        }
        else if(str == "tracking"){
            if(tracking){
                write("Tracking already enabled.");
                return 1;
            }
            write("Tracking enabled.");
            tracking = 1;
            return 1;
        }
        else {
            write("The "+remove_article(GetShort())+" has "+
                    "no such feature.");
            return 1;
        }
    }
    if(active){
        write("The cannon is already on.");
        return 1;
    }
    if(!(this_object()->GetWorn()) || !this_player() ||
            environment(this_object()) != this_player()){
        write("You are not wearing the "+remove_article(GetShort())+".");
        return 1;
    }
    write("You activate the "+remove_article(GetShort())+".");
    say(this_player()->GetName()+"'s "+remove_article(GetShort())+
            " beeps and clicks on.");
    active = 1;
    return 1;
}

int eventTurnOff(mixed str){
    if(!OperateThing(this_player())) return 1;
    if(str && stringp(str)){
        if(str == "debugging" && creatorp(this_player())){
            write("Debugging disabled.");
            debugging = 0;
            return 1;
        }
        else if(str == "tracking"){
            if(!tracking){
                write("Tracking already disabled.");
                return 1;
            }
            write("Tracking disabled.");
            tracking = 0;
            return 1;
        }
        else {
            write("The "+remove_article(GetShort())+" has "+
                    "no such feature.");
            return 1;
        }
    }
    if(!active){
        write("The cannon is already off.");
        return 1;
    }
    write("You deactivate the "+remove_article(GetShort())+".");
    say(this_player()->GetName()+"'s "+remove_article(GetShort())+
            " whines and clicks off.");
    active = 0;
    return 1;
}