- Joined
- Jul 19, 2007
- Messages
- 970
Ok here is 2 spells I have imported from a spell pack and they seems to be working fine actually but the silence-effect doesn't appear on attacked enemies when "Dark Blade" is active and even more wierd, the "Charging Strikes" spell sometimes seems to silence enemies that are damage by the spell, even if it doesn't have "Dark Blade" spell active. Why is this bugs happening? Here is describtion how the spells works like.
Here is the triggers for these spells and they seems to be using a "Dummy Caster" system for it.
So why isn't the attacked unit silenced if "Dark Blade" is active and why does "Charging Strikes" sometimes silence damaged enemies by the spell, even if "Dark Blade" isn't active? And yes I have checked everything and rawcodes is correct. These bugs is even happening on the original spell pack map...
Here is the triggers for these spells and they seems to be using a "Dummy Caster" system for it.
JASS:
//TESH.scrollpos=3
//TESH.alwaysfold=0
library DarkBlades initializer InitTrig uses Damage
//=====================================================================//
// Dark Blades //
// by iAyanami aka Glenphir //
//=====================================================================//
// //
//=====================================================================//
// Implementation Instructions //
//---------------------------------------------------------------------//
// Copy these objects into your map //
// [Abilities] //
// 1) Dark Blades //
// 2) Dark Blades (Spell Book) //
// 3) Dark Blades (Damage - Level 1) //
// 4) Dark Blades (Damage - Level 2) //
// 5) Dark Blades (Damage - Level 3) //
// 6) Dark Blades (Damage - Level 4) //
// 7) Dark Blades (Silence) //
// Ensure that 3), 4), 5), and 6) are inside the Spell Book, 2) //
// //
// [Buffs] //
// 1) Dark Blades (Caster) //
// 2) Dark Blades (Target) //
// //
//=====================================================================//
//=====================================================================//
// CONFIGURATION //
//=====================================================================//
globals
private constant integer ABIL_ID1 = 'A0TE' // raw code of Ability "Dark Blades"
private constant integer ABIL_ID2 = 'A0TF' // raw code of Ability "Dark Blades (Spell Book)"
private constant integer ABIL_ID3 = 'A0TD' // raw code of Ability "Dark Blades (Silence)"
private constant integer BUFF_ID = 'B08S' // raw code of Buff "Dark Blades (Caster)"
private constant boolean PLAYSOUND = false // true if sound is played upon casting
endglobals
private function GetDuration takes unit caster returns real
return 2.00 + (GetUnitAbilityLevel(caster, ABIL_ID1)) // duration of the spell
endfunction
//=====================================================================//
// END CONFIGURATION //
//=====================================================================//
private struct db
unit u
real r
endstruct
public function GetDarkBlades takes unit u returns integer
return GetUnitAbilityLevel(u, ABIL_ID1)
endfunction
public function GetSilenceAbil takes nothing returns integer
return ABIL_ID3
endfunction
public function GetSilence takes unit u returns integer
return GetUnitAbilityLevel(u, ABIL_ID1)
endfunction
private function Expire takes nothing returns boolean
local db d = KT_GetData()
set d.r = d.r - 0.10
if d.r <= 0.00 then
call UnitRemoveAbility(d.u, ABIL_ID2)
call UnitRemoveAbility(d.u, BUFF_ID)
call d.destroy()
return true
elseif GetUnitAbilityLevel(d.u, ABIL_ID2) == 0 then
call UnitAddAbility(d.u, ABIL_ID2)
call SetUnitAbilityLevel(d.u, ABIL_ID2, GetUnitAbilityLevel(d.u, ABIL_ID1))
endif
return false
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABIL_ID1
endfunction
private function Actions takes nothing returns nothing
local db d = db.create()
set d.u = GetTriggerUnit()
set d.r = GetDuration(d.u)
if PLAYSOUND then
endif
call UnitAddAbility(d.u, ABIL_ID2)
call SetUnitAbilityLevel(d.u, ABIL_ID2, GetUnitAbilityLevel(d.u, ABIL_ID1))
call KT_Add(function Expire, d, 0.10)
endfunction
private function Silence takes nothing returns boolean
local unit c = GetEventDamageSource()
local unit t = GetTriggerUnit()
if Damage_IsAttack() and GetUnitAbilityLevel(c, BUFF_ID) > 0 then
call CasterDummy_TargetPoint(c, GetUnitX(t), GetUnitY(t), ABIL_ID3, GetUnitAbilityLevel(c, ABIL_ID1), "silence")
endif
set c = null
set t = null
return false
endfunction
private function InitTrig takes nothing returns nothing
local trigger t = CreateTrigger()
local trigger t2 = CreateTrigger()
local integer i = 0
loop
exitwhen i == 12
call SetPlayerAbilityAvailable(Player(i), ABIL_ID2, false)
set i = i + 1
endloop
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
call TriggerAddCondition(t2, Condition(function Silence))
call Damage_RegisterEvent(t2)
endfunction
endlibrary
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope ChargingStrikes initializer InitTrig
//=====================================================================//
// Charging Strikes //
// by iAyanami aka Glenphir //
//=====================================================================//
// //
//=====================================================================//
// Implementation Instructions //
//---------------------------------------------------------------------//
// Copy these objects into your map //
// [Abilities] //
// 1) Charging Strikes //
// 2) Charging Strikes (Attack Speed) //
// //
//=====================================================================//
//=====================================================================//
// CONFIGURATION //
//=====================================================================//
globals
private constant integer ABIL_ID1 = 'A0TG' // raw code of Ability "Charging Strikes"
private constant integer ABIL_ID2 = 'A0TH' // raw code of Ability "Charging Strikes (Attack Speed)"
private constant real MINDMG = 23.00 // minimum damage dealt
private constant real MAXDMG = 25.00 // maximum damage dealt
private constant real TIME = 0.25 // time taken for charge
private constant real AOE = 150.00 // area of effect of the damage
private constant string SLIDE_EFFECT = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl" // special effect of the charge. set to "none.mdl" if no effects are desired
private constant string HIT_EFFECT = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" // special effect on the targets when they are hit. set to "none.mdl" if no effects are desired.
private constant string HIT_ATTACH = "chest" // attachment point of HIT_EFFECT
private constant boolean STR = false // true if the hero's primary attribute is strength
private constant boolean AGI = true // true if the hero's primary attribute is agility
private constant boolean INT = false // true if the hero's primary attribute is intelligence
// if all is set to false, damage dealt will be random number between MINDMG and MAXDMG
endglobals
private function GetDuration takes unit caster returns real
return 6.00 // duration of attack speed bonus
endfunction
globals
private constant boolean EXTRADMG = true // set to true to deal extra damage and silence enemies if dark blades are activated
endglobals
private function GetExtraDamage takes unit caster, real damage returns real
local integer i = DarkBlades_GetDarkBlades(caster)
if i == 0 then
return damage
endif
return damage * (1.30 + (0.20 * DarkBlades_GetDarkBlades(caster))) // new damage dealt
endfunction
//=====================================================================//
// END CONFIGURATION //
//=====================================================================//
private struct cs
real offsetx
real offsety
real dist
real speed
real damage
real r
group g
unit u
endstruct
private function GetDamage takes unit caster returns real
if STR then
return GetRandomReal(MINDMG, MAXDMG) + I2R(GetHeroStr(caster, true))
elseif AGI then
return GetRandomReal(MINDMG, MAXDMG) + I2R(GetHeroAgi(caster, true))
elseif INT then
return GetRandomReal(MINDMG, MAXDMG) + I2R(GetHeroInt(caster, true))
endif
return GetRandomReal(MINDMG, MAXDMG)
endfunction
private function AttackSpeed takes nothing returns boolean
local cs d = KT_GetData()
set d.r = d.r - 0.10
if d.r <= 0 then
call UnitRemoveAbility(d.u, ABIL_ID2)
call d.destroy()
return true
elseif GetUnitAbilityLevel(d.u, ABIL_ID2) == 0 then
call UnitAddAbility(d.u, ABIL_ID2)
call SetUnitAbilityLevel(d.u, ABIL_ID2, GetUnitAbilityLevel(d.u, ABIL_ID1))
endif
return false
endfunction
private function Slide takes nothing returns boolean
local cs d = KT_GetData()
local group g = Group.get()
local real x = GetUnitX(d.u) + d.offsetx
local real y = GetUnitY(d.u) + d.offsety
local real damage
local unit u
if d.dist <= 0 then
call SetUnitPathing(d.u, true)
call UnitAddAbility(d.u, ABIL_ID2)
call SetUnitAbilityLevel(d.u, ABIL_ID2, GetUnitAbilityLevel(d.u, ABIL_ID1))
call KT_Add(function AttackSpeed, d, 0.10)
call Group.release(d.g)
return true
elseif not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) then
call SetUnitPathing(d.u, false)
call SetUnitX(d.u, x)
call SetUnitY(d.u, y)
endif
call AddSpecialEffect(SLIDE_EFFECT, x, y)
call DestroyEffect(bj_lastCreatedEffect)
set d.dist = d.dist - d.speed
call GroupEnumUnitsInRange(g, x, y, AOE, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if not IsUnitType(u, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u, GetOwningPlayer(d.u)) and not IsUnitType(u, UNIT_TYPE_DEAD) and not IsUnitInGroup(u, d.g) then
if EXTRADMG == true then
call CasterDummy_TargetPoint(d.u, GetUnitX(u), GetUnitY(u), DarkBlades_GetSilenceAbil(), DarkBlades_GetDarkBlades(d.u), "silence")
endif
call UnitDamageTargetEx2(d.u, u, d.damage, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call AddSpecialEffectTarget(HIT_EFFECT, u, HIT_ATTACH)
call GroupAddUnit(d.g, u)
set d.damage = d.damage * 0.85
endif
call GroupRemoveUnit(g, u)
endloop
call Group.release(g)
set g = null
set u = null
return false
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABIL_ID1
endfunction
private function Actions takes nothing returns nothing
local cs d = cs.create()
local real dx = GetSpellTargetX()
local real dy = GetSpellTargetY()
local real angle
local real x
local real y
set d.damage = GetDamage(d.u)
if EXTRADMG == true then
set d.damage = GetExtraDamage(d.u, d.damage)
endif
set d.g = Group.get()
set d.u = GetTriggerUnit()
set x = GetUnitX(d.u)
set y = GetUnitY(d.u)
set angle = Atan2(dy - y, dx - x)
set d.dist = SquareRoot(((x - dx) * (x - dx)) + ((y - dy) * (y - dy)))
set d.speed = d.dist / TIME * 0.03
set d.offsetx = d.speed * Cos(angle)
set d.offsety = d.speed * Sin(angle)
set d.r = GetDuration(d.u)
call KT_Add(function Slide, d, 0.03)
endfunction
private function InitTrig takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
[CODE=JASS]
//TESH.scrollpos=0
//TESH.alwaysfold=0
library CasterDummy initializer InitTrig
//=====================================================================//
// CONFIGURATION //
//=====================================================================//
globals
private constant integer DUMMY_ID = 'n023' // raw code of Caster Dummy
endglobals
//=====================================================================//
// END CONFIGURATION //
//=====================================================================//
globals
private unit dummy
endglobals
public function TargetUnit takes unit owner, unit target, integer abil, integer level, string order returns nothing
call UnitAddAbility(dummy, abil)
call SetUnitAbilityLevel(dummy, abil, level)
call SetUnitOwner(dummy, GetOwningPlayer(owner), false)
call IssueTargetOrder(dummy, order, target)
call UnitRemoveAbility(dummy, abil)
endfunction
public function TargetPoint takes unit owner, real x, real y, integer abil, integer level, string order returns nothing
call UnitAddAbility(dummy, abil)
call SetUnitAbilityLevel(dummy, abil, level)
call SetUnitOwner(dummy, GetOwningPlayer(owner), false)
call IssuePointOrder(dummy, order, x, y)
call UnitRemoveAbility(dummy, abil)
endfunction
private function InitTrig takes nothing returns nothing
local trigger t = CreateTrigger()
set dummy = CreateUnit(Player(0), DUMMY_ID, 0.00, 0.00, 0.00)
endfunction
endlibrary
So why isn't the attacked unit silenced if "Dark Blade" is active and why does "Charging Strikes" sometimes silence damaged enemies by the spell, even if "Dark Blade" isn't active? And yes I have checked everything and rawcodes is correct. These bugs is even happening on the original spell pack map...
Last edited:



