src/hcode/btech/mech.lite.c

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: mech.lite.c,v 1.1.1.1 2005/01/11 21:18:17 kstevens Exp $
00004  *
00005  * Author: Markus Stenberg <fingon@iki.fi>
00006  *
00007  *  Copyright (c) 1998 Markus Stenberg
00008  *  Copyright (c) 1998-2002 Thomas Wouters
00009  *  Copyright (c) 2000-2002 Cord Awtry
00010  *       All rights reserved
00011  *
00012  * Created: Wed Mar 18 22:33:16 1998 fingon
00013  * Last modified: Thu Dec 10 21:47:06 1998 fingon
00014  *
00015  */
00016 
00017 #include "mech.h"
00018 #include "p.mech.utils.h"
00019 
00020 /* If the target is in the front arc, and Line of Sight is not blocked
00021  * (by terrain, water hexes or more than 2 'points' of wood) and in
00022  * range, the target is lit.
00023  */
00024 static int mech_lites_target(MECH * mech, MECH * target)
00025 {
00026         MAP *map = getMap(mech->mapindex);
00027         int losflag = MechToMech_LOSFlag(map, mech, target);
00028 
00029         if(!MechLites(mech))
00030                 return 0;
00031         if(FaMechRange(mech, target) > LITE_RANGE)
00032                 return 0;
00033         if(!(InWeaponArc(mech, MechFX(target), MechFY(target)) & FORWARDARC))
00034                 return 0;
00035         if((losflag & MECHLOSFLAG_BLOCK) ||
00036            MechLOSFlag_WoodCount(losflag) > 2 ||
00037            MechLOSFlag_WaterCount(losflag) != 0)
00038                 return 0;
00039         return 1;
00040 }
00041 
00042 void cause_lite(MECH * mech, MECH * tempMech)
00043 {
00044         if(MechLit(tempMech))
00045                 return;
00046         if(mech_lites_target(mech, tempMech)) {
00047                 MechCritStatus(tempMech) |= SLITE_LIT;
00048                 if(MechSLWarn(tempMech))
00049                         mech_notify(tempMech, MECHALL, "You are being illuminated!");
00050         }
00051 }
00052 
00053 void end_lite_check(MECH * mech)
00054 {
00055         MAP *map = getMap(mech->mapindex);
00056         MECH *t;
00057         int i;
00058 
00059         if(!MechLit(mech))
00060                 return;
00061         if(!map)
00062                 return;
00063         for(i = 0; i < map->first_free; i++) {
00064                 if(i == mech->mapnumber)
00065                         continue;
00066                 if(!(t = FindObjectsData(map->mechsOnMap[i])))
00067                         continue;
00068                 if(mech_lites_target(t, mech))
00069                         return;
00070         }
00071         MechCritStatus(mech) &= ~SLITE_LIT;
00072         if(MechSLWarn(mech))
00073                 mech_notify(mech, MECHALL, "You are no longer being illuminated.");
00074 }

Generated on Mon May 28 04:25:22 2007 for BattletechMUX by  doxygen 1.4.7