Attachment System Challenge - KillCounter

Trollvottel

never aging title
Reaction score
262
no system, but a quite different version:
(didnt test it and now that many people dont like gamecache):

JASS:
library KillCount initializer Init

    globals
        private gamecache CACHE
    endglobals

    private function U2I takes unit u returns integer
        return u
        return 0
    endfunction
    
    public function Get takes unit u returns integer
        return GetStoredInteger(CACHE, "kills", I2S(U2I(u)))
    endfunction
    
    private function Action takes nothing returns nothing
        local unit die      = GetTriggerUnit()
        local unit kill     = GetKillingUnit()
        local integer id1   = U2I(die)
        local integer id2   = U2I(kill)
        call StoreInteger(CACHE, "kills", I2S(id2), GetStoredInteger(CACHE, "kills", I2S(id2)+1))
        
        if IsUnitType(die, UNIT_TYPE_HERO) != true then
            call StoreInteger(CACHE, "kills", I2S(id1), 0)
        endif
        
    endfunction
    
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerUnitEvent(t, GetLocalPlayer(), EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddAction(t, function Action)
        call InitGameCache("CACHE")
    endfunction
    


endlibrary
 

Cohadar

master of fugue
Reaction score
209
It leaks and it does not even compile...

I am still waiting for someone to use some actual system....
 

Trollvottel

never aging title
Reaction score
262
oh right, that was silly to not even test if there were syntax errors, an update (still none of the systems :rolleyes:, i dont even know WHY you want us to use these systems...):

JASS:
library KillCount initializer Init

    globals
        private gamecache CACHE
    endglobals

    private function U2I takes unit u returns integer
        return u
        return 0
    endfunction
    
    public function Get takes unit u returns integer
        return GetStoredInteger(CACHE, "kills", I2S(U2I(u)))
    endfunction
    
    private function Action takes nothing returns nothing
        local unit die      = GetTriggerUnit()
        local unit kill     = GetKillingUnit()
        local integer id1   = U2I(die)
        local integer id2   = U2I(kill)
        local integer kills = GetStoredInteger(CACHE, "kills", I2S(id2))
        
        if kills != 0 and not (kills > 0) then
            set kills = 0
        endif
        
        call StoreInteger(CACHE, "kills", I2S(id2), kills+1)
        
        if IsUnitType(die, UNIT_TYPE_HERO) != true then
            call StoreInteger(CACHE, "kills", I2S(id1), 0)
        endif
        set die = null
        set kill = null
    endfunction
    
    private function True takes nothing returns boolean
        return true
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerUnitEvent(t, GetLocalPlayer(), EVENT_PLAYER_UNIT_DEATH, Condition(function True))
        call TriggerAddAction(t, function Action)
        call InitGameCache("CACHE")
    endfunction
    


endlibrary
 

Trollvottel

never aging title
Reaction score
262
i didnt.

@adamgriffith:

this is to get the unit's kills... i dont use it in the system, but you see its public ....
 

Cohadar

master of fugue
Reaction score
209
(still none of the systems :rolleyes:, i dont even know WHY you want us to use these systems...):

So you would not have to write all this big ugly codes every time you need to attach something to unit.
(and to prove that some of those systems can't really be used for unit attaching no matter what their authors claim)
 
Reaction score
333
I have given this some more thought, and think this constitutes a better solution (not thoroughly tested):

JASS:
library KillCount initializer Init
    globals
        private integer array Data
        private group G = CreateGroup()
    endglobals
    
    private function H2I takes handle h returns integer
        return h
        return 0
    endfunction
    
    private function GetHandleData takes handle h returns integer
        return Data[H2I(h)-0x100000]
    endfunction
    
    private function SetHandleData takes handle h, integer i returns nothing
        set Data[H2I(h)-0x100000] = i
    endfunction
    
    private function UnitDies takes nothing returns boolean
        local unit u = GetKillingUnit()
        local unit v = GetTriggerUnit()
        
        if (u != null and u != v) then
            if IsUnitInGroup(u, G) then
                call SetHandleData(u, GetHandleData(u)+1)
            else
                call GroupAddUnit(G, u)
                call SetHandleData(u, 1)
            endif
        endif
        
        set u = null
        set v = null
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(t, Condition(function UnitDies))
    endfunction
endlibrary


Once again the attachment system is part of the library, but it is practically identical to CSData, etc.
 

Viikuna

No Marlo no game.
Reaction score
265
Why should anyone attach anything to units? Just use SetunitUserData and give unit a unique index. You can have your data in struct arrays, just use GetUnitUserData to find witch struct belongs to that unit. If unit dies, just recycle it. Move it to some storage area and ressurect it there. If it cant be ressurected, just create a new unit for that index. When you need units for something just grab them from storage area.

Or use PUI. if Im not mistaken, it recycles indexes instead of units.

Anyways, when unit dies take killing units struct from array and save whatever data you need to it.

EDIT. Is there any relation beetween this thread and this ?
 
Reaction score
333
Custom unit data is the best way to do this. I can't think how using PUI would make this any easier - you still run into the same problems.
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Maybe lol. Also cohadar stated not to use Custom Values so this is indeed quite a challenge.
@TheDamien: yes and cohadar also stated not to use custom values, PUI uses it doesn't it?
 

Viikuna

No Marlo no game.
Reaction score
265
No custom value ideed makes it hard, but when you really have a situation where you cant use custom value? This sounds like 'make a knockback without timer..' I think Cohadar himself said that units dont need attaching but indexing.

Must download some attachment system and try this..
 
Reaction score
333
@TheDamien: yes and cohadar also stated not to use custom values, PUI uses it doesn't it?

The idea behind this thread, though, was to prove that we're all n00bs for thinking that unit attachment is just as usable as PUI.
 

Viikuna

No Marlo no game.
Reaction score
265
I would not be suprised..
Lets see what Cohadar says when he gets back here.
 

Cohadar

master of fugue
Reaction score
209
Viikuna said:
Is there any relation beetween this thread and this ?
Everything in universe is connected (or at least on internet)

TheDamien said:
Once again the attachment system is part of the library, but it is practically identical to CSData, etc.
Can you please make it use CSData I would like to see that solution.

Flare said:
OK, I've run into some bother doing it with HAIL. What has worked before (in my own spells) no longer works... time to try and find a fix :D
It never worked properly, you just did not notice it in game.

chobibo said:
Maybe lol. Also cohadar stated not to use Custom Values so this is indeed quite a challenge.
@TheDamien: yes and cohadar also stated not to use custom values, PUI uses it doesn't it?
I have a proper solution for this that uses PUI that will be published after challenge is over.
Read the rules again please.

TheDamien said:
The idea behind this thread, though, was to prove that we're all n00bs for thinking that unit attachment is just as usable as PUI.
Think of it as free education.
 

Flare

Stops copies me!
Reaction score
662
It never worked properly, you just did not notice it in game.

If that was the case, my spell would be total and utter fail (don't say it is fail, because it isn't. I have tested the attachment with debug messages :D). It has stopped my spells from stacking :D

Think of it as free education.

lol, I was expecting something far more Cohadar-y (i.e. all those other systems fail but PUI doesn't [mwuahahahahahahahahahahah])

I have a proper solution for this that uses PUI that will be published after challenge is over.
Read the rules again please.

Oh joy, we have to conform to the rules, yet you don't -.-'
 

chobibo

Level 1 Crypt Lord
Reaction score
48
2. Monopolizing UnitUserData is not allowed.
I didn't see the monopolizing part sorry.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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!
  • 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

      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