Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RemoveAliensInArea(surface, area)
- for _, entity in pairs(surface.find_entities_filtered{area = area, force = "enemy"}) do
- entity.destroy()
- end
- end
- function ReduceAliensInArea(surface, area, reductionFactor, evolution)
- for _, entity in pairs(surface.find_entities_filtered{area = area, force = "enemy"}) do
- if (math.random(0,reductionFactor) > 0) then
- entity.destroy()
- end
- end
- -- Downgrade all huge worms
- if (evolution<0.75) then
- for _, entity in pairs(surface.find_entities_filtered{area = area, name = "behemoth-worm-turret"}) do
- surface.create_entity({
- name="big-worm-turret",
- position=entity.position
- })
- entity.destroy()
- end
- end
- -- Downgrade all big worms
- if (evolution<0.5) then
- for _, entity in pairs(surface.find_entities_filtered{area = area, name = "big-worm-turret"}) do
- surface.create_entity({
- name="medium-worm-turret",
- position=entity.position
- })
- entity.destroy()
- end
- end
- -- Downgrade all medium worms
- if (evolution<0.25) then
- for _, entity in pairs(surface.find_entities_filtered{area = area, name = "medium-worm-turret"}) do
- surface.create_entity({
- name="small-worm-turret",
- position=entity.position
- })
- entity.destroy()
- end
- end
- end
- local function removeAlienDecoratives(surface,area)
- surface.destroy_decoratives( { area=area, name= {"shroom-decal","worms-decal","enemy-decal","enemy-decal-transparent"} } )
- end
- local function scaleDownBiters(surface,area,evolution)
- local reduction = 40
- if (evolution>=0.1) then
- reduction = 30
- end
- if (evolution>=0.2) then
- reduction = 20
- end
- if (evolution>=0.35) then
- reduction = 10
- end
- if (evolution>=0.5) then
- reduction = 5
- end
- if (evolution>=0.65) then
- reduction = 3
- end
- if (evolution>0.8) then
- reduction = 1
- end
- local dice_roll = math.random(0,reduction)
- if ( dice_roll > 2) then
- RemoveAliensInArea(surface,area) -- kill all "enemy" objects in this chunk
- removeAlienDecoratives(surface,event.area)
- elseif (dice_roll > 0)then
- ReduceAliensInArea(surface,area,2,evolution) --downgrade worms and kill some nests
- else
- ReduceAliensInArea(surface,area,0,evolution) --only downgrade worms
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement