dsI/bin/
dsI/extra/creremote/
dsI/extra/mingw/
dsI/extra/wolfpaw/
dsI/fluffos-2.7-ds2.018/
dsI/fluffos-2.7-ds2.018/ChangeLog.old/
dsI/fluffos-2.7-ds2.018/Win32/
dsI/fluffos-2.7-ds2.018/compat/
dsI/fluffos-2.7-ds2.018/compat/simuls/
dsI/fluffos-2.7-ds2.018/testsuite/
dsI/fluffos-2.7-ds2.018/testsuite/clone/
dsI/fluffos-2.7-ds2.018/testsuite/command/
dsI/fluffos-2.7-ds2.018/testsuite/data/
dsI/fluffos-2.7-ds2.018/testsuite/etc/
dsI/fluffos-2.7-ds2.018/testsuite/include/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/master/
dsI/fluffos-2.7-ds2.018/testsuite/log/
dsI/fluffos-2.7-ds2.018/testsuite/single/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
dsI/fluffos-2.7-ds2.018/testsuite/u/
dsI/fluffos-2.7-ds2.018/tmp/
dsI/lib/cfg/
dsI/lib/cmds/common/
dsI/lib/cmds/creators/include/
dsI/lib/cmds/creators/include/SCCS/
dsI/lib/daemon/services/
dsI/lib/doc/
dsI/lib/domains/Ylsrim/
dsI/lib/domains/Ylsrim/adm/
dsI/lib/domains/Ylsrim/armour/
dsI/lib/domains/Ylsrim/broken/
dsI/lib/domains/Ylsrim/fish/
dsI/lib/domains/Ylsrim/meal/
dsI/lib/domains/Ylsrim/npc/
dsI/lib/domains/Ylsrim/virtual/
dsI/lib/domains/Ylsrim/weapon/
dsI/lib/domains/default/creator/
dsI/lib/domains/default/etc/
dsI/lib/domains/default/room/
dsI/lib/lib/comp/
dsI/lib/lib/lvs/
dsI/lib/lib/user/
dsI/lib/lib/virtual/
dsI/lib/obj/
dsI/lib/obj/include/
dsI/lib/realms/
dsI/lib/save/kills/a/
dsI/lib/save/kills/b/
dsI/lib/save/kills/f/
dsI/lib/save/kills/m/
dsI/lib/save/kills/q/
dsI/lib/save/kills/r/
dsI/lib/secure/cfg/
dsI/lib/secure/cfg/classes/
dsI/lib/secure/cfg/races/SCCS/
dsI/lib/secure/cmds/creators/include/
dsI/lib/secure/cmds/players/
dsI/lib/secure/cmds/players/include/
dsI/lib/secure/daemon/include/
dsI/lib/secure/lib/
dsI/lib/secure/lib/include/
dsI/lib/secure/lib/net/
dsI/lib/secure/lib/net/include/
dsI/lib/secure/lib/std/
dsI/lib/secure/obj/
dsI/lib/secure/obj/include/
dsI/lib/secure/save/
dsI/lib/spells/
dsI/lib/verbs/admins/include/
dsI/lib/verbs/common/
dsI/lib/verbs/common/include/
dsI/lib/verbs/creators/
dsI/lib/verbs/creators/include/
dsI/lib/verbs/players/include/SCCS/
dsI/lib/verbs/rooms/
dsI/lib/verbs/rooms/include/
dsI/lib/www/
dsI/v22.2b14/
dsI/win32/
/*    /lib/comp/weapon.c
 *    From the Dead Souls V Object Library
 *    This object combines the ability to be wielded with damage doing
 *    Created by Descartes of Borg 960211
 *    Version: @(#) weapon.c 1.13@(#)
 *    Last modified: 97/01/01
 */

#include <lib.h>
#include <function.h>

inherit LIB_DAMAGE;
inherit LIB_EQUIP;
inherit LIB_POISON;
inherit LIB_WIELD;

private int          Hands      = 1;
private string       WeaponType = "blunt";
private static mixed Wield      = 0;

// abstract methods
string GetDefiniteShort();
string GetKeyName();
string GetShort();
// end abstract methods

varargs string GetEquippedDescription(object who) {
    if( GetWorn() ) {
	string tmp = "It is wielded in ";
	
	if( !who ) {
	    who = this_player();
	}
	if( who == environment() ) {
	    tmp += "your";
	}
	else {
	    tmp += possessive_noun(environment());
	}
	tmp += " " + item_list(GetWorn()) + ".";
	return tmp;
  }
  return 0;
}


string GetEquippedShort() {
    object env = environment();
    string ret = GetShort();
    string array limbs;
 
    if( !env || !living(env) ) {
	return ret;
    }
    limbs = GetWorn();
    if( sizeof(limbs) > 0 ) {
	ret += " (wielded in " + item_list(limbs) + ")";
    }
    return ret;
}

int GetHands() {
    return Hands;
}

int SetHands(int x) {
    return (Hands = x);
}

string array GetSave() {
    return (damage::GetSave() + equip::GetSave() + poison::GetSave());
}

string GetWeaponType() {
    return WeaponType;
}
 
string SetWeaponType(string str) {
    if( !stringp(str) ) {
	error("Bad argument 1 to SetWeaponType().\n\tExpected: string, Got: " +
	      typeof(str) + "\n");
    }
    return (WeaponType = str);
}
 
mixed GetWield() {
    return Wield;
}
 
mixed SetWield(mixed val) {
    return (Wield = val);
}
 
mixed CanEquip(object who, string array limbs) {
    mixed tmp = equip::CanEquip(who, limbs);

    if( tmp != 1 ) {
	return tmp;
    }
    if( GetHands() != sizeof(limbs) ) {
	return "#You must use " + cardinal(Hands) + " to wield " +
	    GetDefiniteShort() + ".";
    }
    if( Hands > sizeof(who->GetWieldingLimbs()) ) {
	return "#You do not have enough limbs for that weapon!";
    }
    if( newbiep(who) && GetClass() > 30 ) {
	return "You are not skilled enough to wield this weapon.";
    }
    return 1;
}

int eventDeteriorate(int type) {
    int x = GetClass();
 
    if( x ) {
        object env = environment();
 
        if( living(env) ) {
            if( x > 1 ) {
		env->eventPrint(capitalize(GetDefiniteShort()) +
				" is wearing down.");
	    }
            else {
		env->eventPrint(capitalize(GetDefiniteShort()) +
				" is completely worn.");
	    }
        }
	if( GetProperty("blessed") ) {
	    SetClass(x-2);
	}
        else {
	    SetClass(x-1);
	}
    }
    return 1;
}

mixed eventEquip(object who, string array limbs) {
    mixed tmp;
    
    if( functionp(Wield) ) {
	if( functionp(Wield) & FP_OWNER_DESTED ) {
	    return "Function pointer owner destructed.";
	}
	if( !evaluate(Wield, who, limbs) ) {
	    return 1;
	}
	else {
	    return equip::eventEquip(who, limbs);
	}
    }
    tmp = equip::eventEquip(who, limbs);
    if( tmp != 1 ) {
	return tmp;
    }
    if( stringp(Wield) ) {
	who->eventPrint(Wield);
    }
    else {
	who->eventPrint("You wield " + GetShort() + ".");
    }
    environment(who)->eventPrint(who->GetName() + " wields " + GetShort() +
				 ".", who);
    return 1;
}
 
int eventStrike(object target) {
    int poison = GetPoison();
 
    if( poison > 0 ) {
	int x = random(poison) + 1;
	
        if( x > 0 ) {
	    send_messages("", "$agent_possessive_noun " + GetKeyName() +
			  " poisons $target_name.", environment(), target,
			  environment(environment()));
            target->AddPoison(x);
            AddPoison(-x);
        }
    }
    return damage::eventStrike(target);
}

mixed eventUnequip(object who) {
    mixed tmp = equip::eventUnequip(who);

    if( tmp != 1 ) {
	return tmp;
    }
    send_messages("unwield", "$agent_name $agent_verb $target_name.",
		  who, this_object(), environment(who));
    return 1;
}

// Some things to respond to provide friendly error messages
mixed direct_remove_obj() {
    if( environment() != this_player() ) {
	return "#You don't have that!";
    }
    return "#Do you mean to unwield it?";
}

mixed direct_wear_obj() {
    if( environment() != this_player() ) {
	return "#You don't have that!";
    }
    return "#Do you mean to wield it?";
}