Dirac
22710180
- Reaction score
- 147
As the title says, is that possible? i don't wan't any green text displaying bonus damage next to the base damage, i just want plain damage increase. Non hero units so modifying stats is not an option
Upgrades with more than 4 levels will increase the loading time.
//********************************************************************
//** This file is part of the YouTD engine **
//** copyright by gex @2009,2010 (<a href="http://www.eeve.org" target="_blank" class="link link--external" rel="nofollow ugc noopener">www.eeve.org</a>, <a href="mailto:[email protected]">[email protected]</a>)**
//** **
//** If you use it for other purposes, give proper credit and **
//** leave this copyright box untouched **
//********************************************************************
//Private library used by libUnit to alter unit values
library libPreload uses TimerUtils //You can probably remove this don't forget to remove uses libPreload then and the function used in the script below
function preloadAbil takes integer abil returns nothing
endfunction
endlibrary
library libBonus initializer init uses libPreload
globals
integer array bonusAbils
integer array bonusBasis
constant real BONUS_MULTIPLIER_HP_REGEN = 1.0
constant real BONUS_MULTIPLIER_MANA_REGEN = 10.0 //These values seem wrong, but actually, the regen ability uses wrong values (actually twice as big as shown)
constant integer BONUS_DAMAGE = 0
constant integer BONUS_IAS = 1
constant integer BONUS_MANA = 2
constant integer BONUS_MANA_REG = 3
constant integer BONUS_ARMOR = 4
constant integer BONUS_HP = 5
constant integer BONUS_HP_REGEN = 6
constant integer BONUS_MANA_REGEN = 7
constant integer BONUS_BASE = 25
constant integer REGEN_BONUS_BASE = 100
constant integer BONUS_BASE_DAMAGE = 039;IDMA039;
constant integer BONUS_BASE_DAMAGE_NEG = 039;IDNA039;
constant integer INVENTORY_ABIL = 039;AInv039;
constant integer TOMES_NEG_START = 40
constant integer MAX_BASE_DAMAGE_POSITIVE = 20
constant integer MAX_BASE_DAMAGE_NEGATIVE = 20
item array tomes
endglobals
private function init takes nothing returns nothing
local integer i
set bonusAbils[BONUS_DAMAGE] = 039;Adm5039;
set bonusAbils[BONUS_IAS] = 039;Aas5039;
set bonusAbils[BONUS_MANA] = 039;Ama5039;
set bonusAbils[BONUS_ARMOR] = 039;Aar5039;
set bonusAbils[BONUS_HP] = 039;Ahp7039;
set bonusAbils[BONUS_HP_REGEN] = 039;Reg0039;
set bonusAbils[BONUS_MANA_REGEN] = 039;Mre5039;
set bonusBasis[BONUS_DAMAGE] = BONUS_BASE
set bonusBasis[BONUS_IAS] = BONUS_BASE
set bonusBasis[BONUS_MANA] = BONUS_BASE
set bonusBasis[BONUS_ARMOR] = BONUS_BASE
set bonusBasis[BONUS_HP] = BONUS_BASE
set bonusBasis[BONUS_HP_REGEN] = REGEN_BONUS_BASE
set bonusBasis[BONUS_MANA_REGEN] = REGEN_BONUS_BASE
set i = 0
loop
set tomes<i> = CreateItem(BONUS_BASE_DAMAGE+i,0.0,0.0)
call SetWidgetLife(tomes<i>,0.0)
set i = i + 1
exitwhen i == MAX_BASE_DAMAGE_POSITIVE
endloop
set i = 0
loop
set tomes[TOMES_NEG_START+i] = CreateItem(BONUS_BASE_DAMAGE_NEG+i,0.0,0.0)
call SetWidgetLife(tomes[TOMES_NEG_START+i],0.0)
set i = i + 1
exitwhen i == MAX_BASE_DAMAGE_NEGATIVE
endloop
endfunction
//Alters base damage (tomes...)
function alterBaseDamageInternal takes unit u, integer delta returns nothing
local integer i
local integer amount
local item it
local boolean b = (UnitInventorySize(u) == 0)
if (delta < 0) then
set delta = -delta
set i = TOMES_NEG_START
elseif (delta > 0) then
set i = 0
else
return
endif
if b then
call UnitAddAbility(u,INVENTORY_ABIL)
endif
loop
exitwhen delta == 0
set amount = delta - (delta / 2) * 2 //Modulo 2
if(amount != 0) then
set it = tomes<i>
call SetWidgetLife(it,100.0)
call UnitAddItem(u, it)
call SetItemPosition(it,0.0,0.0)
endif
set delta = delta / 2
set i = i + 1
endloop
if b then
call UnitRemoveAbility(u,INVENTORY_ABIL)
endif
endfunction
private struct BaseDamageModification
unit u
integer delta
public static method create takes unit u, integer delta returns BaseDamageModification
local BaseDamageModification b = BaseDamageModification.allocate()
set b.u = u
set b.delta = delta
return b
endmethod
endstruct
function alterBaseDamageTimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local BaseDamageModification bdm = GetTimerData(t)
call ReleaseTimer(t)
call alterBaseDamageInternal(bdm.u,bdm.delta)
call bdm.destroy()
endfunction
function alterBaseDamage takes unit u, integer delta returns nothing
local timer t
local BaseDamageModification bdm
if (delta == 0) then
return
endif
set t = NewTimer()
set bdm = BaseDamageModification.create(u,delta)
call SetTimerData(t,bdm)
call TimerStart(t,0.0,false,function alterBaseDamageTimer)
endfunction
</i></i></i>