Skip to content

Commit

Permalink
Fixed SmartRocket projectile
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed Jul 19, 2022
1 parent e61b61f commit 9474adb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions Scripts/Cannons_Pack_libs/Global_Scripts/SmartRocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ SmartRocket = class(GLOBAL_SCRIPT)
SmartRocket.projectiles = {}
SmartRocket.proj_queue = {}

SmartRocket.sv_last_update = 0
SmartRocket.cl_last_update = 0
SmartRocket.m_ref_count = 0

--The FOV of Smart Rocket is 60 degrees (-0.66)
--The FOV of Smart Rocket Detector is 80 degress (-0.88)

function SmartRocket.server_sendProjectile(self, shapeScript, data, id)
local data_to_send = _cpProj_ClearNetworkData(data, id)

_tableInsert(self.proj_queue, {id, shapeScript.shape, data_to_send})
_tableInsert(SmartRocket.proj_queue, {id, shapeScript.shape, data_to_send})
end

SR_ModeEnum = {
Expand Down Expand Up @@ -44,7 +48,7 @@ function SmartRocket.client_loadProjectile(self, data)
local proximity_fuze = proj_settings[ProjSettingEnum.proxFuze]
local ignored_players = _cpProj_proxFuzeIgnore(shape.worldPosition, proximity_fuze)

self.projectiles[#self.projectiles + 1] = {
SmartRocket.projectiles[#SmartRocket.projectiles + 1] = {
effect = effect,
pos = position,
dir = velocity,
Expand All @@ -60,12 +64,12 @@ function SmartRocket.client_loadProjectile(self, data)
end

function SmartRocket.server_onScriptUpdate(self, dt)
for k, data in pairs(self.proj_queue) do
for k, data in pairs(SmartRocket.proj_queue) do
self.network:sendToClients("client_loadProjectile", data)
self.proj_queue[k] = nil
SmartRocket.proj_queue[k] = nil
end

for b, proj in pairs(self.projectiles) do
for b, proj in pairs(SmartRocket.projectiles) do
if proj and proj.hit then
_cpProj_betterExplosion(proj.hit, 60, 0.7, 7000, 30, "ExplBig", true)
end
Expand Down Expand Up @@ -173,9 +177,9 @@ local function PickATarget(rocket, char_pos, char_visible)
end

function SmartRocket.client_onScriptUpdate(self, dt)
for k, rocket in pairs(self.projectiles) do
for k, rocket in pairs(SmartRocket.projectiles) do
if rocket and rocket.hit then
self.projectiles[k] = nil
SmartRocket.projectiles[k] = nil
end

if rocket and not rocket.hit then
Expand Down Expand Up @@ -288,7 +292,7 @@ function SmartRocket.client_onScriptUpdate(self, dt)
end

function SmartRocket.client_onScriptDestroy(self)
local deleted_projectiles = _cpProj_cl_destroyProjectiles(self.projectiles)
local deleted_projectiles = _cpProj_cl_destroyProjectiles(SmartRocket.projectiles)
SmartRocket.projectiles = {}
SmartRocket.proj_queue = {}
_cpPrint(("SmartRocket: Deleted %s projectiles"):format(deleted_projectiles))
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Cannons_Pack_libs/ScriptLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if CP_SCRIPTLOADER_SCRIPTS_LOADED then return end
CP_SCRIPTLOADER_SCRIPTS_LOADED = true

print("[CannonsPack] Version: 4.81")
print("[CannonsPack] Version: 4.82")
print("[CannonsPack] Loading libraries...")

dofile("FunctionReferences.lua")
Expand Down
4 changes: 2 additions & 2 deletions Scripts/_info.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
What are u doing here? you little thief

Cannons Pack version 4.81 changelog:
1. Fixed the shooting position for Small Rocket Pod
Cannons Pack version 4.82 changelog:
1. Fixed projectiles not working in survival worlds

Made by:
Questionable Mark - creator of all the textures, UV maps and also some scripts and cannon models.
Expand Down

0 comments on commit 9474adb

Please sign in to comment.