@@ -98,12 +98,19 @@ local function reset_cast_state_if_has_any_other_item(player_data)
98
98
end
99
99
end
100
100
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
+
101
106
function net_handling .mod .fire (peer_id , fire_data )
102
107
local player_data = player_fns .peer_get_player_data (peer_id )
103
108
local entity = player_data .entity
104
109
if not EntityGetIsAlive (entity ) then
105
110
return
106
111
end
112
+ local inventory2Comp
113
+ local mActiveItem
107
114
if ctx .my_id ~= ctx .host_id and EntityGetIsAlive (ctx .my_player .entity ) then
108
115
local x , y = EntityGetTransform (entity )
109
116
local my_x , my_y = EntityGetTransform (ctx .my_player .entity )
@@ -112,10 +119,24 @@ function net_handling.mod.fire(peer_id, fire_data)
112
119
local cdx , cdy = cam_x - x , cam_y - y
113
120
local DIST = 1024 * 1024
114
121
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
115
136
return
116
137
end
117
138
end
118
-
139
+ :: cont ::
119
140
local rng = fire_data [1 ]
120
141
local message = fire_data [2 ]
121
142
@@ -133,13 +154,17 @@ function net_handling.mod.fire(peer_id, fire_data)
133
154
local controlsComp = EntityGetFirstComponentIncludingDisabled (entity , " ControlsComponent" )
134
155
135
156
if controlsComp ~= nil then
136
- local inventory2Comp = EntityGetFirstComponentIncludingDisabled (entity , " Inventory2Component" )
157
+ if inventory2Comp == nil then
158
+ inventory2Comp = EntityGetFirstComponentIncludingDisabled (entity , " Inventory2Component" )
159
+ end
137
160
138
161
if (inventory2Comp == nil ) then
139
162
return
140
163
end
141
164
142
- local mActiveItem = ComponentGetValue2 (inventory2Comp , " mActiveItem" )
165
+ if mActiveItem == nil then
166
+ mActiveItem = ComponentGetValue2 (inventory2Comp , " mActiveItem" )
167
+ end
143
168
144
169
if mActiveItem ~= nil then
145
170
local aimNormal_x , aimNormal_y = ComponentGetValue2 (controlsComp , " mAimingVectorNormalized" )
0 commit comments