本文整理汇总了C++中Nation::add_income方法的典型用法代码示例。如果您正苦于以下问题:C++ Nation::add_income方法的具体用法?C++ Nation::add_income怎么用?C++ Nation::add_income使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nation
的用法示例。
在下文中一共展示了Nation::add_income方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void CampaignEastWest::plot_a2_next_day()
{
// give food, money and live point if lack
if( !nation_array.is_deleted(plot_enemy_nation_recno))
{
Nation *monsterNation = nation_array[plot_enemy_nation_recno];
if( monsterNation->cash < 1000.0f )
monsterNation->add_income(INCOME_CHEAT, 10.0f, 1);
else if( monsterNation->cash < 5000.0f )
monsterNation->add_income(INCOME_CHEAT, 2.0f, 1);
if( monsterNation->food < 1000.0f )
monsterNation->add_food( 10.0f );
else if( monsterNation->food < 5000.0f )
monsterNation->add_food( 2.0f );
if( monsterNation->live_points < 1000.0f )
monsterNation->change_live_points( 10.0f );
else if( monsterNation->live_points < 5000.0f )
monsterNation->change_live_points( 2.0f );
}
}
示例2: sell_firm
void Firm::sell_firm(char remoteAction)
{
if( !remoteAction && remote.is_enable() )
{
// packet structure : <firm recno>
short *shortPtr = (short *)remote.new_send_queue_msg(MSG_FIRM_SELL, sizeof(short));
*shortPtr = firm_recno;
return;
}
//------- sell at 50% of the original cost -------//
Nation* nationPtr = nation_array[nation_recno];
float sellIncome = (float) firm_res[firm_id]->setup_cost / 2 * (int) hit_points / (int) max_hit_points();
float sellLiveIncome = (float) firm_res[firm_id]->setup_live_points_cost / 2 * (int) hit_points / (int) max_hit_points();
nationPtr->add_income(INCOME_SELL_FIRM, sellIncome);
if( nationPtr->is_monster() )
nationPtr->change_live_points( sellLiveIncome );
se_res.sound(center_x, center_y, 1, 'F', firm_id, "SELL" );
firm_array.del_firm(firm_recno);
}
示例3: being_killed
//------- Begin of function Firm::being_killed ------//
//
// <BaseObj*> attackerObj - this can be NULL if the attacker no longer
// exists (the damage is caused by a bullet.)
//
void Firm::being_killed(BaseObj* attackerObj)
{
se_res.sound(center_x, center_y, 1, 'F', firm_id, "DIE" );
if( nation_recno == nation_array.player_recno && attackerObj ) //BUGHERE
news_array.firm_destroyed(firm_recno, attackerObj);
// ######## begin Gilbert 17/6 ########//
if( nation_recno == 0 && firm_id == FIRM_LAIR && is_monster() )
{
news_array.monster_firm_destroyed( monster_id(), center_x, center_y );
}
// ######## end Gilbert 17/6 ########//
if( nation_recno )
{
if( attackerObj && attackerObj->nation_recno )
nation_array[attackerObj->nation_recno]->enemy_firm_destroyed++;
if( nation_recno )
nation_array[nation_recno]->own_firm_destroyed++;
}
//-----------------------------------------//
if( attackerObj && attackerObj->nation_recno )
{
Nation* attackerNation = nation_array[attackerObj->nation_recno];
//-- destroying a monster firm raise the attacking nation's reputation --//
if( is_monster() )
{
float repIncrease = (float) max_hit_points() / 600;
//-- if the lair is enslaving the towns, increase the reputation bonus --//
if( cast_to_FirmLair() )
{
int tributeAmount = cast_to_FirmLair()->collect_town_tribute(0);
repIncrease += (float) tributeAmount / 600;
}
attackerNation->change_reputation(repIncrease);
//--- when destroying an enslaving Fryhtan lair, the independent towns enslaved by it will reduce its resistance towards you by 30 points ---//
if( cast_to_FirmLair() )
{
int i;
Town* townPtr;
for( i=0 ; i<linked_town_count ; i++ )
{
if(town_array.is_deleted(linked_town_array[i]))
continue;
townPtr = town_array[linked_town_array[i]];
//--- if it is a linked independent town ---//
if( townPtr->nation_recno == 0 &&
// ####### begin Gilbert 9/3 ########//
nation_recno &&
// ####### end Gilbert 9/3 ########//
townPtr->resistance(nation_recno) < MONSTER_COLLECT_TOWN_TRIBUTE_LOYALTY )
{
townPtr->change_resistance(attackerObj->nation_recno, -30);
}
}
}
}
//------ destroyng a building gives money ------//
float killMoney = (float) (firm_res[firm_id]->setup_cost + firm_recno%100) / 3; // add some randomness
attackerNation->add_income( INCOME_TREASURE, killMoney );
attackerNation->increased_cash = killMoney;
}
firm_array.del_firm(firm_recno);
}
示例4: process_accepted_reply
//.........这里部分代码省略.........
{
memset(&talkMsg, 0, sizeof(TalkMsg));
talkMsg.to_nation_recno = (char) talk_para1;
talkMsg.from_nation_recno = to_nation_recno;
talkMsg.talk_id = TALK_END_FRIENDLY_TREATY;
talk_res.send_talk_msg( &talkMsg, COMMAND_AUTO );
}
//--- send a declare war message to the target kingdom ---//
memset(&talkMsg, 0, sizeof(TalkMsg));
talkMsg.to_nation_recno = (char) talk_para1;
talkMsg.from_nation_recno = to_nation_recno;
talkMsg.talk_id = TALK_DECLARE_WAR;
talk_res.send_talk_msg( &talkMsg, COMMAND_AUTO );
//----------------------------------------------------//
goodRelationDec = 10;
}
break;
case TALK_REQUEST_BUY_FOOD:
{
int buyCost = talk_para1 * talk_para2 / 10;
fromNation->add_food( (float) talk_para1 );
fromNation->add_expense( EXPENSE_IMPORTS, (float) buyCost, 0 );
toNation->consume_food( (float) talk_para1 );
toNation->add_income( INCOME_EXPORTS, (float) buyCost, 0 );
break;
}
case TALK_DECLARE_WAR:
toRelation->started_war_on_us_count++; // how many times this nation has started a war with us, the more the times the worse this nation is.
toNation->set_relation_status(from_nation_recno, RELATION_HOSTILE);
fromRelation->set_never_accept_until_date(TALK_REQUEST_CEASE_WAR, 150);
toRelation->set_never_accept_until_date(TALK_REQUEST_CEASE_WAR, 150);
fromRelation->set_never_accept_until_date(TALK_GIVE_TRIBUTE, 300);
toRelation->set_never_accept_until_date(TALK_GIVE_TRIBUTE, 300);
//--- decrease reputation of the nation which declares war ---//
if( toNation->reputation > 0 )
fromNation->change_reputation( -toNation->reputation * 20 / 100 );
break;
case TALK_GIVE_TRIBUTE:
case TALK_GIVE_AID:
fromNation->give_tribute( to_nation_recno, talk_para1 );
break;
case TALK_DEMAND_TRIBUTE:
case TALK_DEMAND_AID:
toNation->give_tribute( from_nation_recno, talk_para1 );
goodRelationDec = talk_para1/200;
break;
case TALK_EXCHANGE_TECH:
fromNation->give_tech( to_nation_recno, talk_para1, talk_para3 ); // give this tech to the target nation