- Joined
- Dec 2, 2016
- Messages
- 733
This script activates when chain lightning is casted.
So basically in this game you have a human. He is your main unit and if he dies that player loses the game.
Human has 600hp early game.
He has units that are 400hp(expendable units)
So the enemy team has to get their chain levels high enough to kill these 400hp units. This is needed for game to progress. Enemy kills these units gets gold and exp. Other team uses these units to repair a wall that protects their base.
So the problem here if I don't have this script is, if the enemy team which consists of two players with the chain lightning ability. If they get both 300dmg on their chain they can insta kill the player. So this script or what it's supposed to do is.
When player 1 uses the chain lightning ability, he does full damage. But right after the first chain is casted and hits a buff (grounded) is applied to the human(600hp unit) and then any chain after that first chain will do 60% less damage to the unit. This balances out the human, while still allowing the enemy teams to kill the 400hp unit without this buff.
So I'm really confused, when only 1 single enemy team player uses chain lightning on the human. This line below runs. The unit takes full damage from the chain and applies the buff to the unit.
But when two enemy team players both use chain at just about the same or similar time span this line runs:
Now what doesn't make sense to me is that if it's a solo chain lighting attack. The buff gets applied after the damage is dealt, yet when they both use the ability at the same time the buff gets applied before even the first chain damage is dealth and they both end up doing 60% less. What am I doing wrong here that's causing this? Thanks.
So basically in this game you have a human. He is your main unit and if he dies that player loses the game.
Human has 600hp early game.
He has units that are 400hp(expendable units)
So the enemy team has to get their chain levels high enough to kill these 400hp units. This is needed for game to progress. Enemy kills these units gets gold and exp. Other team uses these units to repair a wall that protects their base.
So the problem here if I don't have this script is, if the enemy team which consists of two players with the chain lightning ability. If they get both 300dmg on their chain they can insta kill the player. So this script or what it's supposed to do is.
When player 1 uses the chain lightning ability, he does full damage. But right after the first chain is casted and hits a buff (grounded) is applied to the human(600hp unit) and then any chain after that first chain will do 60% less damage to the unit. This balances out the human, while still allowing the enemy teams to kill the 400hp unit without this buff.
So I'm really confused, when only 1 single enemy team player uses chain lightning on the human. This line below runs. The unit takes full damage from the chain and applies the buff to the unit.
JASS:
else if (GetUnitAbilityLevel(ENUM_UNIT, ID_BUFF_GROUNDED) == 0) {
But when two enemy team players both use chain at just about the same or similar time span this line runs:
JASS:
if (GetUnitAbilityLevel(ENUM_UNIT, ID_BUFF_GROUNDED) > 0) {
Now what doesn't make sense to me is that if it's a solo chain lighting attack. The buff gets applied after the damage is dealt, yet when they both use the ability at the same time the buff gets applied before even the first chain damage is dealth and they both end up doing 60% less. What am I doing wrong here that's causing this? Thanks.
JASS:
library chainOfDeath requires AbilityEvent, libMisc, libSetup {
private function removeAbil() {
UnitRemoveAbilityBJ( 'AGnd', GetEnumUnit() );
}
private function vA() {
timer t = GetExpiredTimer();
UnitHandle uh = GetTimerData(t);
UnitRemoveAbility(uh.u, ID_BUFF_GROUNDED);
ForGroupBJ( GetUnitsInRectAll(GetEntireMapRect()), function removeAbil);
uh.destroy();
ReleaseTimer(t);
}
private function eA() {
timer t = GetExpiredTimer();
UnitHandle uh = GetTimerData(t);
UnitRemoveAbility(uh.u, ID_ABILITY_GND_BUFFPLACER);
UnitRemoveAbility(uh.u, ID_BUFF_GROUNDED);
ForGroupBJ( GetUnitsInRectAll(GetEntireMapRect()), function removeAbil);
uh.destroy();
ReleaseTimer(t);
}
private function OnChainEffect() {
unit uT = GetSpellTargetUnit();
boolean b;
xedamage dmg;
BJDebugMsg( "yesMain" );
GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(uT), GetUnitY(uT), 256., null);
for(ENUM_UNIT = EnumGroupInit(); EnumGroupCheck(); ENUM_UNIT = EnumGroupEnd()) {
if (IsHuman(ENUM_UNIT)) {
if (GetUnitAbilityLevel(ENUM_UNIT, ID_BUFF_GROUNDED) > 0) {
SetUnitAbilityLevel(ENUM_UNIT, ID_BUFF_GROUNDED , 0 );
BJDebugMsg( "yes" );
UnitAddAbility(ENUM_UNIT, ID_ABILITY_GROUNDED);
UnitMakeAbilityPermanent(ENUM_UNIT, true, ID_ABILITY_GROUNDED);
TimerStart(NewTimerEx(UnitHandle.create(ENUM_UNIT)), 2.5, false, function vA);
}
else if (GetUnitAbilityLevel(ENUM_UNIT, ID_BUFF_GROUNDED) == 0) {
BJDebugMsg( "yes2" );
UnitAddAbility(ENUM_UNIT, ID_ABILITY_GND_BUFFPLACER);
UnitMakeAbilityPermanent(ENUM_UNIT, true, ID_ABILITY_GND_BUFFPLACER);
TimerStart(NewTimerEx(UnitHandle.create(ENUM_UNIT)), 8, false, function eA);
}
}
else if (GetUnitTypeId(ENUM_UNIT) == ID_ENGINEER) {
b = false;
GroupEnumUnitsInRange(ENUM_GROUP2, GetUnitX(ENUM_UNIT), GetUnitY(ENUM_UNIT), 256., null);
for(ENUM_UNIT2 = EnumGroupInit2(); EnumGroupCheck2(); ENUM_UNIT2 = EnumGroupEnd2()) {
if (IsWall(ENUM_UNIT2) && GetOwningPlayer(ENUM_UNIT2) != GetOwningPlayer(ENUM_UNIT)) {
b = true;
}
}
if (b) {
dmg = xedamage.create();
dmg.damageTargetForceValue(GetSpellAbilityUnit(), ENUM_UNIT, 2000); // increased from 1000 to insta kill engineers
dmg.destroy();
}
}
}
uT = null;
}
private function onInit() {
AddAbilityEffectEvent(ID_ABILITY_CHAIN, OnChainEffect);
}
}