📄 tac_class.cpp
字号:
while (current_vc)
{
if (test_filter (current_vc, filter, team))
{
break;
}
current_vc = current_vc->succ;
}
victory_condition::leave_critical_section ();
return current_vc;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
victory_condition *tactical_mission::get_first_unfiltered_victory_condition (void)
{
victory_condition::enter_critical_section ();
current_vc = conditions;
victory_condition::leave_critical_section ();
return current_vc;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
victory_condition *tactical_mission::get_next_unfiltered_victory_condition (void)
{
victory_condition::enter_critical_section ();
current_vc = current_vc->succ;
victory_condition::leave_critical_section ();
return current_vc;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_mission::set_points_required (int value)
{
points_required = value;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int tactical_mission::get_points_required (void)
{
return points_required;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_mission::evaluate_victory_conditions (void)
{
UISendMsg *vcdone;
victory_condition
*vc;
int
count,
per,
old_active,
changed=0;
Objective
objective;
Unit
unit;
victory_condition::enter_critical_section ();
vc = conditions;
count = 1;
while (vc)
{
if(!vc->active)
{
old_active = vc->active;
switch (vc->type)
{
case vt_occupy:
{
objective = (Objective) FindEntity (vc->id);
if (objective && objective->IsObjective())
{
if (vc->team == objective->GetOwner())
vc->active = TRUE;
//else
// vc->active = FALSE;
}
break;
}
case vt_destroy:
{
objective = (Objective) FindEntity (vc->id);
if (objective && objective->IsObjective())
{
int i;
int classID;
uchar origtype;
ObjClassDataType* oc;
oc = objective->GetObjectiveClassData();
if(oc)
{
classID = objective->GetFeatureID(vc->feature_id);
origtype=Falcon4ClassTable[classID].vuClassData.classInfo_[VU_TYPE];
for(i=0;i<oc->Features;i++)
{
classID = objective->GetFeatureID(i);
if(Falcon4ClassTable[classID].vuClassData.classInfo_[VU_TYPE] == origtype)
if(objective->GetFeatureStatus(i) == 3)
{
vc->active=TRUE;
break;
}
}
}
}
break;
}
case vt_degrade:
{
objective = (Objective) FindEntity (vc->id);
if (objective && objective->IsObjective())
{
//MonoPrint ("%08x = %d ", objective, objective->GetObjectiveStatus ());
if (objective->GetObjectiveStatus () <= 100 - vc->tolerance * 10)
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
//else
//{
// //MonoPrint ("FALSE\n");
// vc->active = FALSE;
//}
}
break;
}
case vt_attrit:
{
unit = (Unit) FindEntity (vc->id);
if (unit)
{
if(!unit->IsUnit())
break;
per = 10 * unit->GetTotalVehicles () / unit->GetFullstrengthVehicles ();
// MonoPrint ("%08x = %d:%d %d%% ", unit, unit->GetFullstrengthVehicles (), unit->GetTotalVehicles (), per);
if (per <= (10 - vc->tolerance))
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
//MonoPrint ("FALSE\n");
vc->active = FALSE;
}
}
else
{
// MonoPrint ("Unit Destroyed %08x = %d\n", unit);
vc->active = TRUE;
}
break;
}
case vt_intercept:
{
unit = (Unit) FindEntity (vc->id);
if (unit)
{
if(!unit->IsUnit())
break;
if (!vc->max_vehicles)
{
vc->max_vehicles = unit->GetTotalVehicles ();
}
}
if ((unit) && (vc->max_vehicles))
{
// MonoPrint ("%08x = %d:%d ", unit, vc->number, unit->GetTotalVehicles ());
if (vc->max_vehicles - unit->GetTotalVehicles () >= vc->tolerance)
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
// MonoPrint ("FALSE\n");
vc->active = FALSE;
}
}
else
{
// MonoPrint ("Unit Destroyed %08x = %d\n", unit);
vc->active = TRUE;
}
break;
}
//default:
//{
// vc->active = FALSE;
//}
}
if (old_active != vc->active)
{
update_team_victory_window();
//MonoPrint ("Victory Condition %d is now %s\n", count, (vc->active?"TRUE":"FALSE"));
changed=1;
// Send message to remote players
if(TheCampaign.IsMaster() && gCommsMgr->Online())
{
vcdone=new UISendMsg(FalconNullId,FalconLocalGame);
vcdone->dataBlock.from=FalconLocalSessionId;
vcdone->dataBlock.msgType=UISendMsg::VC_Update;
vcdone->dataBlock.number=vc->get_number();
vcdone->dataBlock.value=vc->active;
FalconSendMessage(vcdone,TRUE);
}
}
}
count ++;
vc = vc->succ;
}
victory_condition::leave_critical_section ();
if(changed)
gRefreshScoresList=1;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#if 0 // NOT supported anymore -PJW
void tactical_mission::evaluate_parameters (void *arg_wp, double x, double y, double z, double s)
{
victory_condition
*vc;
int
old_active,
num,
count;
float
dp,
dt,
dx,
dy,
dv,
dz;
static float tos_table[] =
{
0,
5,
10,
20,
60,
120
},
airspeed_table[] =
{
0,
5,
10,
20,
50,
100
},
altitude_table[] =
{
50,
100,
200,
500,
1000
},
position_table[] =
{
0,
500,
1000,
2000,
5000,
10000
};
WayPointClass
*wp,
*first_wp;
wp = (WayPointClass *) arg_wp;
while ((wp) && (wp->GetPrevWP ()))
{
wp = wp->GetPrevWP ();
}
first_wp = wp;
victory_condition::enter_critical_section ();
vc = conditions;
count = 1;
while (vc)
{
old_active = vc->active;
if ((vc->type == vt_tos) || (vc->type == vt_airspeed) || (vc->type == vt_altitude) || (vc->type == vt_position))
{
wp = first_wp;
num = vc->data.steerpoint;
while ((wp) && (num > 1))
{
wp = wp->GetNextWP ();
num --;
}
wp->GetLocation (&dx, &dy, &dz);
dx = dx - x;
dy = dy - y;
dz = dz - z;
dp = sqrt (dx * dx + dy * dy);
}
switch (vc->type)
{
case vt_tos:
{
if ((fabs (dp) < 10000) && (fabs (dz) < 1000))
{
dt = ((float)wp->GetWPArrivalTime() - SimLibElapsedTime) / SEC_TO_MSEC;
//MonoPrint ("%d TOS %f ", count, dt);
if ((vc->tolerance >= 1) && (vc->tolerance <= 5) && (fabs (dt) < tos_table[vc->tolerance]))
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
//MonoPrint ("FALSE\n");
}
}
break;
}
case vt_airspeed:
{
if ((fabs (dp) < 10000) && (fabs (dz) < 1000))
{
dv = s - wp->GetWPSpeed ();
//MonoPrint ("%d AirSpeed %f ", count, dv);
if ((vc->tolerance >= 1) && (vc->tolerance <= 5) && (fabs (dt) < airspeed_table[vc->tolerance]))
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
//MonoPrint ("FALSE\n");
}
}
break;
}
case vt_altitude:
{
if ((fabs (dp) < 10000) && (fabs (dz) < 1000))
{
//MonoPrint ("%d Alititude %f ", count, dz);
if ((vc->tolerance >= 1) && (vc->tolerance <= 5) && (abs(dz) < altitude_table[vc->tolerance]))
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
//MonoPrint ("FALSE\n");
}
}
break;
}
case vt_position:
{
if ((fabs (dp) < 10000) && (fabs (dz) < 1000))
{
//MonoPrint ("%d Position %f ", count, dp);
if ((vc->tolerance >= 1) && (vc->tolerance <= 5) && (fabs (dp) < position_table[vc->tolerance]))
{
//MonoPrint ("TRUE\n");
vc->active = TRUE;
}
else
{
//MonoPrint ("FALSE\n");
vc->active = FALSE;
}
}
break;
}
}
if (old_active != vc->active)
{
//MonoPrint ("Victory Condition %d is now %s\n", count, (vc->active?"TRUE":"FALSE"));
}
count ++;
vc = vc->succ;
}
victory_condition::leave_critical_section ();
}
#endif
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_mission::calculate_victory_points(void)
{
victory_condition::enter_critical_section ();
victory_condition
*vc;
int
pts[8] =
{
0
};
vc = conditions;
while (vc)
{
if(vc->active)
{
pts[vc->team] += vc->points;
}
vc = vc->succ;
}
memcpy (team_pts, pts, sizeof(int) * 8);
victory_condition::leave_critical_section ();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int tactical_mission::determine_victor(void)
{
int
i;
UISendMsg
*vcdone;
if(get_game_over())
return(TRUE);
if(TheCampaign.GetCampaignTime() >= TheCampaign.GetTETimeLimitTime())
{
set_game_over(1);
if(TheCampaign.IsMaster() && gCommsMgr->Online())
{
vcdone=new UISendMsg(FalconNullId,FalconLocalGame);
vcdone->dataBlock.from=FalconLocalSessionId;
vcdone->dataBlock.msgType=UISendMsg::VC_GameOver;
FalconSendMessage(vcdone,TRUE);
}
return(TRUE);
}
if(points_required <= 0)
return(FALSE);
for (i = 0; i < 8;i++)
{
if(team_pts[i] >= points_required)
{
if(TheCampaign.IsMaster() && gCommsMgr->Online())
{
vcdone=new UISendMsg(FalconNullId,FalconLocalGame);
vcdone->dataBlock.from=FalconLocalSessionId;
vcdone->dataBlock.msgType=UISendMsg::VC_GameOver;
FalconSendMessage(vcdone,TRUE);
}
set_game_over(1);
return TRUE;
}
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int determine_tactical_rating(void)
{
if(current_tactical_mission)
{
return current_tactical_mission->determine_rating();
}
//I like to succeed :) BTW, we should never get here
return mr_success;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int tactical_mission::determine_rating(void)
{
int player_pts = 0;
int best_opp = 0;
evaluate_victory_conditions();
calculate_victory_points();
player_pts = team_pts[team];
for(int i = 0; i < 8; i++)
{
if( (team_pts[i] > best_opp) && (i != team) )
best_opp = team_pts[i]; }
if(player_pts >= points_required)
{
if(best_opp >= points_required)
{
if(player_pts > best_opp)
return mr_marginal_victory;
else if(player_pts < best_opp)
return mr_marginal_defeat;
else
return mr_tie;
}
else
{
if(TheCampaign.TE_type != tt_engagement)
return mr_success;
else
return mr_decisive_victory;
}
}
else
{
if(best_opp > points_required)
{
if(TheCampaign.TE_type != tt_engagement)
return mr_failure;
else
return mr_crushing_defeat;
}
else
return mr_stalemate;
}
//I like to succeed :) BTW, we should never get here
return mr_success;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -