Skip to content

Commit

Permalink
bug and SE fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiplacon committed May 21, 2023
1 parent c3602b8 commit cb6ddfb
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 66 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 1.2.3
Date: 5/21/2023
Bugfixes:
- Fixed that throwing an item that was created after my mod was loaded would cause a crash. It now throws a placeholder sprite but functions correctly.
- Fixed that movement speed buffs would reset after using the bounce pad or zipline, which caused problems with the RPG system mod. Reported by JackCyber
- Fixed the Space Exploration "integration"
---------------------------------------------------------------------------------------------------
Version: 1.2.2
Date: 5/11/2023
Changes:
Expand Down
108 changes: 75 additions & 33 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function(event)
or (catapult.orientation == 0.75 and catapult.held_stack_position.x >= catapult.position.x+properties.BurnerSelfRefuelCompensation)
then
-- activate/disable thrower based on overflow prevention
if (catapult.name ~= "RTThrower-PrimerThrower" and settings.global["RTOverflowComp"].value == true) then
if (catapult.name ~= "RTThrower-PrimerThrower" and settings.global["RTOverflowComp"].value == true and properties.InSpace == false) then
-- pointing at some entity
if (properties.targets[HeldItem]
and properties.targets[HeldItem].valid -- its an entity
Expand Down Expand Up @@ -222,13 +222,6 @@ function(event)
local x = catapult.drop_position.x
local y = catapult.drop_position.y
local distance = math.sqrt((x-catapult.held_stack_position.x)^2 + (y-catapult.held_stack_position.y)^2)
--local arc = -(0.3236*distance^-0.404)-- closer to 0 = higher arc
if (properties.InSpace == true) then
arc = -99999999999999
x = x + (-global.OrientationUnitComponents[catapult.orientation].x * 1000)
y = y + (-global.OrientationUnitComponents[catapult.orientation].y * 1000)
distance = math.sqrt((x-catapult.held_stack_position.x)^2 + (y-catapult.held_stack_position.y)^2)
end
-- calcaulte projectile parameters
local start=catapult.held_stack_position
local speed = 0.18
Expand All @@ -251,7 +244,7 @@ function(event)
end
local AirTime = math.max(1, math.floor(distance/speed)) -- for super fast throwers that move right on top of their target
local destination = nil
if (settings.global["RTOverflowComp"].value == true) then
if (settings.global["RTOverflowComp"].value == true and properties.InSpace == false) then
if (properties.targets[HeldItem] ~= nil and properties.targets[HeldItem].valid) then
destination = properties.targets[HeldItem].unit_number
if (global.OnTheWay[properties.targets[HeldItem].unit_number] == nil) then
Expand All @@ -268,25 +261,64 @@ function(event)
end
global.FlyingItems[global.FlightNumber] =
{
item=HeldItem,
amount=catapult.held_stack.count,
target={x=x, y=y},
start=start,
AirTime=AirTime,
StartTick=game.tick,
LandTick=game.tick+AirTime,
destination=destination,
space=properties.InSpace,
surface=catapult.surface,
item=HeldItem,
amount=catapult.held_stack.count,
target={x=x, y=y},
start=start,
AirTime=AirTime,
StartTick=game.tick,
LandTick=game.tick+AirTime,
destination=destination,
space=properties.InSpace,
surface=catapult.surface,
}
if (properties.InSpace == false) then
catapult.surface.create_entity
{
name="RTItemProjectile-"..HeldItem..speed*100,
position=catapult.held_stack_position,
source_position=start,
target_position=catapult.drop_position
}
if (game.entity_prototypes["RTItemProjectile-"..HeldItem..speed*100]) then
catapult.surface.create_entity
{
name="RTItemProjectile-"..HeldItem..speed*100,
position=catapult.held_stack_position,
source_position=start,
target_position=catapult.drop_position
}
else
catapult.surface.create_entity
{
name="RTTestProjectile"..speed*100,
position=catapult.held_stack_position,
source_position=start,
target_position=catapult.drop_position
}
end
else
x = x + (-global.OrientationUnitComponents[catapult.orientation].x * 100)
y = y + (-global.OrientationUnitComponents[catapult.orientation].y * 100)
distance = math.sqrt((x-catapult.held_stack_position.x)^2 + (y-catapult.held_stack_position.y)^2)
AirTime = math.max(1, math.floor(distance/speed))
local vector = {x=x-catapult.held_stack_position.x, y=y-catapult.held_stack_position.y}
local path = {}
for i = 1, AirTime do
local progress = i/AirTime
path[i] =
{
x = catapult.held_stack_position.x+(progress*vector.x),
y = catapult.held_stack_position.y+(progress*vector.y),
height = 0
}
end
path.duration = AirTime
global.FlyingItems[global.FlightNumber].path = path
global.FlyingItems[global.FlightNumber].space = true
global.FlyingItems[global.FlightNumber].LandTick = game.tick+AirTime
global.FlyingItems[global.FlightNumber].sprite = rendering.draw_sprite
{
sprite = "item/"..HeldItem,
x_scale = 0.5,
y_scale = 0.5,
target = catapult.held_stack_position,
surface = catapult.surface
}
global.FlyingItems[global.FlightNumber].spin = math.random(-10,10)*0.01
end
if (catapult.held_stack.item_number ~= nil) then
local CloudStorage = game.create_inventory(1)
Expand Down Expand Up @@ -475,13 +507,23 @@ function(event)
local player = game.players[event.player_index]
if (player.cursor_stack.valid_for_read == true) then
local item = player.cursor_stack.name
player.surface.create_entity
{
name="RTItemProjectile-"..item..25,
position=player.position,
source_position=player.position,
target_position=event.cursor_position
}
if (game.entity_prototypes["RTItemProjectile-"..item..25]) then
player.surface.create_entity
{
name="RTItemProjectile-"..item..25,
position=player.position,
source_position=player.position,
target_position=event.cursor_position
}
else
player.surface.create_entity
{
name="RTTestProjectile"..25,
position=player.position,
source_position=player.position,
target_position=event.cursor_position
}
end
end
end)

Expand Down
2 changes: 1 addition & 1 deletion data-final-fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -887,4 +887,4 @@ for Category, ThingsTable in pairs(data.raw) do
data:extend({casper})
end
end
end
end
96 changes: 94 additions & 2 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ data:extend({
},
{
type = "stream",
name = "RTTestProjectile",

name = "RTTestProjectile18",
particle_spawn_interval = 0,
particle_spawn_timeout = 0,
particle_vertical_acceleration = 0.0035,
Expand All @@ -110,6 +109,99 @@ data:extend({
}
}
},
shadow =
{
layers =
{
{
filename = "__RenaiTransportation__/graphics/icon.png",
line_length = 1,
frame_count = 1,
priority = "high",
size = 32,
scale = 19.2/32,
tint = {0,0,0,0.5}
}
}
},
oriented_particle = true
},
{
type = "stream",
name = "RTTestProjectile25",
particle_spawn_interval = 0,
particle_spawn_timeout = 0,
particle_vertical_acceleration = 0.0035,
particle_horizontal_speed = 0.25,
particle_horizontal_speed_deviation = 0,
particle =
{
layers =
{
{
filename = "__RenaiTransportation__/graphics/icon.png",
line_length = 1,
frame_count = 1,
priority = "high",
size = 32,
scale = 19.2/32
}
}
},
shadow =
{
layers =
{
{
filename = "__RenaiTransportation__/graphics/icon.png",
line_length = 1,
frame_count = 1,
priority = "high",
size = 32,
scale = 19.2/32,
tint = {0,0,0,0.5}
}
}
},
oriented_particle = true
},
{
type = "stream",
name = "RTTestProjectile60",
particle_spawn_interval = 0,
particle_spawn_timeout = 0,
particle_vertical_acceleration = 0.0035,
particle_horizontal_speed = 0.6,
particle_horizontal_speed_deviation = 0,
particle =
{
layers =
{
{
filename = "__RenaiTransportation__/graphics/icon.png",
line_length = 1,
frame_count = 1,
priority = "high",
size = 32,
scale = 19.2/32
}
}
},
shadow =
{
layers =
{
{
filename = "__RenaiTransportation__/graphics/icon.png",
line_length = 1,
frame_count = 1,
priority = "high",
size = 32,
scale = 19.2/32,
tint = {0,0,0,0.5}
}
}
},
oriented_particle = true
}
})
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": "1.2.2",
"version": "1.2.3",
"title": "Renai Transportation",
"author": "Kiplacon",
"factorio_version": "1.1",
Expand Down
2 changes: 1 addition & 1 deletion locale/en/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ EjectorHatchRTTech=Like a Hatch but in reverse.
RTThrowerTime=Thrower versions of all inserters currently installed, even modded ones.
SignalPlateTech=Thrower and Circuit Network crossover
PrimerPlateTech=Ever wish you could throw your grenades and rockets even further?
RTFocusedFlinging=Allows you to adjust a thrower's throwing distance to be less than 15. Hover and press Interact (default F) to do so.
RTFocusedFlinging=Allows you to adjust a thrower's throwing distance to be less than 15. Hover and press Interact (default F) to do so, or set the range via circuit signal.
RTFlyingFreight=Train junctions? More like train jump-tions
RTFreightPlates=It's like bounce pads, but for trains.
RTZiplineTech=Use your existing power network as a highway!
Expand Down
28 changes: 21 additions & 7 deletions script/MiscFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function SwapToGhost(player)
"character_inventory_slots_bonus",
"character_mining_speed_modifier",
"character_additional_mining_categories",
"character_running_speed_modifier",
"character_build_distance_bonus",
"character_item_drop_distance_bonus",
"character_reach_distance_bonus",
Expand Down Expand Up @@ -189,8 +188,27 @@ function SwapBackFromGhost(player, FlyingItem)
FlyingItem.SwapBack.destructible = true
FlyingItem.SwapBack.health = OG2.health
FlyingItem.SwapBack.selected_gun_index = OG2.selected_gun_index
FlyingItem.player.character_running_speed_modifier = 0

