btmux/autom4te.cache/
btmux/doc/.svn/
btmux/event/.svn/
btmux/game/.svn/
btmux/game/bin/.svn/
btmux/game/data/.svn/
btmux/game/logs/.svn/
btmux/game/maps/
btmux/game/maps/.svn/
btmux/game/maps/.svn/prop-base/
btmux/game/maps/.svn/props/
btmux/game/maps/.svn/text-base/
btmux/game/maps/.svn/wcprops/
btmux/game/mechs/
btmux/game/mechs/.svn/
btmux/game/mechs/.svn/prop-base/
btmux/game/mechs/.svn/props/
btmux/game/mechs/.svn/text-base/
btmux/game/mechs/.svn/wcprops/
btmux/game/text/.svn/
btmux/include/.svn/
btmux/misc/
btmux/misc/.svn/
btmux/misc/.svn/prop-base/
btmux/misc/.svn/props/
btmux/misc/.svn/text-base/
btmux/misc/.svn/wcprops/
btmux/python/
btmux/python/.svn/
btmux/python/.svn/prop-base/
btmux/python/.svn/props/
btmux/python/.svn/text-base/
btmux/python/.svn/wcprops/
btmux/src/.svn/prop-base/
btmux/src/.svn/props/
btmux/src/.svn/text-base/
btmux/src/.svn/wcprops/
btmux/src/hcode/.svn/
btmux/src/hcode/btech/
btmux/src/hcode/btech/.svn/
btmux/src/hcode/btech/.svn/prop-base/
btmux/src/hcode/btech/.svn/props/
btmux/src/hcode/btech/.svn/text-base/
btmux/src/hcode/btech/.svn/wcprops/
btmux/src/hcode/include/.svn/
/*
 * $Id: mech.lite.c,v 1.1.1.1 2005/01/11 21:18:17 kstevens Exp $
 *
 * Author: Markus Stenberg <fingon@iki.fi>
 *
 *  Copyright (c) 1998 Markus Stenberg
 *  Copyright (c) 1998-2002 Thomas Wouters
 *  Copyright (c) 2000-2002 Cord Awtry
 *       All rights reserved
 *
 * Created: Wed Mar 18 22:33:16 1998 fingon
 * Last modified: Thu Dec 10 21:47:06 1998 fingon
 *
 */

#include "mech.h"
#include "p.mech.utils.h"

/* If the target is in the front arc, and Line of Sight is not blocked
 * (by terrain, water hexes or more than 2 'points' of wood) and in
 * range, the target is lit.
 */
static int mech_lites_target(MECH * mech, MECH * target)
{
    MAP * map = getMap(mech->mapindex);
    int losflag = MechToMech_LOSFlag(map, mech, target);

    if (!MechLites(mech))
	return 0;
    if (FaMechRange(mech, target) > LITE_RANGE)
        return 0;
    if (!(InWeaponArc(mech, MechFX(target),
		      MechFY(target)) & FORWARDARC))
	return 0;
    if ((losflag & MECHLOSFLAG_BLOCK) ||
	MechLOSFlag_WoodCount(losflag) > 2 ||
	MechLOSFlag_WaterCount(losflag) != 0)
	return 0;
    return 1;
}

void cause_lite(MECH * mech, MECH * tempMech)
{
    if (MechLit(tempMech))
	return;
    if (mech_lites_target(mech, tempMech)) {
	MechCritStatus(tempMech) |= SLITE_LIT;
	if (MechSLWarn(tempMech))
	    mech_notify(tempMech, MECHALL, "You are being illuminated!");
    }
}

void end_lite_check(MECH * mech)
{
    MAP * map = getMap(mech->mapindex);
    MECH * t;
    int i;

    if (!MechLit(mech))
	return;
    if (!map)
	return;
    for (i = 0; i < map->first_free; i++) {
	if (i == mech->mapnumber)
	    continue;
	if (!(t = FindObjectsData(map->mechsOnMap[i])))
	    continue;
	if (mech_lites_target(t, mech))
	    return;
    }
    MechCritStatus(mech) &= ~SLITE_LIT;
    if (MechSLWarn(mech))
    	mech_notify(mech, MECHALL, "You are no longer being illuminated.");
}