00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "mech.h"
00018 #include "p.mech.utils.h"
00019
00020
00021
00022
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 }