Larcenist
REP: Respect, Envy, Prosperity?
- Reaction score
- 211
Solved!
The main purpose is to work as a system that manipulates experience gained based on some factors. Regular exp gain and the killing blow bonus works just fine, though the denying part does not trigger.
This is the part that doesn't work as planned:
Even if the killing unit is an ally of the dying unit the then actions does not fire.
Edit: Solved, it was working all the time though only noticable when an enemy hero was withing exp range.
JASS:
library Experience requires Shared
globals
private constant integer ForestMeleeCreep1 = 039;e003039;
private constant integer ForestRangeCreep1 = 039;e004039;
private constant integer ForestMeleeCreep2 = 039;e000039;
private constant integer ForestRangeCreep2 = 039;e002039;
private constant integer ForestTower1 = 039;etrp039;
private constant integer ForestTower2 = 039;e011039;
private constant integer ForestTower3 = 039;e00M039;
private constant integer AncientOfWar = 039;e00N039;
private constant integer GlaiveThrower = 039;e00O039;
private constant integer DoomMeleeCreep1 = 039;u002039;
private constant integer DoomRangeCreep1 = 039;u003039;
private constant integer DoomMeleeCreep2 = 039;u000039;
private constant integer DoomRangeCreep2 = 039;u001039;
private constant integer DoomTower1 = 039;uzg1039;
private constant integer DoomTower2 = 039;u00D039;
private constant integer DoomTower3 = 039;u00O039;
private constant integer Crypt = 039;u00P039;
private constant integer MeatWagon = 039;u00Q039;
//Experience rate setup
private constant real MeleeCreep1BaseExp = 25.
private constant real RangeCreep1BaseExp = 40.
private constant real MeleeCreep2BaseExp = 40.
private constant real RangeCreep2BaseExp = 55.
private constant real Tower1BaseExp = 125.
private constant real Tower2BaseExp = 200.
private constant real Tower3BaseExp = 300.
private constant real CryptAncientBaseExp = 175.
private constant real CatapultBaseExp = 500.
private constant real ExpAoE = 750.
private constant real KillBlowExpRate = 1.2
private constant real DenyExpRate = 0.25
//Can be changed with -em and similar for increased exp gain.
public real Rate = 1.
endglobals
public function Gain takes unit k, unit d returns nothing
local group UG = CreateGroup()
local unit FLoop
local real NettoExpGain
if GetUnitTypeId(d) == ForestMeleeCreep1 or GetUnitTypeId(d) == DoomMeleeCreep1 then
set NettoExpGain = MeleeCreep1BaseExp
elseif GetUnitTypeId(d) == ForestRangeCreep1 or GetUnitTypeId(d) == DoomRangeCreep1 then
set NettoExpGain = RangeCreep1BaseExp
elseif GetUnitTypeId(d) == ForestMeleeCreep2 or GetUnitTypeId(d) == DoomMeleeCreep2 then
set NettoExpGain = MeleeCreep2BaseExp
elseif GetUnitTypeId(d) == ForestRangeCreep2 or GetUnitTypeId(d) == DoomRangeCreep2 then
set NettoExpGain = RangeCreep2BaseExp
elseif GetUnitTypeId(d) == ForestTower1 or GetUnitTypeId(d) == DoomTower1 then
set NettoExpGain = Tower1BaseExp
elseif GetUnitTypeId(d) == ForestTower2 or GetUnitTypeId(d) == DoomTower2 then
set NettoExpGain = Tower2BaseExp
elseif GetUnitTypeId(d) == ForestTower3 or GetUnitTypeId(d) == DoomTower3 then
set NettoExpGain = Tower3BaseExp
elseif GetUnitTypeId(d) == AncientOfWar or GetUnitTypeId(d) == Crypt then
set NettoExpGain = CryptAncientBaseExp
elseif GetUnitTypeId(d) == GlaiveThrower or GetUnitTypeId(d) == MeatWagon then
set NettoExpGain = CatapultBaseExp
endif
call GroupEnumUnitsInRange(UG, GetUnitX(d), GetUnitY(d), ExpAoE, Condition(function True))
loop
set FLoop = FirstOfGroup(UG)
exitwhen FLoop == null
if IsUnitEnemy(FLoop, GetOwningPlayer(d)) == true and GetWidgetLife(FLoop) > .405 and IsUnitType(FLoop, UNIT_TYPE_HERO) == true then
if IsUnitAlly(k, GetOwningPlayer(d)) == true then
call AddHeroXP(FLoop, R2I(NettoExpGain * DenyExpRate * Rate + 0.5), true)
call BJDebugMsg("Test")
else
if FLoop == k then
call AddHeroXP(FLoop, R2I(NettoExpGain * KillBlowExpRate * Rate + 0.5), true)
else
call AddHeroXP(FLoop, R2I(NettoExpGain * Rate + 0.5), true)
endif
endif
endif
call GroupRemoveUnit(UG, FLoop)
endloop
call DestroyGroup(UG)
set UG = null
endfunction
endlibrary
The main purpose is to work as a system that manipulates experience gained based on some factors. Regular exp gain and the killing blow bonus works just fine, though the denying part does not trigger.
This is the part that doesn't work as planned:
JASS:
if IsUnitAlly(k, GetOwningPlayer(d)) == true then
call AddHeroXP(FLoop, R2I(NettoExpGain * DenyExpRate * Rate + 0.5), true)
call BJDebugMsg("Test")
else
if FLoop == k then
call AddHeroXP(FLoop, R2I(NettoExpGain * KillBlowExpRate * Rate + 0.5), true)
else
call AddHeroXP(FLoop, R2I(NettoExpGain * Rate + 0.5), true)
endif
endif
Even if the killing unit is an ally of the dying unit the then actions does not fire.
Edit: Solved, it was working all the time though only noticable when an enemy hero was withing exp range.