attack.cpp File Reference

All the routines for fighting in ASC. More...

#include <stdio.h>
#include <math.h>
#include <iostream>
#include "typen.h"
#include "buildingtype.h"
#include "vehicletype.h"
#include "attack.h"
#include "spfst.h"
#include "gameoptions.h"
#include "actions/changeunitproperty.h"
#include "actions/consumeammo.h"
#include "actions/registerunitrftarget.h"
#include "actions/inflictdamage.h"
#include "actions/removemine.h"
#include "actions/removeobject.h"
#include "actions/changeobjectproperty.h"

Include dependency graph for attack.cpp:

Go to the source code of this file.

Functions

void log (const Vehicle *attacker, const Vehicle *attackee)
AttackWeapattackpossible (const Vehicle *attacker, int x, int y)
 Is attacker able to attack anything in field x/y ?
bool attackpossible2u (const Vehicle *attacker, const Vehicle *target, AttackWeap *atw, int targetheight)
 Is attacker able to attack target ? Distance is not evaluated.
bool attackpossible28 (const Vehicle *attacker, const Vehicle *target, AttackWeap *atw, int targetHeight)
 Is attacker able to attack target ? Distance is assumed one field.
bool attackpossible2n (const Vehicle *attacker, const Vehicle *target, AttackWeap *atw)
 Is attacker able to attack target ? Actual distance used.
bool vehicleplattfahrbar (const Vehicle *vehicle, const MapField *field)
 Can the vehicle drive across the field and destroy any unit there by moving over them?


Detailed Description

All the routines for fighting in ASC.

Definition in file attack.cpp.


Function Documentation

AttackWeap* attackpossible ( const Vehicle attacker,
int  x,
int  y 
)

Is attacker able to attack anything in field x/y ?

Definition at line 769 of file attack.cpp.

References Vehicle::ammo, attackpossible2n(), beeline(), MapField::building, AttackWeap::building, cmm_building, ContainerBase::color, UnitWeapon::count, cwbombn, cwcannonn, cwcruisemissile, cwlargemissilen, cwlasern, cwsmallmissilen, cwtorpedon, Player::diplomacy, SingleWeapon::efficiency, fieldvisiblenow(), GameMap::getField(), getFirstBit(), getheightdelta(), ContainerBase::getMap(), ContainerBase::getOwner(), GameMap::getPlayer(), SingleWeapon::getScalarWeaponType(), MapField::getVehicle(), ContainerBaseType::height, Vehicle::height, DiplomaticStateVector::isHostile(), SingleWeapon::mindistance, AttackWeap::object, MapField::objects, SingleWeapon::shootable(), SingleWeapon::sourceheight, SingleWeapon::targ, SingleWeapon::targetingAccuracy, Vehicle::typ, Building::typ, MapField::vehicle, UnitWeapon::weapon, VehicleType::weapons, Vehicle::weapstrength, Vehicle::xpos, GameMap::xsize, Vehicle::ypos, and GameMap::ysize.

Referenced by tsearchreactionfireingunits::attack(), tunitattacksobject::setup(), tunitattacksbuilding::setup(), and tunitattacksunit::setup().

bool attackpossible28 ( const Vehicle attacker,
const Vehicle target,
AttackWeap attackweap = NULL,
int  targetHeight = -1 
)

Is attacker able to attack target ? Distance is assumed one field.

The distance is assumed to be 1 field. The routine is used for the movement routines for example, because units moving next to enemies get a movement malus. Does not evaluate any diplomatic states

Parameters:
attacker the attacking unit
target the unit that is being attacked
attackweap if != NULL, detailed information about the weapons which can perform the attack are written to attackweap
targetHeight if != -1 , assume the target unit was on this height (bitmapped!)

Definition at line 910 of file attack.cpp.

References Vehicle::ammo, AttackWeap::count, UnitWeapon::count, SingleWeapon::efficiency, getFirstBit(), getheightdelta(), SingleWeapon::getScalarWeaponType(), Vehicle::height, SingleWeapon::mindistance, minmalq, VehicleType::movemalustyp, AttackWeap::num, SingleWeapon::offensive(), SingleWeapon::shootable(), SingleWeapon::sourceheight, AttackWeap::strength, SingleWeapon::targ, AttackWeap::target, SingleWeapon::targetingAccuracy, Vehicle::typ, AttackWeap::typ, AttackWeap::vehicle, UnitWeapon::weapon, VehicleType::weapons, and Vehicle::weapstrength.

