Tweaks to survival mode with spawn chances.

This commit is contained in:
Storm Dragon
2025-09-23 00:41:23 -04:00
parent a686e816f5
commit d2304fae85
2 changed files with 23 additions and 8 deletions
+1
View File
@@ -437,6 +437,7 @@ class Level:
damage=damage,
attack_range=attack_range,
speed_multiplier=speed_multiplier,
attack_pattern={"type": "hunter"}, # Hunt like original spiders
)
self.enemies.append(enemy)
+22 -8
View File
@@ -131,17 +131,31 @@ class SurvivalGenerator:
levelData["weapon_sound_overrides"] = self.weaponOverrides
# Calculate spawn rates based on difficulty
collectibleDensity = max(0.1, 0.3 - (difficultyLevel * 0.02)) # Fewer collectibles over time
enemyDensity = min(0.8, 0.2 + (difficultyLevel * 0.05)) # More enemies over time
hazardDensity = min(0.4, 0.1 + (difficultyLevel * 0.03)) # More hazards over time
graveDensity = max(0.15, 0.25 - (difficultyLevel * 0.01)) # Moderate grave density, slight decrease over time
objectDensity = max(0.1, 0.2 - (difficultyLevel * 0.01)) # Fewer misc objects over time
# Ensure total probabilities stay under 1.0 to prevent graves being squeezed out
collectibleDensity = max(0.05, 0.15 - (difficultyLevel * 0.01)) # Fewer collectibles over time
enemyDensity = min(0.4, 0.15 + (difficultyLevel * 0.025)) # More enemies over time
hazardDensity = min(0.2, 0.05 + (difficultyLevel * 0.015)) # More hazards over time
graveDensity = 0.25 # Constant grave density throughout all waves
objectDensity = max(0.05, 0.1 - (difficultyLevel * 0.005)) # Fewer misc objects over time
# Generate objects across the segment with buffer zones
startBufferZone = 25 # Safe zone at start of each wave
endBufferZone = 30 # Safe zone at end of each wave
currentX = startBufferZone # Start placing objects after start buffer zone
# Guarantee at least one coffin per wave if coffins exist in templates
coffinTemplates = [obj for obj in self.objectTemplates if obj.get("type") == "coffin"]
coffin_placed = False
if coffinTemplates:
# Place guaranteed coffin in the first quarter of the level
coffin_x = random.randint(startBufferZone + 10, (segmentLength - endBufferZone) // 4)
coffin_template = random.choice(coffinTemplates)
coffin_obj = copy.deepcopy(coffin_template)
coffin_obj["item"] = "random" # Override any specified item
coffin_obj["x"] = coffin_x
levelData["objects"].append(coffin_obj)
coffin_placed = True
while currentX < segmentLength - endBufferZone:
# Determine what to place based on probability
rand = random.random()
@@ -270,9 +284,9 @@ class SurvivalGenerator:
baseChance = obj.get("zombie_spawn_chance", 0)
obj["zombie_spawn_chance"] = min(50, baseChance + (difficultyLevel * 2))
# Add item spawn chance that scales with difficulty (more items later when you need them)
baseItemChance = 30 # 30% base chance
obj["item_spawn_chance"] = min(70, baseItemChance + (difficultyLevel * 3))
# Add item spawn chance that decreases with difficulty (fewer items in later waves)
baseItemChance = 50 # 50% base chance
obj["item_spawn_chance"] = max(10, baseItemChance - (difficultyLevel * 2))
obj["item"] = "random" # Will be resolved to specific item in level generation
# Handle x_range vs single x