Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiplacon authored Nov 16, 2021
1 parent 14a0c21 commit 2779d46
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 25 deletions.
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
---------------------------------------------------------------------------------------------------
Version: 0.9.1
Date: 11/15/2021
Changes:
- Changed Impact Wagon item spread to be more of an area rather than 9 lines.
- Changed Impact Wagon item spread to be more like a rolling wave and less like a perfect arc. In theory this helps space out item landings so there aren't as many grouped together that have to be calculated at once. It also looks cooler.
- Changed the setting for item grouping to instead be maximum projectiles created per train, default 1000. This helps limit lag for trains with multiple Impact Wagons.
- Targeted the center of tiles that items landed on to better detect Open Chests and other things with small collision boxes or shrunken by Squeak Through.
- Things fired from the Ejector Hatch are now faster than normal.
Bugfixes:
- Fixed that trains wouldn't be damaged by the Impact Unloader if they ran backwards.
- Some locale and description fixes.
---------------------------------------------------------------------------------------------------
Version: 0.9.0
Date: 11/12/2021
Additions:
Expand Down
17 changes: 16 additions & 1 deletion control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ function(event)
local start=catapult.held_stack_position
local distance = math.sqrt((x-catapult.held_stack_position.x)^2 + (y-catapult.held_stack_position.y)^2)
local vector = {x=x-catapult.held_stack_position.x, y=y-catapult.held_stack_position.y}
local speed = 0.18
if (catapult.name == "RTThrower-EjectorHatchRT") then
distance = math.sqrt((x-catapult.position.x)^2 + (y-catapult.position.y)^2)
vector = {x=x-catapult.position.x, y=y-catapult.position.y}
start=catapult.position
speed = 0.25
rendering.set_target(sprite, catapult.position)
rendering.set_target(shadow, catapult.position)
end
local speed = 0.18
local arc = -(0.3236*distance^-0.404)-- closer to 0 = higher arc
local AirTime = math.floor(distance/speed)
local spin = math.random(-10,10)*0.01
Expand Down Expand Up @@ -335,3 +336,17 @@ function(event)
global.OnTheWay = {}
end
end)

-- script.on_event(defines.events.on_player_driving_changed_state,
-- -- player_index :: uint
-- -- entity :: LuaEntity (optional): The vehicle if any.
-- function(event)
-- local player = game.players[event.player_index]
-- if (player.character and player.driving == false) then
-- for each, properties in pairs(global.FlyingTrains) do
-- if (properties.passenger and properties.passenger.unit_number == player.character.unit_number) then
-- properties.GuideCar.set_passenger(player)
-- end
-- end
-- end
-- end)
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "RenaiTransportation",
"version": "0.9.0",
"version": "0.9.1",
"title": "Renai Transportation",
"author": "Kiplacon",
"factorio_version": "1.1",
Expand Down
17 changes: 11 additions & 6 deletions locale/en/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RTMagnetRail=Magnetic Train Pad
RTMagnetRampDrain=Magnet Ramp Power Buffer
RTTrainRamp-placer=Train Ramp
RTMagnetTrainRamp-placer=Magnet Train Ramp
RTImpactUnloader-placer=Impact Unloader
RTImpactUnloader=Impact Unloader

