System Aggro System

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Version 1.0, everything is in the Read Me.

Pictures:


AggroSystem.jpg


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
 

elmstfreddie

The Finglonger
Reaction score
203
I don't see why anyone would want this, because it's part of strategy to get another unit to just attack once and lure the creep away from a weak ally. If the weak ally did most of the damage with your system, he couldn't escape.
I like Warcraft's default system o_O
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
The creeps in default WC3 tend to stick on one unit, this system makes the targets of creeps change faster, depending on the damage they deal.
 

waaaks!

Zinctified
Reaction score
256
i really dont know how to make systems, im impressed
+rep but i cant.. sorry, maybe next time...
 

Steel

Software Engineer
Reaction score
109
I recommend making an addition of a few constants that will be spells that increase or decrease as unit's threat/agro.
 

Matemeo

New Member
Reaction score
20
Perfect, just what I've been looking for, though, I'll have to modify to add in spells that lower and increase aggro, but this is a great base, + REP, goodjob.
 
S

schilling

Guest
i want to test this jass thingy, but when i add it my world editor map, but when i'm off to save the world editor shuts down :confused:

anyways, the jass looks very very cool:)
 

Deadeyeflint

New Member
Reaction score
0
could someone tell me how to add spells that incrase/decrase aggro to this trigger, or just give me some funktions to copy? ^^
i'm trying to use JASS2 since yesterday, and that would just be too difficult to me. :(
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
You could scope/library the whole lot, making the handle functions private...

If you leave it like that, people with handle var functions elsewhere in their map will get double function errors.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Not he don't have, he is not using it.
It is tend to be easy to implent by newbies that uses normal editor.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top