📄 te_team_victory.cpp
字号:
vc = (victory_condition *) editbox->GetUserNumber (0);
vc->set_points (editbox->GetInteger ());
update_team_victory_window ();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#endif
static void set_points_required_for_victory (long, short hittype, C_Base *ctrl)
{
C_EditBox
*editbox;
if(hittype != DIK_RETURN)
return;
editbox = (C_EditBox *) ctrl;
current_tactical_mission->set_points_required (editbox->GetInteger ());
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static void delete_tactical_object (long, short, C_Base *)
{
C_Base
*parent;
victory_condition
*next_vc,
*vc;
unsigned char
*src;
int
id,
x, y,
old_team,
width,
height,
loop;
C_Squadron
*c_squadron;
C_ATO_Flight
*c_flight;
SquadronClass
*squadron;
FlightClass
*flight;
VU_ID
vu_id;
parent = gPopupMgr->GetCallingControl ();
gPopupMgr->CloseMenu ();
id = parent->GetID ();
if (id == ATO_ALL_TREE)
{
c_flight = (C_ATO_Flight *) ((C_TreeList *) parent)->GetLastItem ()->Item_;
flight = (Flight) FindEntity (c_flight->GetVUID());
if (flight)
{
flight->Remove ();
gGps->Update ();
}
}
else if (id == ALL_SQUADRON_TREE)
{
// Its a squadron :-)
c_squadron = (C_Squadron *) ((C_TreeList *) parent)->GetLastItem ()->Item_;
squadron = (Squadron) FindEntity (c_squadron->GetVUID());
if (squadron)
{
tactical_remove_squadron (squadron);
squadron->Remove ();
gGps->Update ();
}
}
else if (id >= 3000000)
{
// Its a victory condition - delete it.
vc = (victory_condition *) parent->GetUserNumber (0);
gMapMgr->RemoveVC(vc->get_team(),vc->get_number());
delete vc;
evaluate_filter ();
update_team_victory_window ();
}
else
{
// Its actually a team we are trying to delete - just overloaded the function a little :-)
old_team = 0;
for (loop = 1; loop < 8; loop ++)
{
if (TeamInfo[loop])
{
old_team ++;
}
}
if (old_team > 1) // must have some old team if you want to delete it :-)
{
for (loop = 0; loop < 8; loop ++)
{
if (parent == team_name[loop])
{
RemoveTeam (team_mapping[loop]);
// Need to remove Team Ownership on land.
src = TheCampaign.CampMapData;
width = TheCampaign.TheaterSizeX / MAP_RATIO;
height = TheCampaign.TheaterSizeY / MAP_RATIO;
for (y = 0; y < height; y ++)
{
for (x = 0; x < width; x ++)
{
if (x & 1)
{
old_team = (src[(y * width + x) / 2] & 0xf0) >> 4;
if (old_team == team_mapping[loop])
{
src[(y * width + x) / 2] &= 0x0f;
}
}
else
{
old_team = src[(y * width + x) / 2] & 0xf;
if (old_team == team_mapping[loop])
{
src[(y * width + x) / 2] &= 0xf0;
}
}
}
}
// Need to Fix all Objectives / Squadrons
delete_all_units_for_team (team_mapping[loop]);
// Remove all of this team Victory Conditions
vc = current_tactical_mission->get_first_unfiltered_victory_condition ();
while (vc)
{
next_vc = current_tactical_mission->get_next_unfiltered_victory_condition ();
if (vc->get_team () == team_mapping[loop])
{
gMapMgr->RemoveVC(vc->get_team(),vc->get_number());
delete vc;
}
vc = next_vc;
}
update_team_victory_window ();
break;
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_add_victory_condition (VU_ID id,C_Base *)
{
CampEntity ent;
victory_condition *vc;
TREELIST *item;
ent=(CampEntity)vuDatabase->Find(id);
if(!ent)
return;
if(ent->IsObjective() || ent->IsFlight() || ent->IsBattalion())
{
vc = new victory_condition (current_tactical_mission);
vc->set_team (gSelectedTeam);
vc->set_vu_id (id);
if(ent->IsObjective())
{
vc->set_type (vt_degrade);
vc->set_tolerance(10); // default to 100%
}
else if(ent->IsFlight())
{
vc->set_type (vt_intercept);
vc->set_tolerance(((Flight)ent)->GetTotalVehicles()); // default to ALL
}
else
{
vc->set_type (vt_attrit);
vc->set_tolerance(10); // default to 100%
}
vc->set_sub_objective(-1); // NO individual target assigned
if(gVCTree)
{
vc->control=MakeVCControl(vc);
// Add VC control to VC tree
item=gVCTree->CreateItem(vc->get_number(),C_TYPE_ITEM,vc->control);
if(item)
{
gVCTree->AddItem(gVCTree->GetRoot(),item);
((C_Victory*)vc->control)->SetOwner(item);
vc->control->SetReady(1);
vc->control->SetClient(gVCTree->GetClient());
vc->control->SetParent(gVCTree->Parent_);
vc->control->SetSubParents(gVCTree->Parent_);
gVCTree->RecalcSize();
if(gVCTree->Parent_)
gVCTree->Parent_->RefreshClient(gVCTree->GetClient());
}
}
if (gMapMgr)
{
gMapMgr->AddVC (vc);
}
UpdateVCOptions(vc);
update_team_victory_window ();
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int get_tactical_number_of_teams (void)
{
int
num,
loop;
num = 0;
for (loop = 1; loop < 8; loop ++)
{
if (TeamInfo[loop])
{
num ++;
}
}
return num;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void add_vc_air_unit (long, short, C_Base *)
{
C_Base
*parent;
victory_condition
*vc;
FlightClass
*flight;
VU_ID
vu_id;
C_ATO_Flight
*c_flight;
parent = gPopupMgr->GetCallingControl ();
gPopupMgr->CloseMenu ();
c_flight = (C_ATO_Flight *) ((C_TreeList *) parent)->GetLastItem ()->Item_;
flight = (Flight) FindEntity (c_flight->GetVUID());
if (flight)
{
vc = new victory_condition (current_tactical_mission);
vc->set_team (flight->GetTeam ());
vc->set_type (vt_intercept);
vc->set_vu_id (vu_id);
if (gMapMgr)
{
gMapMgr->AddVC (vc);
}
update_team_victory_window ();
gMainHandler->EnableWindowGroup (3400);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void add_all_vcs_to_ui (void)
{
TREELIST *item;
victory_condition *vc;
if(!gVCTree)
return;
gVCTree->DeleteBranch(gVCTree->GetRoot());
if (gMapMgr)
{
vc = current_tactical_mission->get_first_unfiltered_victory_condition ();
while (vc)
{
// Add VC Icons to Map
// Init VC control
vc->control=MakeVCControl(vc);
// Add VC control to VC tree
item=gVCTree->CreateItem(vc->get_number(),C_TYPE_ITEM,vc->control);
if(item)
{
gVCTree->AddItem(gVCTree->GetRoot(),item);
((C_Victory*)vc->control)->SetOwner(item);
vc->control->SetReady(1);
vc->control->SetClient(gVCTree->GetClient());
vc->control->SetParent(gVCTree->Parent_);
vc->control->SetSubParents(gVCTree->Parent_);
}
gMapMgr->AddVC (vc);
UpdateVCOptions(vc);
vc = current_tactical_mission->get_next_unfiltered_victory_condition ();
}
}
gVCTree->RecalcSize();
if(gVCTree->Parent_)
gVCTree->Parent_->RefreshClient(gVCTree->GetClient());
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// returns LISTBOX ID to use
long EvaluateSituation()
{
short i,teams,winners,higuys,myteam;
long TeamScores[NUM_TEAMS];
long VictoryPoints,HighestPoints;
memset(TeamScores,0,sizeof(TeamScores));
teams=0;
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
{
TeamScores[i]=GetCurrentVCScore(i);
teams++;
}
}
winners=0;
HighestPoints=0;
VictoryPoints=current_tactical_mission->get_points_required();
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamScores[i] >= VictoryPoints)
winners++;
if(TeamScores[i] > HighestPoints)
HighestPoints=TeamScores[i];
}
higuys=0;
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamScores[i] >= HighestPoints)
higuys++;
}
// Handle 1 team stuff
if(teams < 2)
{
if(winners)
return(TAC_SUCCESS);
else
return(TAC_FAILURE);
}
else if(winners) // Handle Multiple team stuff
{
myteam=FalconLocalSession->GetTeam();
if(TeamScores[myteam] >= VictoryPoints) // We are among the winners
{
if(TeamScores[myteam] >= HighestPoints) // We are on top
{
if(higuys > 1) // Draw... oh well
return(TAC_DRAW);
else
{
if(winners > 1)
return(TAC_MARGINAL_WIN);
else
return(TAC_DECISIVE_WIN);
}
}
else
return(TAC_DEFEAT);
}
else // We are a loser :)
{
return(TAC_MAJOR_DEFEAT);
}
}
return(TAC_STALEMATE);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// This is called to open the EndGame window after returning to the UI
void EndGameEvaluation()
{
C_Window *win;
C_ListBox *lbox;
LISTBOX *lbitem;
long eval;
win=gMainHandler->FindWindow(TAC_END_WIN);
{
UpdateVCScoring(TAC_END_WIN,0);
lbox=(C_ListBox*)win->FindControl(TAC_WIN_TITLE);
if(lbox)
{
eval=EvaluateSituation();
lbox->SetValue(eval);
lbitem=lbox->FindID(eval);
if(lbitem && lbitem->Label_)
{
win->HideCluster(lbitem->Label_->GetUserNumber(1));
win->HideCluster(lbitem->Label_->GetUserNumber(2));
win->UnHideCluster(lbitem->Label_->GetUserNumber(0));
}
}
win->RefreshWindow();
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void TriggerTacEndGame (void)
{
ShowGameOverWindow=1;
if(gMainHandler && ShowGameOverWindow)
{
C_Window *win;
TheCampaign.EndgameResult=1;
SetTimeCompression(0);
if(gMainHandler->GetWindowFlags(CP_COUNTDOWN_WIN) & C_BIT_ENABLED)
{
win=gMainHandler->FindWindow(CP_COUNTDOWN_WIN);
if(win)
{
CancelCampaignCompression();
gMainHandler->HideWindow(win);
}
}
PostMessage(gMainHandler->GetAppWnd(),FM_OPEN_GAME_OVER_WIN,game_TacticalEngagement,0);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void OpenTEGameOverWindow()
{
if(!gMainHandler)
return;
EndGameEvaluation();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void TacEngGameOver ()
{
if (current_tactical_mission)
{
current_tactical_mission->set_game_over (1);
check_victory_conditions ();
TriggerTacEndGame(); // Tell UI to open window
OTWDriver.SetFrontTextFlags(OTWDriver.GetFrontTextFlags() | SHOW_TE_SCORES);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Remote version...
void TacEngSetVCCompleted(long ID, int value)
{
victory_condition *vc;
if(current_tactical_mission)
{
vc=current_tactical_mission->get_first_unfiltered_victory_condition();
while(vc)
{
if(vc->get_number() == ID)
{
vc->set_active(value);
}
vc=current_tactical_mission->get_next_unfiltered_victory_condition();
}
gRefreshScoresList=1;
if(!current_tactical_mission->get_game_over() && check_victory_conditions())
{
TriggerTacEndGame(); // Tell UI to open window
OTWDriver.SetFrontTextFlags(OTWDriver.GetFrontTextFlags() | SHOW_TE_SCORES);
}
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Host Version
void CheckForVictory (void)
{
if(current_tactical_mission)
{
// Victory Condition Checks
if(!current_tactical_mission->get_game_over() && check_victory_conditions())
{ // Kevin, when you transmit the EndgameResult variable... there is a duplicate section of code to this in
// te_team_victory.cpp at the bottom
TriggerTacEndGame(); // Tell UI to open window
OTWDriver.SetFrontTextFlags(OTWDriver.GetFrontTextFlags() | SHOW_TE_SCORES);
}
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -