Пример #1
0
//------- Begin of function Tornado::hit_building -----//
//	building means firm or town
//
void Tornado::hit_building()
{
	short damageXLoc = damage_x_loc();
	short damageYLoc = damage_y_loc();
	if( damageXLoc < 0 || damageXLoc >= world.max_x_loc ||
		damageYLoc < 0 || damageYLoc >= world.max_y_loc)
		return;

	Location* locPtr = world.get_loc(damageXLoc, damageYLoc);

	if(locPtr->is_firm() )
//		&& firm_res[(firmPtr=firm_array[locPtr->firm_recno()])->firm_id]->buildable )
	{
		Firm *firmPtr = firm_array[locPtr->firm_recno()];
		firmPtr->hit_points -= attack_damage*2;

		if( !damage_player_flag && firmPtr->is_own() )
		{
			damage_player_flag = 1;
			// add news message
			news_array.tornado_hit(sprite_recno);
		}

		if( firmPtr->hit_points <= 0)
		{
			firmPtr->hit_points = (float) 0;

			se_res.sound(firmPtr->center_x, firmPtr->center_y, 1,
				'F', firmPtr->firm_id, "DIE" );

			firm_array.del_firm(locPtr->firm_recno());
		}
	}

	if( locPtr->is_town() )
	{
		Town *townPtr = town_array[locPtr->town_recno()];

		if( !damage_player_flag && townPtr->is_own() )
		{
			damage_player_flag = 1;
			// add news message
			news_array.tornado_hit(sprite_recno);
		}

		if( townPtr->hit_points > 0.0f )
		{
			townPtr->hit_points -= attack_damage*2;
			if( townPtr->hit_points <= 0 )
			{
				townPtr->hit_points = (float) 0;
			}
		}
		else
		{
			// ###### begin Gilbert 10/2 #######//
			if( (life_time % 10) == 0 ) 
				townPtr->kill_town_people(0);
			// ###### end Gilbert 10/2 #######//
		}
	}
}
Пример #2
0
void CampaignEastWest::plot_d2_create_game()
{
	// find a non-own nation
	int srcNation;
	for( srcNation = nation_array.size(); srcNation > 0; --srcNation)
	{
		if( !nation_array.is_deleted(srcNation)
			&& !nation_array[srcNation]->is_own() )
		{
			break;
		}
	}

	//
	int unitId;
	short kingXLoc = -1, kingYLoc;
	if(srcNation)
	{
		Nation *nationPtr = nation_array[srcNation];
		if( nationPtr->is_human() )
			unitId = race_res[nationPtr->race_id]->infantry_unit_id;
		else
			unitId = monster_res[nationPtr->monster_id()]->unit_id;

		if( nationPtr->king_unit_recno )
		{
			unit_array[nationPtr->king_unit_recno]->get_cur_loc( kingXLoc, kingYLoc);
		}
	}
	else
		unitId = 0;


	Town *targetTown;

	// find a town and turn it independent

	int count = 1;
	for(int townRecno = 1; townRecno <= town_array.size() && count > 0; ++townRecno )
	{
		if( town_array.is_deleted(townRecno) )
			continue;

		targetTown = town_array[townRecno];
		if( targetTown->is_own() )
		{
			targetTown->set_nation(0);

			// ----- create a monster next to town -------//

			if( unitId && kingXLoc >= 0)
			{
				int unitRecno = targetTown->create_unit(unitId);
				if( unitRecno )
				{
					unit_array[unitRecno]->betray(srcNation);
					unit_array[unitRecno]->move(kingXLoc, kingYLoc, true);
				}
			}

			--count;
		}
	}
}