System Synergistic Energy eXchange

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Synergistic Energy eXchange

JASS:
library SEX requires AIDS
// SEX
// Synergistic Energy eXchange
// 'v'one.oh-nein //
// When a unit comes within range of another unit, their hp and mana will balance out.
// If the unit they ran into has a lower maximum health and/or mana, it will still try to balance.
// Permanent!
//
//
//                *Credits*
//                     Jesus5Lyf
//              Romeh
//                     Renend
//              Flarz
//                     Foop
//              Ken!
    globals
        private constant real RANGE = 200
            //Range for proc.
        private constant integer PROCCHANCE = 10000
            //Higher = Greater Chance, up to 10000.
        private group g = CreateGroup()
    endglobals
    
    private function FailSafe takes nothing returns boolean
        return true
    endfunction
    
    private function Shares takes nothing returns boolean
        local unit u
        local unit q
        local unit z = GetTriggerUnit()
        local real hp = 0
        local real mana = 0
        local real dist1 = 0
        local real dist2 = 0
        local real xz = GetUnitX(z)
        local real xq
        local real yz = GetUnitY(z)
        local real yq
        
        call GroupEnumUnitsInRange(g,GetUnitX(z),GetUnitY(z),RANGE,Condition(function FailSafe))
        
        loop
        exitwhen FirstOfGroup(g) == null
            set q = FirstOfGroup(g)
            set xq = GetUnitX(q)
            set yq = GetUnitY(q)
            set dist2 = ((xz-xq)*(xz-xq))+((yz-yq)*(yz-yq))
            if dist1 == 0 or dist1 < dist2 then
                set dist1 = dist2
                set u = q
            endif
            call GroupRemoveUnit(g,q)
        endloop
        if GetRandomInt(1,10000) <= PROCCHANCE then
            set hp = GetWidgetLife(z) + GetWidgetLife(u)
            set mana = GetUnitState(z,UNIT_STATE_MANA) + GetUnitState(u,UNIT_STATE_MANA)
            call SetWidgetLife(z,hp/2)
            call SetUnitState(z,UNIT_STATE_MANA,mana/2)
            call SetWidgetLife(u,hp/2)
            call SetUnitState(u,UNIT_STATE_MANA,mana/2)
        endif
        set u = null
        set q = null
        set z = null
        return false
    endfunction
    
    private struct Spawnings extends array
        //! runtextmacro AIDS()
        private trigger trig
        
        private static method AIDS_filter takes unit u returns boolean
            return GetUnitAbilityLevel(u,'Aloc') == 0
        endmethod
        
        private method AIDS_onCreate takes nothing returns nothing
            set this.trig = CreateTrigger()
            call TriggerAddCondition(this.trig,Condition(function Shares))
            call TriggerRegisterUnitInRange(this.trig,this.unit,RANGE,Condition(function FailSafe))
        endmethod
        private method AIDS_onDestroy takes nothing returns nothing
            call DestroyTrigger(this.trig)
        endmethod
    endstruct
endlibrary


This is a system I spent all day (with large breaks) completing and ironing out all the bugs. Hope you enjoy my SEX system, it requires AIDS.

It gives all units on your map the chance to even out their life, great when near high-HP buildings, but can damage them. Can work for or against you.
 

Attachments

  • SEX.w3m
    24.6 KB · Views: 187

BlackRose

Forum User
Reaction score
239
What is up with people making systems like this :D? I like it :D

If a unit moves out of range? Will the HP return back to normal?
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
No, it's a perm thing. Low chance of it happening though. I could probably make it reset, and actually make use of AIDS.
 

RaiJin

New Member
Reaction score
40
i lol'd so bad

Library SEX requires AIDS

LOOOOOOOOOOOOOOOOL

sorry but that waas halrious xD i juts died of laughter

anyhow :thup: going to look at it now
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
'v'one.oh-cix released, won't proc for locusts.

and

'v'one.oh-sVen

Global group
 

Kenny

Back for now.
Reaction score
202
1. Add a local unit for GetTriggerUnit(), you use it like 10 times.

2. Use a global group, maybe?

3. Couldn't you just use the regular FirstOfGroup() loop for the loop you do? Example:

JASS:
loop
    set u = FirstOfGroup(Group)
    exitwhen u == null
    call GroupRemoveUnit(Group,u)
    // Do stuff here.
endloop


4. You could get rid of the SquareRoot() function, as you are only comparing distances.

5. This:

JASS:
set u = FirstOfGroup(g)


Could be:

JASS:
set u = q


6. This:

JASS:
if GetRandomInt(1,10000) <= PROCCHANCE then


Can you just use the standard (0,100) or (0.00,1.00) format?

7. You could also set GetUnitX(GetTriggerUnit()) and GetUnitY(GetTriggerUnit()) to locals as well if you wish.

Besides all that, this is pretty cool, and a nice example of how AIDS can make things so friggin' simple!

Nice work. :D
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
1. Add a local unit for GetTriggerUnit(), you use it like 10 times.
No, purposely avoided that.
2. Use a global group, maybe?
07 added that
3. Couldn't you just use the regular FirstOfGroup() loop for the loop you do? Example:

JASS:

loop
    set u = FirstOfGroup(Group)
    exitwhen u == null
    call GroupRemoveUnit(Group,u)
    // Do stuff here.
endloop
AIDS is weird, and so is my code. Trust me, I tried that stuff.
4. You could get rid of the SquareRoot() function, as you are only comparing distances.
Thats how wc3 got dist between points. o_O
5. This:

JASS:

set u = FirstOfGroup(g)


Could be:

JASS:

set u = q
No! It bugs.
6. This:

JASS:

if GetRandomInt(1,10000) <= PROCCHANCE then


Can you just use the standard (0,100) or (0.00,1.00) format?
I'm fond of giant numbers, tis not hurting anyone :D
7. You could also set GetUnitX(GetTriggerUnit()) and GetUnitY(GetTriggerUnit()) to locals as well if you wish.
Heh, I like my 50' horizontal lines.
Besides all that, this is pretty cool, and a nice example of how AIDS can make things so friggin' simple!

Nice work. :D
Yay AIDS.
 

Kenny

Back for now.
Reaction score
202
No, purposely avoided that.

Wait what? You purposely avoided optimising your script? Am I missing something here?

Thats how wc3 got dist between points. o_O

Yes, but SquareRoot() is slow as, and comparing distances can be done without it, as it will still compare the biggest to smallest and what-not.

For example:

A distance of 100 will become 100 * 100 = 10,000.
A distance of 80 will become 80 * 80 = 6,400.

10,000 is still greater than 6,400. Therefore SquareRoot() is just overdoing it.

No! It bugs.

It shouldn't. It's probably due to how you wrote it maybe.

Heh, I like my 50' horizontal lines.

For the sake of optimisation, I say crack that 50 line limit you have.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
'v'one.oh-ate
Didn't optimize the getunitx and such, but make triggerunit a local. Removed sq root.
 

Romek

Super Moderator
Reaction score
964
Make the x/y's locals.
Also, all the Get/SetUnitState(..., UNIT_STATE_LIFE) should be Get/SetWidgetLife(..).
Faster. =)

I thought you were taking the piss when making this. ¬_¬
Why would someone want something like this?

I think this'd be better off as a spell or something.
 

Jesus4Lyf

Good Idea™
Reaction score
397

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Version 9 released. Necessary changes made, I hope.
 

Romek

Super Moderator
Reaction score
964
GY'd.
This isn't anything except the name, and I'm sure you know what.

(It should be SEE by the way)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top