So, here’s an idea.
Make nuked cities. These cities must be pretty large to be nuked. So, when we got required city, we nuke it.
Features of nuked cities:
0. The most nearest city to player’s spawn point isn’t nuked at all. If there’s few of them then there must be one city that wasn’t nuked.
-
They have epicenter of the explosion. It the most important part. Epicenter should be located mostly near to the center of city.
-
Explosion have some radius of destruction, but sound wave should break glass items far more further. Speaking of that i should say that nuked city must have all windows (as terrain element, as vehicle part - no matter) broken. Moreover - sound wave should break glass objects even beyond the city, so, even if a survivor don’t know where’s nuked city they can notice that by broken windows in vehicles. And, a little bonus, everyone who could hear now can’t.
-
Most of buildings are damaged by the explosion. Than more nearer to the epicenter, than more damaged. I assume that should occur on creating-world stage after placing items.
So, some numbers:
~10% of destruction radius is full destruction zone. Bulidings in that zone fully destroyed, vehicles fully smashed, and the most powerful radiation. ~20% of this zone is craters. No one is alive here.
~40% of destruction radius is 3rd degree burns zone. Buildings in that zone almost always destroyed, but some of them may withstand, but they have their furtinute smashed and thrown in random place. There’s also a lot of fires started. Vehicles mostly smashed, but some of them had withstanded shockwave and been thrown in random place. Some very heavy damaged zombies may appear. Still strong radiation, but weaker than in full destruction zone.
~70% of destruction radius is 2rd degree burns zone. Bulidings in that zone often damaged, but partially. Vehicles mostly aren’t even smashed. Decreased spawn rate of zombies, some of them moderately damaged. Weak radiation.
~100% of destruction radius is shockwave affection zone. Nothing is destroyed, but items and furniture displaced a little. -
Items are damaged too, in same pattern as buildings.
-
In any case here’s decreased spawn rate, but monsters are far more bizarre, thanks for radiation.
So, an algorithm of “nuking”:
0. Generate a map completely. Nuking is the last thing before adding our man.
According to source code:
[code] //Reset character pickup rules
vAutoPickupRules[2].clear();
//Put some NPCs in there!
create_starting_npcs();
//Load NPCs. Set nearby npcs to active.
load_npcs();
//spawn the monsters
m.spawn_monsters(); // Static monsters
//Create mutation_category_level
u.set_highest_cat_level();
//Calc mutation drench protection stats
u.drench_mut_calc();
MAPBUFFER.set_dirty();
[/code]
Nuking function must be called after spawn_monsters.
- Find generated cities
- Find their centers
- Check for all cities: if their size > 8 and one_in((int)(80 / std::min(std::max(size, 8), 16)) then we found our victim.
- Now, randomly choose epicenters from city centers
- Define nuke’s strengths, it’s rng(6, 16).
- Now, find which map tiles are affected by explosion.
- Now, the most important part. For V of all those map-tiles do
9.1. Find distance (by sqrt( (x1-x0)^2 + (y1-y0)^2 ) ) from epicenter to our map-tile.
9.2. Power of shockwave formula: std::max(1000 / distance + rng(0, 1000 / (radius - std::max(distance-1, 2))) * (rng(0, 100) > 50 ? -1 : 1), 0)
Explanation
std::max(formula, 0) - bound check
1000 / distance - than further, than weaker
rng(0, new_formula) - randomness to power of shockwave
1000 / (radius - std::max(distance-1, 2)) - Depending from distance from epicenter, randomness range maybe from -500 to 500, than nearer to epicenter, than lesser (?) difference
(rng (0, 100) > 50 ? -1 : 1) - with 49% chance shockwave maybe weaker, otherwise stronger.
radius - radius of explosion
distance - distance from epicenter to map-tile.
9.3. Radiation falls by square-pattern from 50000 to almost zero:
50000 / 2^distance
According to wikipedia, powerful nuclear explosions leave lesser radiation than weaker ones.
By our formula minimum difference between the most weakest and the most strongest explosion is…
781,25 - ~0,77 = 780,48 bar.
9.4. Now, we apply force to local region
We need to mix map::bash and map::destroy into map::nuke_shockwave(int x, int y, int power).
Power, that need to destroy:
a wooden wall: 100
a concrete wall: 300
a palisade: 60
a floor: 150 (because floor should get lesser power)
So, the function is : (rng(power * .75, power) >= health_of_terrain ? map::destroy(x, y, false) : nil)
If a thing is destructable, then use map::bash instead. If that’s a thing that can be moved and it wasn’t destroyed at first time, then select a random tile and move it there with chance of rng(0, 150) < power.
9.5. Damage every item according to it’s volume, material and weight. Than more volume - than more power is applied, than stronger material - than lesser damage, than higher weight - than more damage.
- If (ACTIVE_WORLD_OPTIONS[“STATIC_SPAWN”]) then
10.1. Damage monster with DT_HEAT with force, that depends from distance to epicenter.
10.2. If monster is still alive, then damage every monster with DT_BASH for power-force according to it’s volume and weight (i mean corpse, of course)
10.3. If monster is still alive after bashing, then, depending from radiation value, mutate him into something dangerous.
else
10.-1. apply local spawn rate decreasing zone. It’s something new, yep. Than higher radiation - than higher divider of chosen spawn rate.
10.-2. Change spawn point monster into something new.
End.
It can be very hard to code, but imagine - that’s NEW TYPE of cities with MORE DANGEROUS zombies. Radiation, damaged building, fires - it’s all can be very changelling. After all that’s something new.