1
1
LinkLuaModifier (" modifier_item_bloodstone_oaa" , " items/bloodstone.lua" , LUA_MODIFIER_MOTION_NONE )
2
- LinkLuaModifier (" modifier_item_bloodstone_charge_collector" , " items/bloodstone.lua" , LUA_MODIFIER_MOTION_NONE )
2
+ -- LinkLuaModifier("modifier_item_bloodstone_charge_collector", "items/bloodstone.lua", LUA_MODIFIER_MOTION_NONE)
3
3
4
4
item_bloodstone_1 = class ({})
5
5
@@ -18,7 +18,7 @@ item_bloodstone_4 = item_bloodstone_1
18
18
item_bloodstone_5 = item_bloodstone_1
19
19
20
20
---- ----------------------------------------------------------------------
21
- -- base modifier, is an aura
21
+ -- base modifier
22
22
23
23
modifier_item_bloodstone_oaa = class ({})
24
24
@@ -170,31 +170,55 @@ function modifier_item_bloodstone_oaa:GetModifierConstantManaRegen()
170
170
end
171
171
172
172
---- ----------------------------------------------------------------------
173
- -- charge loss
173
+ -- charge handling
174
174
175
175
function modifier_item_bloodstone_oaa :OnDeath (keys )
176
- local dead = self :GetCaster ()
176
+ local caster = self :GetCaster ()
177
+ local dead = keys .unit
178
+ local killer = keys .attacker
179
+ local stone = self :GetAbility ()
180
+
181
+ -- someone else died or owner is reincarnating
182
+ if caster ~= dead or caster :IsReincarnating () then
183
+ -- Dead unit is an actually dead real enemy hero unit
184
+ if caster :GetTeamNumber () ~= dead :GetTeamNumber () and dead :IsRealHero () and not dead :IsTempestDouble () and not dead :IsReincarnating () then
185
+ -- Charge gain
186
+
187
+ local function IsItemBloodstone (item )
188
+ return string.sub (item :GetAbilityName (), 0 , 15 ) == " item_bloodstone"
189
+ end
190
+
191
+ local items = map (partial (caster .GetItemInSlot , caster ), range (0 , 5 ))
192
+ local firstBloodstone = nth (1 , filter (IsItemBloodstone , items ))
193
+ local isSelfFirstBloodstone = firstBloodstone == stone
177
194
178
- if dead ~= keys .unit then
179
- -- someone else died
195
+ local casterToDeadVector = dead :GetAbsOrigin () - caster :GetAbsOrigin ()
196
+ local isDeadInChargeRange = casterToDeadVector :Length2D () <= stone :GetSpecialValueFor (" charge_range" )
197
+
198
+ if (isDeadInChargeRange or killer == caster ) and isSelfFirstBloodstone then
199
+ stone :SetCurrentCharges (stone :GetCurrentCharges () + 1 )
200
+ self .charges = stone :GetCurrentCharges ()
201
+ end
202
+ end
180
203
return
181
204
end
182
205
183
- local stone = self :GetAbility ()
206
+ -- Charge loss
207
+
184
208
local oldCharges = stone :GetCurrentCharges ()
185
209
local newCharges = math.max (1 , math.ceil (oldCharges * stone :GetSpecialValueFor (" on_death_removal" )))
186
210
187
211
stone :SetCurrentCharges (newCharges )
188
212
self .charges = newCharges
189
213
190
- if not dead :IsRealHero () or dead :IsTempestDouble () then
214
+ if not caster :IsRealHero () or caster :IsTempestDouble () then
191
215
return
192
216
end
193
217
194
218
local healAmount = stone :GetSpecialValueFor (" heal_on_death_base" ) + (stone :GetSpecialValueFor (" heal_on_death_per_charge" ) * oldCharges )
195
219
local heroes = FindUnitsInRadius (
196
- dead :GetTeamNumber (),
197
- dead :GetAbsOrigin (),
220
+ caster :GetTeamNumber (),
221
+ caster :GetAbsOrigin (),
198
222
nil ,
199
223
stone :GetSpecialValueFor (" heal_on_death_range" ),
200
224
DOTA_UNIT_TARGET_TEAM_FRIENDLY ,
@@ -213,67 +237,67 @@ end
213
237
---- ----------------------------------------------------------------------
214
238
-- aura stuff
215
239
216
- function modifier_item_bloodstone_oaa :IsAura ()
217
- return true
218
- end
219
-
220
- function modifier_item_bloodstone_oaa :GetAuraSearchType ()
221
- return DOTA_UNIT_TARGET_HERO
222
- end
223
-
224
- function modifier_item_bloodstone_oaa :GetAuraSearchTeam ()
225
- return DOTA_UNIT_TARGET_TEAM_ENEMY
226
- end
227
-
228
- function modifier_item_bloodstone_oaa :GetAuraRadius ()
229
- return self :GetAbility ():GetSpecialValueFor (" charge_range" )
230
- end
231
-
232
- function modifier_item_bloodstone_oaa :GetModifierAura ()
233
- return " modifier_item_bloodstone_charge_collector"
234
- end
235
-
236
- ---- ----------------------------------------------------------------------
237
- -- charge collector, stacking modifiers that gives stacks
238
- -- stacking auras don't get applied more than once no matter what
239
-
240
- modifier_item_bloodstone_charge_collector = class ({})
241
-
242
- function modifier_item_bloodstone_charge_collector :DeclareFunctions ()
243
- return {
244
- MODIFIER_EVENT_ON_DEATH
245
- }
246
- end
247
-
248
- function modifier_item_bloodstone_charge_collector :IsHidden ()
249
- return true
250
- end
251
- function modifier_item_bloodstone_charge_collector :GetAttributes ()
252
- return MODIFIER_ATTRIBUTE_MULTIPLE
253
- end
254
-
255
- -- charge gain
256
- function modifier_item_bloodstone_charge_collector :OnDeath (keys )
257
- if not IsServer () then
258
- return
259
- end
260
-
261
- local dead = self :GetParent ()
262
-
263
- if dead ~= keys .unit then
264
- -- someone else died
265
- return
266
- end
267
-
268
- local caster = self :GetCaster ()
269
-
270
- -- Find the first bloodstone we can
271
- local found = false
272
- for i = 0 , 5 do
273
- local item = caster :GetItemInSlot (i )
274
- if not found and item and string.sub (item :GetAbilityName (), 0 , 15 ) == " item_bloodstone" then
275
- found = true
276
- item :SetCurrentCharges ( item :GetCurrentCharges () + 1 )
277
- end
278
- end
279
- end
240
+ -- function modifier_item_bloodstone_oaa:IsAura()
241
+ -- return true
242
+ -- end
243
+
244
+ -- function modifier_item_bloodstone_oaa:GetAuraSearchType()
245
+ -- return DOTA_UNIT_TARGET_HERO
246
+ -- end
247
+
248
+ -- function modifier_item_bloodstone_oaa:GetAuraSearchTeam()
249
+ -- return DOTA_UNIT_TARGET_TEAM_ENEMY
250
+ -- end
251
+
252
+ -- function modifier_item_bloodstone_oaa:GetAuraRadius()
253
+ -- return self:GetAbility():GetSpecialValueFor("charge_range")
254
+ -- end
255
+
256
+ -- function modifier_item_bloodstone_oaa:GetModifierAura()
257
+ -- return "modifier_item_bloodstone_charge_collector"
258
+ -- end
259
+
260
+ -- -- ------------------------------------------------------------------------
261
+ -- -- charge collector, stacking modifiers that gives stacks
262
+ -- -- stacking auras don't get applied more than once no matter what
263
+
264
+ -- modifier_item_bloodstone_charge_collector = class({})
265
+
266
+ -- function modifier_item_bloodstone_charge_collector:DeclareFunctions()
267
+ -- return {
268
+ -- MODIFIER_EVENT_ON_DEATH
269
+ -- }
270
+ -- end
271
+
272
+ -- function modifier_item_bloodstone_charge_collector:IsHidden()
273
+ -- return true
274
+ -- end
275
+ -- function modifier_item_bloodstone_charge_collector:GetAttributes()
276
+ -- return MODIFIER_ATTRIBUTE_MULTIPLE
277
+ -- end
278
+
279
+ -- -- charge gain
280
+ -- function modifier_item_bloodstone_charge_collector:OnDeath(keys)
281
+ -- if not IsServer() then
282
+ -- return
283
+ -- end
284
+
285
+ -- local dead = self:GetParent()
286
+
287
+ -- if dead ~= keys.unit or not keys.unit:IsRealHero() or keys.unit:IsReincarnating() or keys.unit:IsTempestDouble() then
288
+ -- -- someone else died or it was not a real hero, Tempest Double, or is reincarnating
289
+ -- return
290
+ -- end
291
+
292
+ -- local caster = self:GetCaster()
293
+
294
+ -- -- Find the first bloodstone we can
295
+ -- local found = false
296
+ -- for i = 0, 5 do
297
+ -- local item = caster:GetItemInSlot(i)
298
+ -- if not found and item and string.sub(item:GetAbilityName(), 0, 15) == "item_bloodstone" then
299
+ -- found = true
300
+ -- item:SetCurrentCharges( item:GetCurrentCharges() + 1 )
301
+ -- end
302
+ -- end
303
+ -- end
0 commit comments