Example #1
0
#include "Sim/Units/UnitDef.h"
#include "Sim/Units/CommandAI/CommandQueue.h"
#include "creg/STL_Map.h"
#include "creg/STL_Set.h"
#include "creg/Serializer.h"
#include "creg/cregex.h"
#include "System/GlobalStuff.h"

#define CMD_CHANGE_MODE 	160
#define CMD_AREA_UPGRADE 	165
#define CMD_DUMMY			170

CR_BIND(CGroupAI, );

CR_REG_METADATA(CGroupAI,(
				CR_ENUM_MEMBER(mode),
				CR_MEMBER(myUnits),
				CR_MEMBER(lockedMexxes),
				CR_MEMBER(maxMetal),
				CR_MEMBER(mohoBuilderId),
				CR_MEMBER(unitsChanged),
				CR_POSTLOAD(PostLoad)
				));

CR_BIND(CGroupAI::UnitInfo, );

CR_REG_METADATA_SUB(CGroupAI, UnitInfo,(
					CR_MEMBER(maxExtractsMetal),
					CR_MEMBER(wantedMohoId),
					CR_MEMBER(wantedMohoName),
					CR_MEMBER(nearestMex),
Example #2
0
#include "MoveMath/MoveMath.h"
#include "Sim/Misc/GlobalConstants.h"
#include "System/creg/STL_Deque.h"
#include "System/creg/STL_Map.h"
#include "System/Exceptions.h"
#include "System/CRC.h"
#include "System/myMath.h"
#include "System/Util.h"

CR_BIND(MoveDef, ());
CR_BIND(MoveDefHandler, );

CR_REG_METADATA(MoveDef, (
	CR_MEMBER(name),

	CR_ENUM_MEMBER(moveFamily),
	CR_ENUM_MEMBER(terrainClass),

	CR_MEMBER(xsize),
	CR_MEMBER(xsizeh),
	CR_MEMBER(zsize),
	CR_MEMBER(zsizeh),
	CR_MEMBER(depth),
	CR_MEMBER(depthModParams),
	CR_MEMBER(maxSlope),
	CR_MEMBER(slopeMod),
	CR_MEMBER(crushStrength),
	CR_MEMBER(speedModMults),

	CR_MEMBER(pathType),
	CR_MEMBER(unitDefRefCount),
#include "CoverageHandler.h"


#define COVERAGE_SQUARE 4.0
#define COVERAGE_SQUARE2 32.0

CR_BIND(CCoverageHandler ,(NULL,Radar))

CR_REG_METADATA(CCoverageHandler,(
				CR_MEMBER(CovMap),
			    CR_MEMBER(ai),
				CR_ENUM_MEMBER(Type),
				CR_RESERVED(64)
				));

int mandist(int x1, int y1, int x2, int y2){
	return abs(x1 - x2) + abs(y1 - y2);
}
int RevDist(int X1, int Y1, int X2, int Y2, int Max, int Increment){
	int dist = mandist(X1, Y1, X2, Y2);
	if(dist * Increment > Max)
		return 0;
	else
		return Max - dist * Increment;
}
float Dist(float x1, float y1, float x2, float y2){
	return (float)hypot(fabs(x1 - x2), fabs(y1-y2));
}
float F3Dist(float3 A, float3 B){
	return (float)hypot(fabs(A.x - B.x), fabs(A.z - A.z));
Example #4
0
#include "System/myMath.h"

CR_BIND_DERIVED_INTERFACE(AMoveType, CObject);
CR_REG_METADATA(AMoveType, (
	CR_MEMBER(owner),
	CR_MEMBER(goalPos),
	CR_MEMBER(oldPos),
	CR_MEMBER(oldSlowUpdatePos),

	CR_MEMBER(maxSpeed),
	CR_MEMBER(maxSpeedDef),
	CR_MEMBER(maxWantedSpeed),
	CR_MEMBER(repairBelowHealth),

	CR_MEMBER(useHeading),
	CR_ENUM_MEMBER(progressState)
));

AMoveType::AMoveType(CUnit* owner):
	owner(owner),

	goalPos(owner? owner->pos: ZeroVector),
	oldPos(owner? owner->pos: ZeroVector),
	oldSlowUpdatePos(oldPos),

	useHeading(true),

	progressState(Done),

	maxSpeed(owner? owner->unitDef->speed / GAME_SPEED : 0.0f),
	maxSpeedDef(owner? owner->unitDef->speed / GAME_SPEED : 0.0f),
#include "myMath.h"

CR_BIND_DERIVED(CSolidObject, CWorldObject, );
CR_REG_METADATA(CSolidObject,
(
	CR_MEMBER(mass),
	CR_MEMBER(blocking),
	CR_MEMBER(floatOnWater),
	CR_MEMBER(isUnderWater),
	CR_MEMBER(immobile),
	CR_MEMBER(blockHeightChanges),
	CR_MEMBER(xsize),
	CR_MEMBER(ysize),
	CR_MEMBER(height),
	CR_MEMBER(heading),
	CR_ENUM_MEMBER(physicalState),
	CR_MEMBER(midPos),
	CR_MEMBER(isMoving),
	CR_MEMBER(residualImpulse),
	CR_MEMBER(mobility),
	CR_MEMBER(mapPos),
	CR_MEMBER(buildFacing),
	CR_MEMBER(isMarkedOnBlockingMap),
	CR_MEMBER(speed),
	CR_RESERVED(16))
);


CSolidObject::CSolidObject():
	mass(100000),
	blocking(false),
Example #6
0
CR_BIND_STRUCT(Triangle);
CR_REG_METADATA(Triangle, (CR_MEMBER(vrt)));

// Joints
CR_BIND_DERIVED(BaseJoint, creg::BaseObject);

CR_BIND_DERIVED(HingeJoint, BaseJoint);
CR_REG_METADATA(HingeJoint, CR_MEMBER(axis));

CR_BIND_DERIVED(UniversalJoint, BaseJoint);
CR_REG_METADATA(UniversalJoint, CR_MEMBER(axis));

// IK info
CR_BIND(IKinfo);
CR_REG_METADATA(IKinfo, (CR_MEMBER(joint), CR_ENUM_MEMBER(jointType)));

// Poly
CR_BIND_DERIVED(Poly, creg::BaseObject);
CR_REG_METADATA(Poly, (
	CR_MEMBER(verts), 
	CR_MEMBER(texname), 
	CR_MEMBER(color), 
	CR_MEMBER(taColor),
	CR_MEMBER(texture),
	CR_MEMBER_SETFLAG(texture, CM_NoSerialize), // the texture shouldn't be serialized
	CR_MEMBER(isSelected))
);

CR_BIND(Rotator);
CR_REG_METADATA(Rotator, 
Example #7
0
#include "MoveMath/MoveMath.h"
#include "Sim/Misc/GlobalConstants.h"
#include "System/creg/STL_Deque.h"
#include "System/creg/STL_Map.h"
#include "System/Exceptions.h"
#include "System/CRC.h"
#include "System/myMath.h"
#include "System/Util.h"

CR_BIND(MoveDef, ());
CR_BIND(MoveDefHandler, (NULL));

CR_REG_METADATA(MoveDef, (
	CR_MEMBER(name),

	CR_ENUM_MEMBER(speedModClass),
	CR_ENUM_MEMBER(terrainClass),

	CR_MEMBER(xsize),
	CR_MEMBER(xsizeh),
	CR_MEMBER(zsize),
	CR_MEMBER(zsizeh),
	CR_MEMBER(depth),
	CR_MEMBER(depthModParams),
	CR_MEMBER(maxSlope),
	CR_MEMBER(slopeMod),
	CR_MEMBER(crushStrength),
	CR_MEMBER(speedModMults),

	CR_MEMBER(pathType),
	CR_MEMBER(udRefCount),
Example #8
0
// number of SlowUpdate calls that a target (unit) must
// be out of radar (and hence LOS) contact before it is
// considered 'lost' and invalid (for attack orders etc)
//
// historically this value was 120, which meant that it
// took (120 * UNIT_SLOWUPDATE_RATE) / GAME_SPEED == 64
// seconds (!) before eg. aircraft would stop tracking a
// target that cloaked after flying over it --> obviously
// unreasonable
static const int TARGET_LOST_TIMER = 15;
static const float COMMAND_CANCEL_DIST = 17.0f;

CR_BIND(CCommandQueue, );
CR_REG_METADATA(CCommandQueue, (
	CR_MEMBER(queue),
	CR_ENUM_MEMBER(queueType),
	CR_MEMBER(tagCounter)
));

CR_BIND_DERIVED(CCommandAI, CObject, );
CR_REG_METADATA(CCommandAI, (
	CR_MEMBER(stockpileWeapon),

	CR_MEMBER(possibleCommands),
	CR_MEMBER(commandQue),
	CR_MEMBER(nonQueingCommands),
	CR_MEMBER(lastUserCommand),
	CR_MEMBER(selfDCountdown),
	CR_MEMBER(lastFinishCommand),

	CR_MEMBER(owner),
Example #9
0
#include "IncCREG.h"
#include "IncExternAI.h"
#include "IncGlobalAI.h"

#include "KAIK.h"
extern CKAIK* KAIKStateExt;

CR_BIND(BuildingTracker, )
CR_REG_METADATA(BuildingTracker, (
	CR_MEMBER(unitUnderConstruction),
	CR_ENUM_MEMBER(category),
	CR_MEMBER(hpLastFrame),
	CR_MEMBER(damage),
	CR_MEMBER(hpSomeTimeAgo),
	CR_MEMBER(damageSomeTimeAgo),
	CR_MEMBER(startedRealBuildingFrame),
	CR_MEMBER(etaFrame),
	CR_MEMBER(maxTotalBuildPower),
	CR_MEMBER(assignedTotalBuildPower),
	CR_MEMBER(energyUsage),
	CR_MEMBER(metalUsage),

	CR_MEMBER(buildTask),
	CR_MEMBER(factory),
	CR_MEMBER(economyUnitTracker),
	CR_RESERVED(16)
))

CR_BIND(EconomyUnitTracker, )
CR_REG_METADATA(EconomyUnitTracker, (
	CR_MEMBER(economyUnitId),
Example #10
0
	CR_MEMBER(uh),
	CR_MEMBER(dm),
	CR_MEMBER(ah),
	CR_MEMBER(dgunConHandler),
	CR_RESERVED(16)
));

CR_BIND(UnitType, );
CR_REG_METADATA(UnitType, (
	CR_MEMBER(canBuildList),
	CR_MEMBER(builtByList),
	CR_MEMBER(DPSvsUnit),
	CR_MEMBER(TargetCategories),
	// cannot serialize this directly
	// CR_MEMBER(def),
	CR_ENUM_MEMBER(category),
	CR_MEMBER(isHub),
	CR_MEMBER(techLevel),
	CR_MEMBER(costMultiplier),
	CR_MEMBER(sides),
	CR_POSTLOAD(PostLoad)
));

CR_BIND(integer2, );
CR_REG_METADATA(integer2, (
	CR_MEMBER(x),
	CR_MEMBER(y)
));

CR_BIND(BuilderTracker, );
CR_REG_METADATA(BuilderTracker, (
Example #11
0
	CR_MEMBER(relWeaponPos),
	CR_MEMBER(relWeaponMuzzlePos),
	CR_MEMBER(muzzleFlareSize),
	CR_MEMBER(lastTargetRetry),
	CR_MEMBER(areaOfEffect),
	CR_MEMBER(badTargetCategory),
	CR_MEMBER(onlyTargetCategory),
	CR_MEMBER(incoming),
//	CR_MEMBER(weaponDef),
	CR_MEMBER(stockpileTime),
	CR_MEMBER(buildPercent),
	CR_MEMBER(numStockpiled),
	CR_MEMBER(numStockpileQued),
	CR_MEMBER(interceptTarget),
	CR_MEMBER(salvoError),
	CR_ENUM_MEMBER(targetType),
	CR_MEMBER(sprayAngle),
	CR_MEMBER(useWeaponPosForAim),
	CR_MEMBER(errorVector),
	CR_MEMBER(errorVectorAdd),
	CR_MEMBER(lastErrorVectorUpdate),
	CR_MEMBER(slavedTo),
	CR_MEMBER(mainDir),
	CR_MEMBER(maxMainDirAngleDif),
	CR_MEMBER(hasCloseTarget),
	CR_MEMBER(avoidFriendly),
	CR_MEMBER(avoidFeature),
	CR_MEMBER(avoidNeutral),
	CR_MEMBER(targetBorder),
	CR_MEMBER(cylinderTargetting),
	CR_MEMBER(minIntensity),
Example #12
0
#include "AAirMoveType.h"
#include "MoveMath/MoveMath.h"

#include "Map/Ground.h"
#include "Map/MapInfo.h"
#include "Sim/Misc/GlobalSynced.h"
#include "Sim/Misc/QuadField.h"
#include "Sim/Units/Unit.h"
#include "Sim/Units/UnitDef.h"
#include "Sim/Units/CommandAI/CommandAI.h"
#include "Sim/Units/Scripts/UnitScript.h"

CR_BIND_DERIVED_INTERFACE(AAirMoveType, AMoveType)

CR_REG_METADATA(AAirMoveType, (
	CR_ENUM_MEMBER(aircraftState),
	CR_ENUM_MEMBER(padStatus),

	CR_MEMBER(oldGoalPos),
	CR_MEMBER(reservedLandingPos),

	CR_MEMBER(wantedHeight),
	CR_MEMBER(orgWantedHeight),

	CR_MEMBER(accRate),
	CR_MEMBER(decRate),
	CR_MEMBER(altitudeRate),

	CR_MEMBER(collide),
	CR_MEMBER(useSmoothMesh),
	CR_MEMBER(autoLand),