You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
Visit the ROAD Programming Website for more programming help.
You are unique. Just like everybody else.
Visit the ROAD Programming Website for more programming help.
// Base class:CActionMessage* CUnit::makeDefaultAction (const Target& tgt) = 0;//Derived unit classes:CActionMessage* CMarine::makeDefaultAction (const Target& tgt){ // marines always attack whenever right-clicked on enemy if (tgt.isEnemy) return new CAttackMessage (tgt); type_id tgtType = typeid (tgt); // gotta find out what type of target we have type_id tgtId == typeid (tgt); if (tgtId == CCarrier.getTypeId ()) return new CBoardMessage (tgt); if (tgtId == CTerrain.getTypeId ()) return new CMoveMessage (tgt); //...}
You are unique. Just like everybody else.
Visit the ROAD Programming Website for more programming help.
type_id CUnit::getTypeId(void){ return typeid *this;}
You are unique. Just like everybody else.
Visit the ROAD Programming Website for more programming help.
#define RESOURCE 0x01#define ENEMY 0x02#define ALLY 0x04#define BLANK 0x08#define HARVEST RESOURCE | ALLY#define ATTACK ENEMY | ALLY...void CUnit::ReactToRightClick (int x, int y){ dword dwCombo; dwCombo = GetUnitType (x, y); dwCombo |= m_dwType; if (dwCombo == HARVEST) { HarvestResource (x, y); } else if (dwCombo == ATTACK) { AttackUnit (x, y); } else { MoveTo (x, y); }}