Code: Show/Hide void botInfo::Kill(Player *p, Player *k)
{ // cycle boxes searching for killer's box for (int box = 1; box <= MAX_BOXES; box++) if ((BoxPilot[box][0]) && (BoxPilot[box][1])) if ((k->name == BoxPilot[box][0]->name) || (k->name == BoxPilot[box][1]->name)) { // Update rank stats PlayerRank *prank = rankings.FindRank(p->name); PlayerRank *krank = rankings.FindRank(k->name); LogPlayerGame(p); LogPlayerGame(k); if (prank) { prank->updated = true; prank->data.deaths++; } if (krank) { krank->updated = true; krank->data.kills++; } if ((prank) && (krank)) { double kRold = krank->data.rating; double kdiff = prank->data.rating - kRold; double kwe = kdiff/400; kwe = 1/(pow(10,kwe) + 1); int kRnew = kRold + (30*(1-kwe)); krank->data.rating = kRnew; krank->updated = true; double pRold = prank->data.rating; double pdiff = krank->data.rating - pRold; double pwe = pdiff/400; pwe = 1/(pow(10,pwe) + 1); int pRnew = pRold + (30*(0-pwe)); prank->data.rating = pRnew; prank->updated = true; } rankings.entries_changed = true; rankings.ResortPlayers(); // killer gets full charge sendPrivate(k, "*prize #13"); // warp killer to corner String w = "*warpto "; w += BoxCoordX3[box]; w += " "; w += BoxCoordY3[box]; sendPrivate(k,w); int kkrank=rankings.ranks.total + 1, pprank=rankings.ranks.total + 2, kkrating=1500; int pprating=1500, kkkill=1, ppkill=0, kkdeath=0, ppdeath=1; if (prank) { pprank = prank->data.rank; pprating = prank->data.rating; ppkill = prank->data.kills; ppdeath = prank->data.deaths; } if (krank) { kkrank = krank->data.rank; kkrating = krank->data.rating; kkkill = krank->data.kills; kkdeath = krank->data.deaths; } // increment winning streak for killer or set winner as killer with streak 1 if (winner[box]) if (k->name == winner[box]->name) wincount[box]++; else { winner[box] = k; wincount[box] = 1; } else { winner[box] = k; wincount[box] = 1; } // display killer/killed stats char str[256]; /* aaaagh-BAD-NEWS kb Palace (energy 169) (won 2 in a row) (Palace Dmg Dealt: Total 5000, Bomb 1300, Bullet 0400) (Rank 1, Rating 1500, K/D 14-3) (aaaagh-BAD-NEWS Dmg Dealt: Total 4030, Bomb 2040, Bullet 1000) (Rank 2, Rating 1750, K/D 51-6) */ sprintf(str, "*arena %s kb %s (energy %d) (won %d in a row)", p->name, k->name, k->energy, wincount[box]); sendPublic(str); sprintf(str, "*arena (%-20s Dmg Dealt: Total %0004d, Bomb %0004d, Bullet %0004d) (Rank %d, Rating %d, K/D %d-%d)", p->name, get_tag(p,DMG_TOTAL_DEALT), get_tag(p,DMG_BOMB_DEALT), get_tag(p,DMG_BULLET_DEALT), pprank, pprating, ppkill, ppdeath); sendPublic(str); sprintf(str, "*arena (%-20s Dmg Dealt: Total %0004d, Bomb %0004d, Bullet %0004d) (Rank %d, Rating %d, K/D %d-%d)", k->name, get_tag(k,DMG_TOTAL_DEALT), get_tag(k,DMG_BOMB_DEALT), get_tag(k,DMG_BULLET_DEALT), kkrank, kkrating, kkkill, kkdeath); sendPublic(str); // reset damage stats set_tag(p, DMG_BULLET_DEALT, 0); set_tag(p, DMG_BOMB_DEALT, 0); set_tag(p, DMG_TOTAL_DEALT, 0); set_tag(k, DMG_BULLET_DEALT, 0); set_tag(k, DMG_BOMB_DEALT, 0); set_tag(k, DMG_TOTAL_DEALT, 0); // if theres a pilot next in line spec killed and put next pilot in if (nextcount[box] > 0) { // spec killed sendPrivate(p,"*spec"); sendPrivate(p,"*spec"); sendPrivate(next[box][0],"*setship 1"); String u = "*warpto "; u += BoxCoordX2[box]; u += " "; u += BoxCoordY2[box]; sendPrivate(next[box][0],u); // incoming pilot gets killed's box slot if (p->name == BoxPilot[box][0]->name) BoxPilot[box][0] = next[box][0]; else if (p->name == BoxPilot[box][1]->name) BoxPilot[box][1] = next[box][0]; // move up the next line MoveUp(0,box); } break; } } |