void COSGCTRL::OnBnClickedAutotimeBtn() { CSetAutoTimeDlg dlg; dlg.m_duration = 10.0; if(dlg.DoModal() == IDCANCEL) return; //collect keyframe pointers from listcontrol std::vector<KeyFrame*> keys; for(int i = 0; i < m_ListCtrl.GetItemCount(); i++) { keys.push_back((KeyFrame*) m_ListCtrl.GetItemData(i)); } //run autoTime autoTime(keys,dlg.m_duration); //update listctrl CString str; for(int i = 0; i < m_ListCtrl.GetItemCount(); i++) { str.Format("%f",keys[i]->timeStamp); m_ListCtrl.SetItemText(i,TIME_COL,str); str.Format("%f",keys[i]->distFromPrev); m_ListCtrl.SetItemText(i,DISTANCE_COL,str); str.Format("%f",keys[i]->duration); m_ListCtrl.SetItemText(i,DURATION_COL,str); } }
void KOTHPlayerJoined::process(bz_EventData * eventData) { if (eventData->eventType != bz_ePlayerJoinEvent || !koth.enabled) return; autoTime(); return; }
void KOTHPlayerLeft::process(bz_EventData * eventData) { if (eventData->eventType != bz_ePlayerPartEvent || !koth.enabled) return; autoTime(); bz_PlayerJoinPartEventData_V1 *partData = (bz_PlayerJoinPartEventData_V1 *) eventData; if (partData->playerID == koth.id) { koth.id = -1; koth.team = eNoTeam; } return; }
void KeepAwayPlayerJoined ( bz_EventData *eventData ) { if (eventData->eventType != bz_ePlayerJoinEvent || !keepaway.enabled || keepaway.flagToKeep == "") return; bz_PlayerJoinPartEventData_V1 *joinData = (bz_PlayerJoinPartEventData_V1*)eventData; if (keepaway.flagToKeep == "Initiate") //first time server starts, first player initiates it. { keepaway.flagToKeep = getFlag(); keepaway.lastReminder = bz_getCurrentTime(); } autoTime(); if (oneTeam(eNoTeam)) // don't send message if not enough teams { keepaway.notEnoughTeams = true; return; } else keepaway.notEnoughTeams = false; if (keepaway.id == -1 && keepaway.enabled && keepaway.flagToKeep != "") { bz_sendTextMessagef (BZ_SERVER, joinData->playerID, "Keep Away flag is %s: find it and keep it for %i seconds!", convertFlag(keepaway.flagToKeep).c_str(), (int)keepaway.adjustedTime); if (keepaway.soundEnabled) bz_sendPlayCustomLocalSound(joinData->playerID,"hunt_select"); } if (keepaway.id != -1 && keepaway.enabled && keepaway.flagToKeep != "" && (joinData->record->team != keepaway.team || joinData->record->team == eRogueTeam)) { bz_sendTextMessagef (BZ_SERVER, joinData->playerID, "%s has Keep Away flag %s - kill him/her before time's up!", keepaway.callsign.c_str(), convertFlag(keepaway.flagToKeep).c_str()); if (keepaway.soundEnabled) bz_sendPlayCustomLocalSound(joinData->playerID,"flag_alert"); } if (keepaway.id != -1 && keepaway.enabled && keepaway.flagToKeep != "" && (joinData->record->team == keepaway.team && joinData->record->team != eRogueTeam)) { bz_sendTextMessagef (BZ_SERVER, joinData->playerID, "%s has Keep Away flag %s - protect him/her until time's up!", keepaway.callsign.c_str(), convertFlag(keepaway.flagToKeep).c_str()); if (keepaway.soundEnabled) bz_sendPlayCustomLocalSound(joinData->playerID,"teamgrab"); } return; }
void KeepAwayPlayerLeft( bz_EventData *eventData ) { if (eventData->eventType != bz_ePlayerPartEvent || !keepaway.enabled || keepaway.flagToKeep == "") return; autoTime(); bz_PlayerJoinPartEventData_V1 *partData = (bz_PlayerJoinPartEventData_V1*)eventData; if (partData->playerID == keepaway.id) { keepaway.id = -1; keepaway.team = eNoTeam; keepaway.toldFlagFree = false; } if (oneTeam(partData->record->team)) // team count check keepaway.notEnoughTeams = true; else keepaway.notEnoughTeams = false; return; }
bool KOTHCommands::handle(int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char *kingmessage = _message.c_str(); if (command == "kingsay") { if (koth.id != -1) bz_sendTextMessage(playerID, koth.id, kingmessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one attempting to be king right now."); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the koth commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if (command == "kothon") { koth.enabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is enabled."); return true; } if (command == "kothoff") { koth.enabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is disabled."); return true; } if (command == "kothsoundon") { koth.soundEnabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are enabled."); return true; } if (command == "kothsoundoff") { koth.soundEnabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are disabled."); return true; } if (command == "kothtimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMult = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier set to %i percent.", (int) (koth.timeMult * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier (%i) must be between 1 and 99 percent.", (int) (koth.timeMult * 100 + 0.5)); } autoTime(); return true; } if (command == "kothtimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMultMin = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum set to %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum must be between 1 and 99 percent."); } autoTime(); return true; } if (command == "kothstatus") { if (koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently enabled."); if (!koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently disabled."); if (koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently enabled."); if (!koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently disabled."); if (koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently enabled."); if (!koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently disabled."); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier = %i percent.", (int) (koth.timeMult * 100 + 0.5)); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier minimum = %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); int AdjTime = (int) (koth.adjustedTime + 0.5); bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time is currently set to: %i seconds", AdjTime); return true; } // explicit time command handler: if (command == "kothtime") { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0) { koth.TTH = inputvalue; autoTime(); int AdjTime = (int) (inputvalue + 0.5); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill hold time has been set to %i seconds.", AdjTime); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time invalid: must be between 1 and 7200 seconds."); } autoTime(); return true; } if (command == "kothautotimeon") { koth.autoTimeOn = true; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment on."); return true; } if (command == "kothautotimeoff") { koth.autoTimeOn = false; koth.adjustedTime = koth.TTH; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment off."); return true; } return false; }
bool KeepAwayCommands::SlashCommand ( int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char* keepermessage = _message.c_str(); if ( command == "kas" ) { if (keepaway.id != -1) bz_sendTextMessage (playerID, keepaway.id, keepermessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one keeping the flag right now."); return true; } if ( command == "kaf" ) { if (keepaway.id == -1) bz_sendTextMessagef (BZ_SERVER, playerID, "The Keep Away flag is: %s", convertFlag(keepaway.flagToKeep).c_str()); else bz_sendTextMessagef (BZ_SERVER, playerID, "%s has Keep Away flag: %s", keepaway.callsign.c_str(), convertFlag(keepaway.flagToKeep).c_str()); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the keepaway commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if ( command == "kasoundoff" ) { keepaway.soundEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are disabled."); return true; } if ( command == "kasoundon" ) { keepaway.soundEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are enabled."); return true; } if ( command == "kaflagresetoff" ) { keepaway.flagResetEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } if ( command == "kaflagreseton" ) { keepaway.flagResetEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); return true; } if ( command == "kaf+" ) { if (!keepaway.forcedFlags) // this will always create an open spot for getFlag(), if it's needed bz_removePlayerFlag (keepaway.id); keepaway.id = -1; keepaway.team = eNoTeam; keepaway.toldFlagFree = false; keepaway.flagToKeep = getFlag(); keepaway.lastReminder = bz_getCurrentTime(); bz_sendTextMessagef(BZ_SERVER, playerID, "Keep Away flag advanced to: %s", convertFlag(keepaway.flagToKeep).c_str()); return true; } if ( command == "kaon") { keepaway.enabled = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is enabled."); return true; } if ( command == "kaoff") { keepaway.enabled = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is disabled."); return true; } if ( command == "katimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMult = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier set to %i percent.", (int)(keepaway.timeMult*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier must be between 1 and 99 percent.", (int)(keepaway.timeMult*100 + 0.5)); autoTime(); return true; } if ( command == "katimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMultMin = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum set to %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum must be between 1 and 99 percent."); autoTime(); return true; } if ( command == "kastatus") { if (keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently enabled."); if (!keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently disabled."); if (keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently enabled."); if (!keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently disabled."); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier = %i percent.", (int)(keepaway.timeMult*100 + 0.5)); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier minimum = %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); int AdjTime = (int)(keepaway.adjustedTime + 0.5); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time is currently set to: %i seconds", AdjTime); if (keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is enabled."); if (!keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is disabled."); if (keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are enabled."); if (!keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are disabled."); if (keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); if (!keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } // explicit time command handler: if ( command == "katime" ) { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0 ) { keepaway.TTH = inputvalue; autoTime(); int AdjTime = (int)(inputvalue + 0.5); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away hold time has been set to %i seconds.", AdjTime); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time invalid: must be between 1 and 7200 seconds."); autoTime(); return true; } if ( command == "kaautotimeon") { keepaway.autoTimeOn = true; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment on."); return true; } if ( command == "kaautotimeoff") { keepaway.autoTimeOn = false; keepaway.adjustedTime = keepaway.TTH; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment off."); return true; } if ( command == "kaffon") { keepaway.forcedFlags = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags on."); return true; } if ( command == "kaffoff") { keepaway.forcedFlags = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags off."); return true; } return false; }