- Joined
- Jul 19, 2007
- Messages
- 942
I have problem with a JASS-ability where the dummy unit casts the "armor reduction ability" on damaged units only sometimes and the "armor reduction ability" doesn't seems set level to the same level as the main-ability. What could be wrong? I have tried everything but I can't find anything wrong and I have checked the raw-codes of the ability/dummy and it's all correct...
JASS:
//TESH.scrollpos=153
//TESH.alwaysfold=0
// +------------------------------------------------------------+
// | |
// | -=-=- Armor Crush [v1.5] -=-=- |
// | -=-=- By WolfieeifloW -=-=- |
// | Requires JASS NewGen and AIDS |
// | |
// +------------------------------------------------------------+
// | |
// | Gives a 15% chance to deal a portion of your health |
// | back at the attacker. This blow is so shocking it |
// | also reduces the attackers armor. |
// | |
// +------------------------------------------------------------+
// | |
// | -=-=- How To Implement -=-=- |
// | 1. Copy this trigger into your map |
// | 2. Copy AIDS into your map |
// | b. Implement AIDS (Follow the script instructions) |
// | 3. Copy the buffs into your map |
// | 4. Copy the abilities into your map |
// | 5. Copy the dummies into your map |
// | 6. Make sure the 'Rawcodes' in the trigger match |
// | your buffs/abilities/units in Object Editor |
// | 7. Customize the spell |
// | 8. Enjoy! |
// | |
// +------------------------------------------------------------+
// | |
// | -=-=- Credits -=-=- |
// | Credits are not needed, but appreciated |
// | Just don't claim this as yours |
// | |
// +------------------------------------------------------------+
// | -=-=- Version History -=-=- |
// | |
// | Version 1.5 |
// | - Changed PUI to AIDS |
// | - Fixed some coding issues |
// | - Added some test map features |
// | - Touched up coding conventions |
// | |
// | Version 1.4 |
// | - Fixed a FirstOfGroup to ForGroup |
// | - Fixed a sound leak |
// | - Fixed texttag leak |
// | - Made floating text more efficient |
// | Credits to Artificial |
// | |
// | Version 1.3 |
// | - Fixed a major bug with Armor Crush not stacking |
// | - Made Armor Crush based off an aura |
// | Prevents the buff from being removed |
// | - Implemented PUI to save GetUnitUserData() |
// | - Fixed some BJ's |
// | - Made Armor Crush sound effect customizable |
// | - Various minor changes |
// | |
// | Older versions... |
// | Read changelog in thread |
// | |
// +------------------------------------------------------------+
scope ArmorCrush initializer Init
// +-------------------------------------+
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// +-------------------------------------+
globals
private constant integer ABILITY_ID = 'AACR'
// Rawcode of 'Armor Crush' ability
private constant integer DUMMY_ABILITY_ID = 'A000'
// Rawcode of 'Armor Crushed' ability
private constant integer BUFF_ID = 'BACR'
// Rawcode of 'Armor Crush' buff
private constant integer DUMMY_BUFF_ID = 'BACD'
// Rawcode of 'Armor Crushed' buff
private constant integer DUMMY = 'nACD'
// Rawcode of 'DummyCaster' unit
private constant integer VOLUME = 0
// Volume of the played sound
private constant string EFFECT = ""
// Path for Armor Crush special effect
private constant string ATTACH = ""
// Attachment point of Armor Crush special effect
private constant string SOUND = ""
// Path for Armor Crush sound effect
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_HERO
// Attack type Armor Crush deals
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_FIRE
// Damage type Armor Crush deals
private constant real TEXT_OFFSET = 0
// Floating text offset
private constant real TEXT_SIZE = 10
// Floating text font size
private constant integer TEXT_RED = 0
// Floating text red color amount (0-100)
private constant integer TEXT_GREEN = 0
// Floating text green color amount (0-100)
private constant integer TEXT_BLUE = 100
// Floating text blue color amount (0-100)
private constant integer TEXT_ALPHA = 0
// Floating text transparency (0-100)
private constant real TEXT_LIFE = 3
// Floating text life
private constant real TEXT_AGE = 2
// Floating text age
private constant real TEXT_SPEED = 75
// Floating text speed
private constant real TEXT_ANGLE = 90
// Floating text angle
private constant string DUMMY_STRING = "acidbomb"
// 'Order String Use/Turn On' for 'Armor Crushed' ability
// Don't change the following three(3) variables
private sound CrushSound = null // Don't change this!
private constant group CRUSHED_GROUP = CreateGroup() // Don't change this!
private integer array UnitCustom // Don't change this!
// Don't change the above three(3) variables
endglobals
// +------------------------------------------------+
// | -=-=- CONFIGURABLE FUNCTIONS -=-=- |
// | -=-=- CONFIGURABLE FUNCTIONS -=-=- |
// | -=-=- CONFIGURABLE FUNCTIONS -=-=- |
// +------------------------------------------------+
// Chance to cast Armor Crush
private function Chance takes integer level returns integer
return 15
endfunction
// How many times Armor Crush stacks
private function Stack takes integer level returns integer
return 3
endfunction
// Percentage of health Armor Crush returns
// Each 0.01 is equal to 1% (So 0.05 would be 5%, 0.25 would be 25%, and so on)
private function Return takes integer level returns real
return level * 0.02
endfunction
// +----------------------------------------------+
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// +----------------------------------------------+
private function ACConditions takes nothing returns boolean
return GetRandomInt(1, 100) <= Chance(GetUnitAbilityLevel(GetTriggerUnit(), ABILITY_ID)) and GetUnitAbilityLevel(GetTriggerUnit(), BUFF_ID) > 0
endfunction
private function ACActions takes nothing returns nothing
local unit ar = GetAttacker()
local real x = GetUnitX(ar)
local real y = GetUnitY(ar)
local unit ad = GetTriggerUnit()
local integer damageAttacker
local texttag tt = CreateTextTag()
local unit u
local integer QT = GetUnitAbilityLevel(ad, ABILITY_ID)
if CrushSound == null then
set CrushSound = CreateSound(SOUND, false, true, true, 10, 10, "SpellsEAX")
endif
call AttachSoundToUnit(CrushSound, ar)
call SetSoundVolume(CrushSound, VOLUME)
call StartSound(CrushSound)
call KillSoundWhenDone(CrushSound)
set CrushSound = null
call DestroyEffect(AddSpecialEffectTarget(EFFECT, ar, ATTACH))
set damageAttacker = R2I(GetWidgetLife(ar))
call UnitDamageTarget(ad, ar, (GetUnitState(ad, UNIT_STATE_LIFE) * (Return(QT))), true, true, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE_WHOKNOWS)
set damageAttacker = damageAttacker - R2I(GetWidgetLife(ar))
set u = CreateUnit(GetOwningPlayer(ad), DUMMY, x, y, GetUnitFacing(ar))
call SetUnitAbilityLevel(u, DUMMY_ABILITY_ID, (UnitCustom[GetUnitIndex(ar)] * QT))
call IssueTargetOrder(u, DUMMY_STRING, ar)
call UnitApplyTimedLife(u, 'BACD', 5.00)
set tt = CreateTextTagUnitBJ((I2S(damageAttacker) + "!" ), ar, TEXT_OFFSET, TEXT_SIZE, TEXT_RED, TEXT_GREEN, TEXT_BLUE, TEXT_ALPHA)
call SetTextTagPermanent(tt, false)
call SetTextTagLifespan(tt, TEXT_LIFE)
call SetTextTagFadepoint(tt, TEXT_AGE)
call SetTextTagVelocityBJ(tt, TEXT_SPEED, TEXT_ANGLE)
set tt = null
if UnitCustom[GetUnitIndex(ar)] < Stack(QT) then
set UnitCustom[GetUnitIndex(ar)] = UnitCustom[GetUnitIndex(ar)] + 1
set u = CreateUnit(GetOwningPlayer(ad), DUMMY, x, y, GetUnitFacing(ar))
call SetUnitAbilityLevel(u, DUMMY_ABILITY_ID, (UnitCustom[GetUnitIndex(ar)] * QT))
call IssueTargetOrder(u, DUMMY_STRING, ar)
call UnitApplyTimedLife(u, 'BACD', 5.00)
if (IsUnitInGroup(ar, CRUSHED_GROUP) == false) then
call GroupAddUnit(CRUSHED_GROUP, ar)
endif
endif
set ar = null
set ad = null
set u = null
endfunction
private function CGRConditions takes nothing returns boolean
return FirstOfGroup(CRUSHED_GROUP) != null
endfunction
private function RemoveU takes nothing returns nothing
if GetUnitAbilityLevel(GetEnumUnit(), DUMMY_BUFF_ID) < 1 then
call GroupRemoveUnit(CRUSHED_GROUP, GetEnumUnit())
set UnitCustom[GetUnitIndex(GetEnumUnit())] = 0
endif
endfunction
private function CGRActions takes nothing returns nothing
call ForGroup(CRUSHED_GROUP, function RemoveU)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(trig, Condition(function ACConditions))
call TriggerAddAction(trig, function ACActions)
set trig = CreateTrigger()
call TriggerRegisterTimerEvent(trig, 1.50, true)
call TriggerAddCondition(trig, Condition(function CGRConditions))
call TriggerAddAction(trig, function CGRActions)
set trig = null
endfunction
endscope


