//assists the player in performing their actions. //Actions are: "Fire", "Reload", "Switch"(weapons), "Hunker", "Item", //"Other". //"Fire" prompts a target selection out of the current enemy //combatants. //Reload resets the current weapon's ammo counter to full, and //decrements magazines by 1. //"Switch" prompts a weapon selection when applicable. //"Hunker" Puts the player in hunkered cover, offering +25 defense. //"Item" prompts an item selection when applicable. //"Other" prompts a description of the action, and prints it. void playerTurn (int activeEnemies, int* player) { int ha = 4; //Number of Half-Actions a player has per turn. //This is an artifact of the way the pen & paper game is played. char* action = malloc(sizeof(char)*8); while (ha > 0) { //ask player what to do printf ("====================\n"); printf("Half-Actions Remaining: %d\n", ha); printf ("What would you like to do?:\n"); printf (" Fire [1]|| Reload [2]|| Switch[1]\nHunker [2]|| Item [1]|| Other [1]\n"); scanf("%s", action); printf("Action selected: \"%s\"\n", action); if (strcmp(action, "Fire") == 0 || strcmp(action, "fire") == 0 || strcmp(action, "f") == 0 || strcmp(action, "F") == 0) { printf("---Fire---\n"); pAttack(playerSelect(activeEnemies), player[7], player[8]);//target, miss, damage ha--; } else if (action == "Reload" || action == "reload" || action == "R" || action == "r") { printf("---Reload---\n"); if (ha > 1) { ha-=2; if (player[11] > 0) { player[9] = player[10]; player[11]--; printf("Lock 'n' load!\n"); } else { printf("No Mags!\n"); } } else { printf("Not enough time!\n"); } } else if (action == "Switch" || action == "switch" || action == "S" || action == "s") { printf("---Switch---\n"); printf("You only have 1 weapon."); /*if (ha > 1) { ha-- switch(); }*/ } else if (action == "Hunker" || action == "hunker" || action == "H" || action == "h") { printf("---Hunker---\n"); if (ha>2) { ha-=2; printf("You take cover, +25 Defense"); player[13] = 25; //isHunkered = true; } } else if (action == "Item" || action == "item" || action == "I" || action == "i") { printf("---Item---\n"); printf("No items :(\n"); } else if (action == "Other" || action == "other" || action == "O" || action == "o") { printf("---Other---\n"); if (ha > 1) { printf("Some time is spent, -1 half action\n"); } } } }
BOOL TMonsterAIElement::ApplyElementNightmareWarp(int iIndex, int iTargetIndex, TMonsterAIState * pAIState) { LPOBJ lpObj = &gObj[iIndex]; BYTE x = this->m_iX; BYTE y = this->m_iY; PMSG_MAGICATTACK_RESULT pAttack(6,iIndex,iIndex); if ( lpObj->Type == OBJ_USER ) DataSend(iIndex,(unsigned char *)&pAttack,pAttack.h.size); MsgSendV2(lpObj,(unsigned char*)&pAttack,pAttack.h.size); LogAddC(2, "[%s] Warp [%d,%d] -> [%d,%d]", lpObj->Name, lpObj->X, lpObj->Y, x, y); gObjTeleportMagicUse(iIndex,x,y); lpObj->TargetNumber = -1; return FALSE; }
void Calculator::calculateAttacks(){ AttacksMap attacks; BorderBattlesMap battles; for(int i=0; i<attackCommands_.size(); i++){ pACommand c = attackCommands_[i]; int from = c->getFromId(); int to = c->getToId(); UnitsId id = c->getUnitId(); int no = c->getNoUnits(); PlayerId attacker = Map::getInstance().getTerritory(from)->ownership(); AttacksMap::iterator iter; if((iter = attacks.find(Pair(from,to))) != attacks.end()){ iter.value()->addUnit(id, no); continue; } if((iter = attacks.find(Pair(to,from))) != attacks.end()){ battles.insert(Pair(to,from), pBorderBattle( new BorderBattle(iter.value(), pAttack(new Attack(from, to, attacker, id, no))))); attacks.erase(iter); continue; } BorderBattlesMap::iterator iter2; if((iter2 = battles.find(Pair(from,to))) != battles.end()){ iter2.value()->attack1()->addUnit(id,no); continue; } if((iter2 = battles.find(Pair(to,from))) != battles.end()){ iter2.value()->attack2()->addUnit(id,no); continue; } attacks.insert(Pair(from,to), pAttack(new Attack(from,to,attacker,id,no))); } //print(attacks, battles); for(BorderBattlesMap::iterator i = battles.begin(); i!=battles.end(); ++i){ int n1 = i.value()->n(1); int n2 = i.value()->n(2); /*FileLogger::write("Battle"); FileLogger::write(QString::number(i.value()->n(1)) .append(" vs ").append(QString::number(i.value()->n(2))));*/ pAttack a = i.value()->getWinner(); /*FileLogger::write(QString::number(i.value()->n(1)) .append(" vs ").append(QString::number(i.value()->n(2))));*/ int terrId = combineInts(a->from(), a->to()); int aLoss; int dLoss; if(i.value()->n(1) == 0){ dLoss = n1; aLoss = n2 - i.value()->n(2); } else { dLoss = n2; aLoss = n1 - i.value()->n(1); } raports_.push_back( RaportFactory::getInstance().create( BATTLE, BORDER_BATTLE, terrId, aLoss, dLoss)); attacks.insert(Pair(a->from(), a->to()), a); } battles.clear(); //print(attacks, battles); for(AttacksMap::iterator i = attacks.begin(); i!=attacks.end(); ++i){ pAttack a = i.value(); int to = i.key().second; AssaultMap::iterator iter = assaults_.find(to); if(iter == assaults_.end()){ assaults_.insert(to, a); } else { iter.value()->addUnits(a->units()); } } //printAssaults(assaults_); }