src/disaster_cmd.cpp
branchnoai
changeset 9601 b499fdd106d5
parent 9599 949374e83b78
child 7048 06b931095b26
child 9620 31e38d28a0af
equal deleted inserted replaced
9600:59cc173953ae 9601:b499fdd106d5
   231 				v->current_order.dest = 1;
   231 				v->current_order.dest = 1;
   232 				v->age = 0;
   232 				v->age = 0;
   233 
   233 
   234 				SetDParam(0, GetStationIndex(tile));
   234 				SetDParam(0, GetStationIndex(tile));
   235 				AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
   235 				AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
   236 					NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
   236 					NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
   237 					v->index,
   237 					v->index,
   238 					0);
   238 					0);
   239 			}
   239 			}
   240 		}
   240 		}
   241 
   241 
   261 		return;
   261 		return;
   262 	}
   262 	}
   263 
   263 
   264 	x = v->x_pos;
   264 	x = v->x_pos;
   265 	y = v->y_pos;
   265 	y = v->y_pos;
   266 	z = GetSlopeZ(x,y);
   266 	z = GetSlopeZ(x, y);
   267 	if (z < v->z_pos) z = v->z_pos - 1;
   267 	if (z < v->z_pos) z = v->z_pos - 1;
   268 	SetDisasterVehiclePos(v, x, y, z);
   268 	SetDisasterVehiclePos(v, x, y, z);
   269 
   269 
   270 	if (++v->age == 1) {
   270 	if (++v->age == 1) {
   271 		CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
   271 		CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
   357 
   357 
   358 		z = v->z_pos;
   358 		z = v->z_pos;
   359 		if (dist <= TILE_SIZE && z > u->z_pos) z--;
   359 		if (dist <= TILE_SIZE && z > u->z_pos) z--;
   360 		SetDisasterVehiclePos(v, gp.x, gp.y, z);
   360 		SetDisasterVehiclePos(v, gp.x, gp.y, z);
   361 
   361 
   362 		if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN)==0) {
   362 		if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN) == 0) {
   363 			v->age++;
   363 			v->age++;
   364 			if (u->u.road.crashed_ctr == 0) {
   364 			if (u->u.road.crashed_ctr == 0) {
   365 				u->u.road.crashed_ctr++;
   365 				u->u.road.crashed_ctr++;
   366 				u->vehstatus |= VS_CRASHED;
   366 				u->vehstatus |= VS_CRASHED;
   367 
   367 
   368 				AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED,
   368 				AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED,
   369 					NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
   369 					NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
   370 					u->index,
   370 					u->index,
   371 					0);
   371 					0);
   372 			}
   372 			}
   373 		}
   373 		}
   374 
   374 
   439 
   439 
   440 			i = GetIndustry(v->dest_tile);
   440 			i = GetIndustry(v->dest_tile);
   441 			DestructIndustry(i);
   441 			DestructIndustry(i);
   442 
   442 
   443 			SetDParam(0, i->town->index);
   443 			SetDParam(0, i->town->index);
   444 			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
   444 			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
   445 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   445 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   446 		}
   446 		}
   447 	} else if (v->current_order.dest == 0) {
   447 	} else if (v->current_order.dest == 0) {
   448 		int x, y;
   448 		int x, y;
   449 		TileIndex tile;
   449 		TileIndex tile;
   512 
   512 
   513 			i = GetIndustry(v->dest_tile);
   513 			i = GetIndustry(v->dest_tile);
   514 			DestructIndustry(i);
   514 			DestructIndustry(i);
   515 
   515 
   516 			SetDParam(0, i->town->index);
   516 			SetDParam(0, i->town->index);
   517 			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
   517 			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
   518 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   518 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   519 		}
   519 		}
   520 	} else if (v->current_order.dest == 0) {
   520 	} else if (v->current_order.dest == 0) {
   521 		int x, y;
   521 		int x, y;
   522 		TileIndex tile;
   522 		TileIndex tile;
   598 		}
   598 		}
   599 
   599 
   600 		t = ClosestTownFromTile(v->dest_tile, (uint)-1);
   600 		t = ClosestTownFromTile(v->dest_tile, (uint)-1);
   601 		SetDParam(0, t->index);
   601 		SetDParam(0, t->index);
   602 		AddNewsItem(STR_B004_UFO_LANDS_NEAR,
   602 		AddNewsItem(STR_B004_UFO_LANDS_NEAR,
   603 			NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ACCIDENT, 0),
   603 			NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0),
   604 			v->tile,
   604 			v->tile,
   605 			0);
   605 			0);
   606 
   606 
   607 		u = ForceAllocateSpecialVehicle();
   607 		u = ForceAllocateSpecialVehicle();
   608 		if (u == NULL) {
   608 		if (u == NULL) {
   949 
   949 
   950 /* Curious submarine #2, just floats around */
   950 /* Curious submarine #2, just floats around */
   951 static void Disaster_Big_Submarine_Init()
   951 static void Disaster_Big_Submarine_Init()
   952 {
   952 {
   953 	Vehicle *v = ForceAllocateSpecialVehicle();
   953 	Vehicle *v = ForceAllocateSpecialVehicle();
   954 	int x,y;
   954 	int x, y;
   955 	Direction dir;
   955 	Direction dir;
   956 	uint32 r;
   956 	uint32 r;
   957 
   957 
   958 	if (v == NULL) return;
   958 	if (v == NULL) return;
   959 
   959 
   984 
   984 
   985 		FOR_ALL_INDUSTRIES(i) {
   985 		FOR_ALL_INDUSTRIES(i) {
   986 			if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
   986 			if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
   987 				SetDParam(0, i->town->index);
   987 				SetDParam(0, i->town->index);
   988 				AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
   988 				AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
   989 					NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TileDiffXY(1, 1), 0);
   989 					NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy + TileDiffXY(1, 1), 0);
   990 
   990 
   991 				{
   991 				{
   992 					TileIndex tile = i->xy;
   992 					TileIndex tile = i->xy;
   993 					TileIndexDiff step = TileOffsByDiagDir(GB(Random(), 0, 2));
   993 					TileIndexDiff step = TileOffsByDiagDir(GB(Random(), 0, 2));
   994 					uint n;
   994 					uint n;