------ modifiers --------
local CharacterModifiers = {
"character_crafting_speed_modifier",
"character_inventory_slots_bonus",
"character_mining_speed_modifier",
"character_additional_mining_categories",
"character_build_distance_bonus",
"character_item_drop_distance_bonus",
"character_reach_distance_bonus",
"character_resource_reach_distance_bonus",
"character_item_pickup_distance_bonus",
"character_loot_pickup_distance_bonus",
"character_trash_slot_count_bonus",
"character_maximum_following_robot_count_bonus",
"character_health_bonus",
"character_personal_logistic_requests_enabled",
"allow_dispatching_robots"
}
for each, modifier in pairs(CharacterModifiers) do
OG2[modifier] = FlyingItem.SwapBack[modifier]
end
if (remote.interfaces["space-exploration"] and remote.interfaces["space-exploration"].on_character_swapped) then
remote.call("space-exploration", "on_character_swapped", {new_character=FlyingItem.SwapBack,old_character=OG2})
end
Expand Down Expand Up @@ -260,7 +278,6 @@ function SwapBackFromGhost(player, FlyingItem)
PlayerProperties.SwapBack.destructible = true
PlayerProperties.SwapBack.health = OG2.health
PlayerProperties.SwapBack.selected_gun_index = OG2.selected_gun_index
player.character_running_speed_modifier = 0
if (remote.interfaces["space-exploration"] and remote.interfaces["space-exploration"].on_character_swapped) then
remote.call("space-exploration", "on_character_swapped", {new_character=PlayerProperties.SwapBack,old_character=OG2})
end
Expand Down Expand Up @@ -428,9 +445,6 @@ function GetOffZipline(player, PlayerProperties)
ZiplineStuff.LetMeGuideYou.destroy()
ZiplineStuff.ChuggaChugga.destroy()
ZiplineStuff.succ.destroy()
if (player.character) then
player.character_running_speed_modifier = 0
end
player.teleport(player.surface.find_non_colliding_position("character", {player.position.x, player.position.y+2}, 0, 0.01))
PlayerProperties.zipline = {}
PlayerProperties.state = "default"
Expand Down
Loading

0 comments on commit cb6ddfb

Please sign in to comment.