RTPayloadWagon=Payload Wagon
Expand Down Expand Up @@ -54,10 +55,14 @@ RTMagnetTrainRamp=Click on this to set where you would like trains jumping off t
RTMagnetTrainRampNoSkip=Click on this to set where you would like trains jumping off this ramp to land. Powerful electromagnets will guide train carriages to the desired landing point, comsuming roughly 200kJ per tile per jump drawn all at once from the ramp's buffer. The buffer must be full for the magnets to work, otherwise the ramp will act like a regular ramp. When chaining ramp jumps in squence, make sure at least one carriage is fully on the ground at all times. Trains do NOT skip a schedule stop when jumping off this (Toggled with Interact)
RTMagnetRail=A powerful electromagnet controlled by the Magnet Train Ramp. It repels or attracts train carriages to help them reach a desired jump range. The particles are a visualization of the magnetic field. Probably.
RTMagnetRampDrain=This buffer powers the electromagnetic pads attached to its Magnet Ramp, emptying all its power into the pads during a jump. Buffer size scales with jump distance, and the buffer fills at 40MW.
RTImpactUnloader=When a train collides with this, all attached Impact Wagons open their hatches causing their contents to fly out. The faster the collision, the more items fly out and the farther they fly. After impact, the train's "current destination" on its schedule is bumped forward by one stop, allowing for automation using a Train Stop placed after the Impact Unloader and a locomotive on the train facing backwards.
RTImpactUnloader=When a train collides with this, all attached Impact Wagons open their hatches causing their contents to fly out. The faster the collision, the more items fly out and the farther they fly. After impact, the train's "current destination" on its schedule is bumped forward by one stop, allowing for automation using a Train Stop placed after the Impact Unloader and a locomotive on the train facing backwards. The maximum number of created projectiles can be adjusted in mod settings.

RTTrainRamp-placer=A train launching off this ramp has the "current destination" on its schedule bumped forward by one stop. This allows guiding automatic trains to the ramp you want it to take using a Train Stop placed after the ramp without messing up the intended route. Press Interact to toggle this schedule skipping off when it is not needed.\nKeep in mind the train might slow down if it approaches a stop, or if the next stop after the jump isn't readily accessible. The train's speed when it hits the ramp dictates how far it will fly. Trains must hit the ramp exactly straight.
RTMagnetTrainRamp-placer=Click on this to set where you would like trains jumping off this ramp to land. Powerful electromagnets will guide train carriages to the desired landing point, comsuming roughly 200kJ per tile per jump drawn all at once from the ramp's buffer. The buffer must be full for the magnets to work, otherwise the ramp will act like a regular ramp. When chaining ramp jumps in squence, make sure at least one carriage is fully on the ground at all times. Trains skip a schedule stop when jumping off this (Toggled with Interact)
RTImpactUnloader-placer=When a train collides with this, all attached Impact Wagons open their hatches causing their contents to fly out. The faster the collision, the more items fly out and the farther they fly. After impact, the train's "current destination" on its schedule is bumped forward by one stop, allowing for automation using a Train Stop placed after the Impact Unloader and a locomotive on the train facing backwards. The maximum number of created projectiles can be adjusted in mod settings.

RTPayloadWagon=When this crash lands, primable items inside will prime and fly out in a 10 tile radius. Explosives (as in the item called "explosives", not "things that explode") in the wagon increase the spread radius by 0.2 tiles capping at +30 tiles at 150 explosive. To limit lag, only 1 full stack of each primable item in the wagon will fly out.
RTImpactWagon=When a train with these wagons collides with an Impact Unloader, all attached Impact Wagons open their hatches causing their contents to fly out. The faster the collision, the more items fly out and the farther they fly.
RTImpactWagon=When a train with these wagons collides with an Impact Unloader, all attached Impact Wagons open their hatches causing their contents to fly out. The faster the collision, the more items fly out and the farther they fly. The maximum number of created projectiles can be adjusted in mod settings.

[technology-name]

Expand Down Expand Up @@ -126,14 +131,14 @@ RTImpactSetting=Enable Impact Wagons and Impact Unloaders
RTZiplineSetting=Enable Electric Ziplines
RTZiplineSmoothSetting=Zipline Motion
RTModdedThrowers=Enable modded thrower varients (Requires base throwers to be enabled)
RTOverflowComp=Thrower Overflow Prevention v2 [WIP]
RTItemGrouping=Projectile grouping
RTOverflowComp=Thrower Overflow Prevention
RTImpactGrouping=Impact Wagon Item Grouping


[mod-setting-description]
RTBounceSetting=Circuit Bounce Pad and Primer Bounce Pad
RTZiplineSmoothSetting=At faster speeds with poles closer together, the bobbing camera motion might be dizzying for some people.
RTModdedThrowers=Enables thrower varients of modded inserters, otherwise only vanilla inserter throwers are made.
RTOverflowComp=Toggles on or off the logic that helps minimize overflow from throwers spilling items all over the place. Disabling probably saves a bit of UPS
RTOverflowComp=Toggles on or off the logic that helps minimize overflow from throwers spilling items all over the place. Disabling this and controlling throwers with circuit network signals would save UPS.
RTThrowersSetting=Enables the base features of thrower inserters, bounce pads, player launchers, and hatches. Required to be on for modded throwers to be created.
RTItemGrouping=How many items are "compressed" into each projectile when thrown for things like the Impact Wagon and Payload Wagon. Larger groupings help reduce lag, but look way less cool.
RTImpactGrouping=The maximum number of projectiles created for each kind of item in an Impact Wagon. Creating fewer projectiles helps reduce lag by grouping more items into each projectile, but looks way less cool.
8 changes: 4 additions & 4 deletions script/event/FlyingItems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local function on_tick(event)
unitx = -1
unity = 0
traveling = "left"
elseif (FlyingItem.start.x < FlyingItem.target.x
elseif (FlyingItem.start.x < FlyingItem.target.x
and math.abs(FlyingItem.start.y-FlyingItem.target.y) < math.abs(FlyingItem.start.x-FlyingItem.target.x)) then
unitx = 1
unity = 0
Expand Down Expand Up @@ -103,7 +103,7 @@ local function on_tick(event)
local x = ThingLandedOn.position.x +unitx*(range+RangeBonus) +unity*(SidewaysShift)
local y = ThingLandedOn.position.y +unity*(range+RangeBonus) +unitx*(SidewaysShift)
local distance = math.sqrt((x-ThingLandedOn.position.x)^2 + (y-ThingLandedOn.position.y)^2)
local speed = 0.18
local speed = FlyingItem.speed
local AirTime = math.floor(distance/speed)
local vector = {x=x-ThingLandedOn.position.x, y=y-ThingLandedOn.position.y}
FlyingItem.target={x=x, y=y}
Expand Down Expand Up @@ -168,7 +168,7 @@ local function on_tick(event)
else
rendering.get_surface(FlyingItem.sprite).spill_item_stack
(
rendering.get_surface(FlyingItem.sprite).find_non_colliding_position("item-on-ground", rendering.get_target(FlyingItem.sprite).position, 0, 0.1),
rendering.get_surface(FlyingItem.sprite).find_non_colliding_position("item-on-ground",FlyingItem.target, 0, 0.1),
{name=FlyingItem.item, count=FlyingItem.amount}
)

Expand Down Expand Up @@ -200,7 +200,7 @@ local function on_tick(event)
if (FlyingItem.player == nil) then
rendering.get_surface(FlyingItem.sprite).spill_item_stack
(
rendering.get_surface(FlyingItem.sprite).find_non_colliding_position("item-on-ground", rendering.get_target(FlyingItem.sprite).position, 0, 0.1),
rendering.get_surface(FlyingItem.sprite).find_non_colliding_position("item-on-ground", FlyingItem.target, 0, 0.1),
{name=FlyingItem.item, count=FlyingItem.amount}
)
end
Expand Down
19 changes: 9 additions & 10 deletions script/event/entity_damaged.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ local function entity_damaged(event)
and event.cause
and (event.cause.type == "locomotive" or event.cause.type == "cargo-wagon" or event.cause.type == "fluid-wagon" or event.cause.type == "artillery-wagon")
) then
if (event.cause.train and event.cause.train.cargo_wagons) then
if (event.cause.train and event.cause.train.cargo_wagons and math.abs(event.cause.train.speed) > 0.125) then
wagons = #event.cause.train.cargo_wagons
for each, wagon in pairs(event.cause.train.cargo_wagons) do
if (wagon.name == "RTImpactWagon") then
local LaunchedPortion = math.abs(wagon.speed)/0.75
Expand All @@ -323,7 +324,7 @@ local function entity_damaged(event)
for ItemName, amount in pairs(wagon.get_inventory(defines.inventory.cargo_wagon).get_contents()) do
local LaunchedAmount = math.floor(amount*LaunchedPortion)
if (LaunchedAmount > 0) then
local GroupSize = settings.global["RTItemGrouping"].value
local GroupSize = math.ceil((LaunchedAmount*wagons)/settings.global["RTImpactGrouping"].value)
for i = 1, math.floor(LaunchedAmount/GroupSize) do
local sprite = rendering.draw_sprite
{
Expand All @@ -344,12 +345,12 @@ local function entity_damaged(event)
}
local xUnit = (math.acos(math.cos(2*math.pi*(wagon.orientation+0.25)))/(0.5*math.pi)) - 1
local yUnit = (math.acos(math.cos(2*math.pi*(wagon.orientation)))/(0.5*math.pi)) - 1
local ForwardSpread = math.random(100,350)*0.1
local HorizontalSpread = math.random(-4,4)*ForwardSpread*0.1
local ForwardSpread = math.random(100,400)*0.1
local HorizontalSpread = math.random(-40,40)*ForwardSpread*0.01
local x = wagon.position.x + (ForwardSpread*wagon.speed*xUnit) + (HorizontalSpread*wagon.speed*yUnit)
local y = wagon.position.y + (ForwardSpread*wagon.speed*yUnit) + (HorizontalSpread*wagon.speed*xUnit)
local distance = math.sqrt((x-wagon.position.x)^2 + (y-wagon.position.y)^2)
local speed = math.abs(wagon.speed)*0.70
local speed = math.abs(wagon.speed) * (distance/(35*math.abs(wagon.speed))) * math.random(45,100)*0.01
local arc = -(0.3236*distance^-0.404) -- lower number is higher arc
local AirTime = math.floor(distance/speed)
local vector = {x=x-wagon.position.x, y=y-wagon.position.y}
Expand Down Expand Up @@ -377,12 +378,12 @@ local function entity_damaged(event)
}
local xUnit = (math.acos(math.cos(2*math.pi*(wagon.orientation+0.25)))/(0.5*math.pi)) - 1
local yUnit = (math.acos(math.cos(2*math.pi*(wagon.orientation)))/(0.5*math.pi)) - 1
local ForwardSpread = math.random(100,350)*0.1
local HorizontalSpread = math.random(-4,4)*ForwardSpread*0.1
local ForwardSpread = math.random(100,400)*0.1
local HorizontalSpread = math.random(-40,40)*ForwardSpread*0.01
local x = wagon.position.x + (ForwardSpread*wagon.speed*xUnit) + (HorizontalSpread*wagon.speed*yUnit)
local y = wagon.position.y + (ForwardSpread*wagon.speed*yUnit) + (HorizontalSpread*wagon.speed*xUnit)
local distance = math.sqrt((x-wagon.position.x)^2 + (y-wagon.position.y)^2)
local speed = math.abs(wagon.speed)*0.75
local speed = math.abs(wagon.speed) * (distance/(35*math.abs(wagon.speed))) * math.random(45,100)*0.01
local arc = -(0.3236*distance^-0.404) -- lower number is higher arc
local AirTime = math.floor(distance/speed)
local vector = {x=x-wagon.position.x, y=y-wagon.position.y}
Expand All @@ -405,8 +406,6 @@ local function entity_damaged(event)
end
event.cause.train.schedule = stor
end
end
if (event.cause.train.speed > 0.15) then
event.cause.health = event.cause.health - (event.cause.prototype.max_health/8)
if (event.cause.health <= 0) then
event.cause.die()
Expand Down
6 changes: 3 additions & 3 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ data:extend({
},
{
type = "int-setting",
name = "RTItemGrouping",
name = "RTImpactGrouping",
setting_type = "runtime-global",
default_value = 1,
minimum_value = 1,
default_value = 1000,
minimum_value = 200, -- minimum fun
order = "i"
}
})

0 comments on commit 2779d46

Please sign in to comment.