Skip to content

Commit e7333d5

Browse files
committed
always fire a couple spells independent on how far away shooter is
1 parent 7ffc566 commit e7333d5

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

quant.ew/files/core/net_handling.lua

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,19 @@ local function reset_cast_state_if_has_any_other_item(player_data)
9898
end
9999
end
100100

101+
local fire_anyways = {"SUMMON_HOLLOW_EGG", "SUMMON_ROCK", "TNTBOX", "TNTBOX_BIG", "FISH", "LEVITATION_FIELD", "POLYMORPH_FIELD", "ALL_DISCS",
102+
"SHIELD_FIELD", "TELEPORTATION_FIELD", "BERSERK_FIELD", "ELECTROCUTION_FIELD", "FREEZE_FIELD", "CHAOS_POLYMORPH_FIELD",
103+
"BOMB_DETONATOR", "DESTRUCTION", "MASS_POLYMORPH", "ALL_ACID", "ALL_BLACKHOLES", "ALL_DEATHCROSSES", "ALL_ROCKETS", "ALL_NUKES",
104+
"CIRCLE_ACID", "SEA_ACID", "ALL_SPELLS", "PIPE_BOMB", "PIPE_BOMB_DEATH_TRIGGER"}
105+
101106
function net_handling.mod.fire(peer_id, fire_data)
102107
local player_data = player_fns.peer_get_player_data(peer_id)
103108
local entity = player_data.entity
104109
if not EntityGetIsAlive(entity) then
105110
return
106111
end
112+
local inventory2Comp
113+
local mActiveItem
107114
if ctx.my_id ~= ctx.host_id and EntityGetIsAlive(ctx.my_player.entity) then
108115
local x, y = EntityGetTransform(entity)
109116
local my_x, my_y = EntityGetTransform(ctx.my_player.entity)
@@ -112,10 +119,24 @@ function net_handling.mod.fire(peer_id, fire_data)
112119
local cdx, cdy = cam_x - x, cam_y - y
113120
local DIST = 1024 * 1024
114121
if mdx * mdx + mdy * mdy > DIST and cdx * cdx + cdy * cdy > DIST then
122+
inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component")
123+
if inventory2Comp ~= nil then
124+
mActiveItem = ComponentGetValue2(inventory2Comp, "mActiveItem")
125+
if mActiveItem ~= nil then
126+
local children = EntityGetAllChildren(state.attack_wand)
127+
for _, child in pairs(children or {}) do
128+
local spell = EntityGetFirstComponentIncludingDisabled(child, "ItemActionComponent")
129+
local spell_name = ComponentGetValue2(spell, "action_id")
130+
if table.contains(fire_anyways, spell_name) then
131+
goto cont
132+
end
133+
end
134+
end
135+
end
115136
return
116137
end
117138
end
118-
139+
::cont::
119140
local rng = fire_data[1]
120141
local message = fire_data[2]
121142

@@ -133,13 +154,17 @@ function net_handling.mod.fire(peer_id, fire_data)
133154
local controlsComp = EntityGetFirstComponentIncludingDisabled(entity, "ControlsComponent")
134155

135156
if controlsComp ~= nil then
136-
local inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component")
157+
if inventory2Comp == nil then
158+
inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component")
159+
end
137160

138161
if (inventory2Comp == nil) then
139162
return
140163
end
141164

142-
local mActiveItem = ComponentGetValue2(inventory2Comp, "mActiveItem")
165+
if mActiveItem == nil then
166+
mActiveItem = ComponentGetValue2(inventory2Comp, "mActiveItem")
167+
end
143168

144169
if mActiveItem ~= nil then
145170
local aimNormal_x, aimNormal_y = ComponentGetValue2(controlsComp, "mAimingVectorNormalized")

0 commit comments

Comments
 (0)