void killAllTeam(int winner, bz_eTeamType teamToKill, bz_eTeamType teamToAward) { bz_APIIntList *playerList = bz_newIntList(); bz_getPlayerIndexList(playerList); for ( unsigned int i = 0; i < playerList->size(); i++ ){ int player = (*playerList)[i]; bz_BasePlayerRecord *PlayerRecord = bz_getPlayerByIndex(player); if (PlayerRecord->team == teamToKill) bz_killPlayer(player,0,winner); else if(PlayerRecord->team == teamToAward) bz_setPlayerWins(player, (bz_getPlayerWins(player)+2)); bz_freePlayerRecord(PlayerRecord); } bz_setTeamWins (teamToAward, (bz_getTeamWins(teamToAward)+1)); bz_setTeamLosses (teamToKill, (bz_getTeamLosses (teamToKill)+1)); }
void MapChangeEventHandler::process ( bz_EventData *eventData ) { if (!eventData) return; switch(eventData->eventType) { case bz_ePlayerJoinEvent: case bz_ePlayerPartEvent: { bz_PlayerJoinPartEventData_V1 *joinPart = (bz_PlayerJoinPartEventData_V1*)eventData; if ( joinPart->eventType == bz_ePlayerJoinEvent ) { if (startTime < 0) startTime = joinPart->eventTime; } else if (endCond == eNoPlayers) { if (!anyPlayers()) nextMap(); } } break; case bz_ePlayerDieEvent: { if (endCond != eMaxKillScore) break; bz_PlayerDieEventData_V1 *die = (bz_PlayerDieEventData_V1*)eventData; if ( bz_getPlayerWins(die->killerID) >= scoreCapLimit ) nextMap(); } break; case bz_eCaptureEvent: { if (endCond != eMaxCapScore) break; bz_CTFCaptureEventData_V1 *cap = (bz_CTFCaptureEventData_V1*)eventData; if ( bz_getTeamWins(cap->teamCapping) >= scoreCapLimit ) nextMap(); } break; case bz_eTickEvent: { if (endCond != eTimedGame && startTime >= 0) break; bz_TickEventData_V1 *tick = (bz_TickEventData_V1*)eventData; double timeDelta = tick->eventTime - startTime; if ( timeDelta >= timeLimit ) nextMap(); } break; case bz_eGetWorldEvent: { if (currentIndex < 0 ) break; bz_GetWorldEventData_V1 *world =(bz_GetWorldEventData_V1*)eventData; world->generated = false; world->worldFile = gameList[currentIndex].mapFile.c_str(); gameList[currentIndex].hasBeenPlayed = true; } break; case bz_eListServerUpdateEvent: { if (currentIndex < 0 ) break; bz_ListServerUpdateEvent_V1 *update =(bz_ListServerUpdateEvent_V1*)eventData; std::string desc = update->description.c_str(); desc = replace_all(desc,std::string("%M"),gameList[currentIndex].publicText); update->description = desc.c_str(); update->handled = true; } break; } }
void BountyHunter::Event (bz_EventData *eventData) { switch (eventData->eventType) { case bz_eFlagDroppedEvent: // This event is called each time a flag is dropped by a player. { bz_FlagDroppedEventData_V1* flagDropData = (bz_FlagDroppedEventData_V1*)eventData; // Get the abbreviation of the flag that was dropped to check if it was a team flag std::string flag = bz_getName(flagDropData->flagID).c_str(); // If the dropped flag is a team flag, keep track of who dropped it and when if (flag == "R*" || flag == "G*" || flag == "B*" || flag == "P*") { lastFlagCarrier = flagDropData->playerID; teamFlagDropped = flag; flagCarryTime = bz_getCurrentTime(); } } break; case bz_ePlayerDieEvent: // This event is called each time a tank is killed. { bz_PlayerDieEventData_V1* dieData = (bz_PlayerDieEventData_V1*)eventData; int victimID = dieData->playerID; int killerID = dieData->killerID; // If the player did not kill themselves, then calculate the bounty points if (victimID != killerID) { // Increment the consecutive kills of the killer if the player is not the server (player ID 253) if (killerID != 253) { consecutiveKills[killerID]++; } // If the person killed had more than 0 kills, calculate the bounty points if (consecutiveKills[victimID] > 0) { // This value will keep track of how many levels of a rampage a player has gotten where each level // is an increment of 6 kills int rampageMultiplier = consecutiveKills[victimID] / 5; // The rampage multiplier times two will be the amount of bounty points granted int bountyPoints = rampageMultiplier * 2; // Only reward bounty points if it's greater than 0 if (bountyPoints > 0) { // Set the player's new points and notify them bz_setPlayerWins(killerID, bz_getPlayerWins(killerID) + bountyPoints); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "%s earned %i bounty points stopping %s's rampage", bz_getPlayerByIndex(killerID)->callsign.c_str(), bountyPoints, bz_getPlayerByIndex(victimID)->callsign.c_str() ); } } // If the person killed was carrying a team flag less than 3 seconds ago, then reward the killer if (lastFlagCarrier == victimID && flagCarryTime + 3 > bz_getCurrentTime()) { // Store the team color std::string teamColor = ""; // Set the respective color judging by the team flag abbreviation if (teamFlagDropped == "R*") { teamColor = "red"; } else if (teamFlagDropped == "G*") { teamColor = "green"; } else if (teamFlagDropped == "B*") { teamColor = "blue"; } else if (teamFlagDropped == "P*") { teamColor = "purple"; } // Set the player's new points and notify them bz_setPlayerWins(killerID, bz_getPlayerWins(killerID) + 2); bz_sendTextMessagef(BZ_SERVER, killerID, "Shooting the %s team flag carrier has earned you 2 bounty points", teamColor.c_str()); } } // Reset the consecutive kills made by the player who just got killed consecutiveKills[victimID] = 0; } break; case bz_ePlayerJoinEvent: // This event is called each time a player joins the game { bz_PlayerJoinPartEventData_V1* joinData = (bz_PlayerJoinPartEventData_V1*)eventData; // Set a player's consecutive kills to 0 when they join in case the array has a null value consecutiveKills[joinData->playerID] = 0; } break; default: break; } }