Referenced by calcMoveMalus(), and fieldAccessible().

bool attackpossible2n ( const Vehicle attacker,
const Vehicle target,
AttackWeap attackweap = NULL 
)

Is attacker able to attack target ? Actual distance used.

Parameters:
attacker the attacking unit
target the unit that is being attacked
attackweap if != NULL, detailed information about the weapons which can perform the attack are written to attackweap

Definition at line 953 of file attack.cpp.

References Vehicle::ammo, Vehicle::attacked, beeline(), AttackWeap::count, UnitWeapon::count, Player::diplomacy, SingleWeapon::efficiency, getFirstBit(), getheightdelta(), ContainerBase::getMap(), ContainerBase::getOwner(), SingleWeapon::getScalarWeaponType(), Vehicle::ReactionFire::getStatus(), Vehicle::hasMoved(), Vehicle::height, DiplomaticStateVector::isHostile(), SingleWeapon::mindistance, VehicleType::movemalustyp, AttackWeap::num, SingleWeapon::offensive(), GameMap::player, Vehicle::reactionfire, Vehicle::ReactionFire::ready, SingleWeapon::shootable(), SingleWeapon::sourceheight, AttackWeap::strength, SingleWeapon::targ, AttackWeap::target, SingleWeapon::targetingAccuracy, Vehicle::typ, AttackWeap::typ, AttackWeap::vehicle, VehicleType::wait, UnitWeapon::weapon, VehicleType::weapons, and Vehicle::weapstrength.

Referenced by attackpossible(), and UnitAttacksUnit_FakeHemming::UnitAttacksUnit_FakeHemming().

bool attackpossible2u ( const Vehicle attacker,
const Vehicle target,
AttackWeap attackweap = NULL,
int  targetheight = -1 
)

Is attacker able to attack target ? Distance is not evaluated.

The distance is not evaluated. The routine is used for the movement routines for example, because the current distance of units A and B is not relevant for the check whether unit A can move across the field where B is standing.

Parameters:
attacker the attacking unit
target the unit that is being attacked
attackweap if != NULL, detailed information about the weapons which can perform the attack are written to attackweap
targetHeight if != -1 , assume the target unit was on this height (bitmapped!)

Definition at line 866 of file attack.cpp.

References Vehicle::ammo, AttackWeap::count, UnitWeapon::count, Player::diplomacy, SingleWeapon::efficiency, getFirstBit(), getheightdelta(), ContainerBase::getMap(), ContainerBase::getOwner(), SingleWeapon::getScalarWeaponType(), Vehicle::height, DiplomaticStateVector::isHostile(), VehicleType::movemalustyp, AttackWeap::num, SingleWeapon::offensive(), GameMap::player, SingleWeapon::shootable(), SingleWeapon::sourceheight, AttackWeap::strength, SingleWeapon::targ, AttackWeap::target, SingleWeapon::targetingAccuracy, Vehicle::typ, AttackWeap::typ, AttackWeap::vehicle, UnitWeapon::weapon, VehicleType::weapons, and Vehicle::weapstrength.

void log ( const Vehicle attacker,
const Vehicle attackee 
)

Definition at line 378 of file attack.cpp.

References Vehicle::experience, ContainerBase::getMap(), ContainerBase::getOwner(), ContainerBaseType::id, CGameOptions::Instance(), ContainerBaseType::name, GameMap::time, GameTime::turn(), and Vehicle::typ.

Referenced by compareMapResources(), getFirstBit(), and tunitattacksunit::setresult().

bool vehicleplattfahrbar ( const Vehicle vehicle,
const MapField field 
)

Can the vehicle drive across the field and destroy any unit there by moving over them?

Definition at line 996 of file attack.cpp.

Referenced by fieldAccessible().


Generated on Mon May 21 01:29:26 2012 for Advanced Strategic Command by  doxygen 1.5.1