Example #1
0
void CampaignEastWest::plot_d1_create_game()
{
	// reduce cash

	(~nation_array)->cash = (~nation_array)->cash / 4;

	// reduce mineral if the mine is owned by the player

	for( int i = 1; i <= site_array.size(); ++i )
	{
		if( site_array.is_deleted(i) )
			continue;

		Site *sitePtr = site_array[i];
		if( sitePtr->site_type == SITE_RAW && sitePtr->has_mine )
		{
			Location *locPtr = world.get_loc(sitePtr->map_x_loc, sitePtr->map_y_loc);
			err_when( !locPtr->is_firm() );
			Firm *firmPtr = firm_array[locPtr->firm_recno()];
			if( firmPtr->is_own() )
			{
				sitePtr->reserve_qty = sitePtr->reserve_qty / 10;

				if( firmPtr->cast_to_FirmMine() )
				{
					firmPtr->cast_to_FirmMine()->reserve_qty = (float)sitePtr->reserve_qty;
				}
				else if( firmPtr->cast_to_FirmMonsterAlchemy() )
				{
					firmPtr->cast_to_FirmMonsterAlchemy()->reserve_qty = (float)sitePtr->reserve_qty;
				}
			}
		}
	}
}
Example #2
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 #######//
		}
	}
}