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: 185

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.
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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