Crazy_Dead
New Member
- Reaction score
- 24
My spell, which has been 54(53) posts about arguing between me and Berb( Thehive ), and now i got this compiling, and It works. ONCE .
And this makes me kinda angry, because of that simple fact, i want to make it.
Code, please look at it, and find the problem. Appreciate. Very much.
EDIT: Just wanted to tell ya, that im kinda proud of this.
Thanks.
//Crazy_Dead :thup:
And this makes me kinda angry, because of that simple fact, i want to make it.
Code, please look at it, and find the problem. Appreciate. Very much.
JASS:
library StrengthAura initializer Init
globals
// CLOSE_RANGE_BONUS = How much strength you get when in Close Range
private constant integer CLOSE_RANGE_BONUS = 15
// MEDIUM_RANGE_BONUS = How much strength you get when in Medium Range
private constant integer MEDIUM_RANGE_BONUS = 10
// LONG_RANGE_BONUS = How much strength you get when in Long Range
private constant integer LONG_RANGE_BONUS = 5
// CLOSE_RANGE = Indicates how long Close Range is.
private constant real CLOSE_RANGE = 200
// MEDIUM_RANGE = Indicates how long Medium Range is.
private constant real MEDIUM_RANGE = 400
// LONG_RANGE = Indicates how long Long Range is.
private constant real LONG_RANGE = 600
// FULL_STR = Should it Include Bonuses from strength gain??
private constant boolean FULL_STR = TRUE
// SPELL_ID = ...
private constant integer SPELL_ID = 039;A00I039;
// BUFF_ID = ...
private constant integer BUFF_ID = 039;B00C039;
// TIMERTICK = Every X seconds ticks, checking and adding strength.
private constant real TIMERTICK = .05
//Dont Touch. Just dont do it.
//=========================================================|
/* */real globX //=|
/* */real globY //=|
/* */group tmpGrp = CreateGroup() //=|
/* */unit picked //=|
/* */unit Owner //=|
/* */timer ti //=|
/* */private hashtable table = InitHashtable() //=|
/* */unit array HeroWithAura //=|
/* */integer HeroWithAuraCount = 0 //=|
//=========================================================|
endglobals
private constant function TYPES takes nothing returns boolean
return IsUnitType(picked, UNIT_TYPE_HERO) and not /*
*/ IsUnitType(picked, UNIT_TYPE_ANCIENT) and not/*
*/ IsUnitType(picked, UNIT_TYPE_ETHEREAL) and not/*
*/ IsUnitType(picked, UNIT_TYPE_MAGIC_IMMUNE) and not/*
*/ IsUnitType(picked, UNIT_TYPE_SUMMONED) and/*
*/ IsUnitInGroup(picked, tmpGrp)
endfunction
//==================================================================================================================
private struct Data
public real x
public real y
public real range
public real xx
public real yy
public real r
public unit Enum
private method ApplyBonus takes unit u, integer bonus returns nothing
if HaveSavedInteger(table, GetHandleId(u), 1) then
call SetHeroStr(u, GetHeroStr(u, true)-LoadInteger(table, GetHandleId(u), 1), false)
if bonus == 0 then
call RemoveSavedInteger(table, GetHandleId(u), 1)
else
call SaveInteger(table, GetHandleId(u), 1, bonus)
endif
else
if bonus != 0 then
call SaveInteger(table, GetHandleId(u), 1, bonus)
endif
endif
call SetHeroStr(u, GetHeroStr(u, true)+bonus, false)
endmethod
private method GetUnitAuraBonus takes unit u returns integer
local integer i = 0
local integer m = 0
loop
exitwhen i == HeroWithAuraCount
if IsUnitInRange(u, HeroWithAura<i>, LONG_RANGE) then
if IsUnitInRange(u, HeroWithAura<i>, CLOSE_RANGE) then
if CLOSE_RANGE_BONUS > m then
debug call BJDebugMsg(" Mission 3: Dummy Msg ")
set m = CLOSE_RANGE_BONUS
endif
elseif IsUnitInRange(u, HeroWithAura<i>, MEDIUM_RANGE) then
if MEDIUM_RANGE_BONUS > m then
set m = MEDIUM_RANGE_BONUS
debug call BJDebugMsg(" Mission 3: Dummy Msg1 ")
endif
else
if LONG_RANGE_BONUS > m then
set m = LONG_RANGE_BONUS
debug call BJDebugMsg(" Mission 3: Dummy Msg2 \n\n\n\n\n\n LOL")
endif
endif
endif
set i = i + 1
endloop
return 0
endmethod
public static method loopFuncEnum takes nothing returns nothing
local thistype this = allocate()
call BJDebugMsg(" Mission 2: ApplyBonus ")
set Enum = GetEnumUnit()
call ApplyBonus(Enum, GetUnitAuraBonus(Enum))
endmethod
endstruct
//==================================================================================================================
public function onLearn takes nothing returns nothing
set HeroWithAura[HeroWithAuraCount] = GetLearningUnit()
set HeroWithAuraCount = HeroWithAuraCount + 1
endfunction
//==================================================================================================================
private function hasBuff takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(), BUFF_ID) > 0
// Filter, which picks all units in the range Which has the buff.
endfunction
//==================================================================================================================
private function Conditions takes nothing returns boolean
return GetLearnedSkill() == SPELL_ID
// Gets the Learned Skill.
endfunction
//==================================================================================================================
private function doLoop takes nothing returns nothing
call ForGroup(tmpGrp, function Data.loopFuncEnum)
call GroupEnumUnitsInRect(tmpGrp, GetWorldBounds(), Filter(function hasBuff))
call BJDebugMsg(" Completed Mission 1: GroupEnum" )
call ForGroup(tmpGrp, function Data.loopFuncEnum)
endfunction
//==================================================================================================================
//==================================================================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
set ti = CreateTimer()
call TimerStart( ti , TIMERTICK , true , function doLoop )
//==========================================================
set t = CreateTrigger()
loop
exitwhen i == 16
call TriggerRegisterPlayerUnitEvent( t , Player(i) , EVENT_PLAYER_HERO_SKILL , null )
set i = i + 1
endloop
call TriggerAddCondition( t , Condition(function Conditions ))
call TriggerAddAction( t , function onLearn )
//===========================================================
endfunction
//==================================================================================================================
//==================================================================================================================
endlibrary</i></i></i>
EDIT: Just wanted to tell ya, that im kinda proud of this.
Thanks.
//Crazy_Dead :thup: