- Joined
- Jun 6, 2015
- Messages
- 82
I heard that there is no such thing as a stupid question..
Ok so I am gonna try to do some LUA here again. I'm sure there is a simple explanation for this but I cant figure it out.
I have created a simple spell and it works great. I don't quite get how to use custom made initialization yet so I am doing it the standard way.
(I have bribes Damage Engine installed, although I have changed the Damage to DamageE in an attempt to make it compatible with NewBonus's Damage interface)
So there is no problem in doing this, it works great. BUT when I install the Chopinski's newbonus system into the map, my triggers don't work anymore. They work only once.
I tried to delete newbonus and it worked again.
Any tips on how to implment both bribes Damage Engine and Chopinskis NewBonus?
Initializing the spell:
The spell:
NewBonus: New Bonus [vJASS][LUA]
Damage Engine: Damage Engine 5.A.0.0
Ok so I am gonna try to do some LUA here again. I'm sure there is a simple explanation for this but I cant figure it out.
I have created a simple spell and it works great. I don't quite get how to use custom made initialization yet so I am doing it the standard way.
(I have bribes Damage Engine installed, although I have changed the Damage to DamageE in an attempt to make it compatible with NewBonus's Damage interface)
So there is no problem in doing this, it works great. BUT when I install the Chopinski's newbonus system into the map, my triggers don't work anymore. They work only once.
I tried to delete newbonus and it worked again.
Any tips on how to implment both bribes Damage Engine and Chopinskis NewBonus?
Initializing the spell:
-
RegisterKvartsmester
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Custom script: RegisterQuartzHammerCastTrigger()
-
Custom script: RegisterQuartzHammerTrigger()
-
-
The spell:
Lua:
local unitSpellCastFlags = {}
function OnQuartzHammerCast()
local castingUnit = GetTriggerUnit()
local spellId = GetSpellAbilityId()
if spellId == FourCC('KV01') then
unitSpellCastFlags[GetHandleId(castingUnit)] = true
end
end
function RegisterQuartzHammerCastTrigger()
local castTrigger = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(castTrigger, EVENT_PLAYER_UNIT_SPELL_CAST)
TriggerAddAction(castTrigger, OnQuartzHammerCast)
end
function QuartzHammerEffect()
local source = udg_DamageEventSource
local target = udg_DamageEventTarget
if unitSpellCastFlags[GetHandleId(source)] then
-- Clear the flag to ensure it's only triggered once per cast
unitSpellCastFlags[GetHandleId(source)] = nil
-- Get x, y coordinates of the target
local x = GetUnitX(target)
local y = GetUnitY(target)
-- Set attribute stats
local strength = GetHeroStr(source, true)
local intelligence = GetHeroInt(source, true)
-- Set stun duration (max 5 seconds by bonuses)
local stunDur = 2 + (strength * 0.01)
if stunDur > 5 then
stunDur = 5
end
-- Set damage
local targetDamage = strength * 3
local aoeDamage = intelligence * 1
-- Deal damage to the target unit
DamageE.apply(source, target, targetDamage, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
-- Create the dummy unit at the target location
local dummy = CreateUnit(GetOwningPlayer(source), FourCC('DUMM'), x, y, 0)
-- Give the dummy unit the Stomp ability and set its stun duration and damage
UnitAddAbility(dummy, FourCC('S000'))
BlzSetAbilityRealLevelField(BlzGetUnitAbility(dummy, FourCC('S000')), ABILITY_RLF_DURATION_NORMAL, 0, stunDur)
BlzSetAbilityRealLevelField(BlzGetUnitAbility(dummy, FourCC('S000')), ABILITY_RLF_DAMAGE_WRS1, 0, aoeDamage)
IssueImmediateOrder(dummy, "stomp")
-- Remove the dummy unit after a short time
TimerStart(CreateTimer(), 2.5, false, function()
RemoveUnit(dummy)
DestroyTimer(GetExpiredTimer())
end)
end
end
function RegisterQuartzHammerTrigger()
local quartzHammerTrigger = CreateTrigger()
TriggerRegisterVariableEvent(quartzHammerTrigger, "udg_DamageEvent", NOT_EQUAL, 0.00)
TriggerAddAction(quartzHammerTrigger, QuartzHammerEffect)
end
NewBonus: New Bonus [vJASS][LUA]
Damage Engine: Damage Engine 5.A.0.0