Rheias
New Helper (I got over 2000 posts)
- Reaction score
- 232
Version 1.0, everything is in the Read Me.
Pictures:
Read Me:
Code:
Pictures:
Read Me:
Code:
===================================================================================================
Foreword:
This is a simple system that helps importing a simple, yet effecting feature into your map. What the
system will allow basically is making certain units effected by the damage dealt to them. Those
units (which will be chosen by you by modifing the trigger) will attack the unit the dealt the most
damage to them in range of 30 (this value is editable as well), this will allow realistic play and
more stratigic play, especially in RPGs, ORPGs, AoSes, Hero Sieges and so on.
You should note though that the system is a little slow becuase it uses H2I function alot. The H2I
allows us to refer to a single unit with an ease by attaching an integer to it.
Credits to KaTTaNa for the local handle system, parts of it are used.
===================================================================================================
Import:
Inorder to import this system all you have to do is to copy the trigger, done. If you have KaTTaNa
handle system imported into your map already, don't copy the upper part of the system, only the part
from " // AGGRO SYSTEM -- BY RHEIAS \\ " and down.
===================================================================================================
History:
Version 1 (June,14,2007)
- First release.
===================================================================================================
I would love to hear comments, suggestions and bugs found, just post them in the thread made!
Rheias
Code:
JASS:
// LOCAL HANDLE SYSTEM == BY KaTTaNa \\
function H2I takes handle h returns integer
return h
return 0
endfunction
function LocalVars takes nothing returns gamecache
if udg_AS_Cache == null then
set udg_AS_Cache = InitGameCache("jasslocalvars.w3v")
endif
return udg_AS_Cache
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
// AGGRO SYSTEM -- BY RHEIAS \\
constant function AggroSys_Range takes nothing returns real
// Returns by how much the new damage needs to be bigger then the last maximum damage.
return 30.
endfunction
constant function AggroSys_Cool takes nothing returns real
// Returns by how much the max value is reduces every second
return 5.
endfunction
function AggroSysGrp_Cons takes nothing returns boolean
// Returns the condition for the units pre-placed that will fit in the system.
return GetPlayerController(GetOwningPlayer(GetFilterUnit()))!=MAP_CONTROL_USER or GetPlayerSlotState(GetOwningPlayer(GetFilterUnit()))!=PLAYER_SLOT_STATE_PLAYING
// At the moment it is every unit that is not controlled by a user or that it's controller is not in-game
endfunction
function AggroSysTrg_Cons takes nothing returns boolean
// Returns the condition for the unit that are created in-game that will fit the system.
return GetPlayerController(GetOwningPlayer(GetTriggerUnit()))!=MAP_CONTROL_USER or GetPlayerSlotState(GetOwningPlayer(GetTriggerUnit()))!=PLAYER_SLOT_STATE_PLAYING
// At the moment it is every unit that is not controlled by a user or that it's controller is not in-game
endfunction
function AggroSysCool_Acts takes nothing returns boolean
local group victims = CreateGroup()
local boolexpr con = Condition(function AggroSysGrp_Cons)
local unit picked
local real max
call GroupEnumUnitsInRect(victims,GetWorldBounds(),con)
loop
set picked = FirstOfGroup(victims)
exitwhen picked == null
set max = GetHandleReal(picked,"max") - AggroSys_Cool()
call SetHandleReal(picked,"max",max)
call GroupRemoveUnit(victims,picked)
endloop
set victims = null
set picked = null
return true
endfunction
function AggroSysPre_Acts takes nothing returns boolean
local group victims = CreateGroup()
local boolexpr con = Condition(function AggroSysGrp_Cons)
local unit picked
call GroupEnumUnitsInRect(victims,GetWorldBounds(),con)
loop
set picked = FirstOfGroup(victims)
exitwhen picked == null
call TriggerRegisterUnitEvent(gg_trg_AggroSys,picked,EVENT_UNIT_DAMAGED)
call GroupRemoveUnit(victims,picked)
endloop
call DestroyGroup(victims)
set victims = null
set picked = null
return true
endfunction
function AggroSysDmg_Acts takes nothing returns boolean
local unit triggerer = GetTriggerUnit()
if AggroSysTrg_Cons() then
call TriggerRegisterUnitEvent(gg_trg_AggroSys,triggerer,EVENT_UNIT_DAMAGED)
endif
set triggerer = null
return true
endfunction
function AggroSysExe_Acts takes nothing returns boolean
local unit source = GetEventDamageSource()
local unit victim = GetTriggerUnit()
local real max = GetHandleReal(victim,"max")
local real damage = GetHandleReal(victim,I2S(H2I(source))) + GetEventDamage()
call SetHandleReal(victim,I2S(H2I(source)),damage)
if damage > max + AggroSys_Range() then
call SetHandleReal(victim,"max",damage)
call IssueTargetOrder(victim,"attack",source)
endif
set source = null
set victim = null
return true
endfunction
//===========================================================================
function InitTrig_AggroSys takes nothing returns nothing
local trigger AggroSysDmg = CreateTrigger()
local trigger AggroSysPre = CreateTrigger()
local trigger AggroSysCool = CreateTrigger()
set gg_trg_AggroSys = CreateTrigger()
call TriggerRegisterTimerEventSingle(AggroSysPre,0.)
call TriggerRegisterEnterRectSimple(AggroSysDmg,GetWorldBounds())
call TriggerAddCondition(gg_trg_AggroSys,Condition(function AggroSysExe_Acts))
call TriggerAddCondition(AggroSysDmg,Condition(function AggroSysDmg_Acts))
call TriggerAddCondition(AggroSysPre,Condition(function AggroSysPre_Acts))
call TriggerAddCondition(AggroSysCool,Condition(function AggroSysCool_Acts))
set AggroSysDmg = null
set AggroSysPre = null
set AggroSysCool = null
endfunction