Perfect IsUnitAlive

Viikuna

No Marlo no game.
Reaction score
265
Getting the manacost of abilities is no problem actually.
Since those are static values, you can just build some database to get those values.


But some natives for manipulating manacost and cooldown would indeed be nice...
 

Rushhour

New Member
Reaction score
46
yep that can be done ofc, but when you keep changing the values to balance things out.. then it gets stupid. You can also have some "system" like checking the manaamount at spellbegin and checking at spellend but there are some more problems like channeling spells,...
We have to live with what he have ;)
happy mapping

Edit: Found some strange stuff 0o:
Simple testing result in this:
Trigger:
  • Custom script: set udg_SellGold=(3/4)*GetUnitGoldCost(GetUnitTypeId(GetTriggerUnit()))
    • Custom script: call BJDebugMsg(I2S(udg_SellGold))

always results in 0

Trigger:
  • Custom script: set udg_SellGold=GetUnitGoldCost(GetUnitTypeId(GetTriggerUnit()))
    • Custom script: call BJDebugMsg(I2S(udg_SellGold))

displays the correct amount 0o
--> multiplications work well, but as a division like (1/2)* or (3/4)* .. is in front of it, I always get 0. I also tried some R2I(I2R(...)) or simply R2I(..) ! This is... stupid 0o
 

Nestharus

o-o
Reaction score
84
Actually, my guide has a complete list of working natives from common.ai... Chapter 9 Natives

http://www.thehelper.net/forums/showthread.php?t=137090


That list was compiled after testing each and every native in common.ai to see which one's worked and which one's didn't (well, most of them, a lot of it was just logic on my part ^_^).

I used to just have that list for myself, but when I wrote the guide I put it in there. I made that list when I wrote Stock (previously known as Gcsn).
 

Nestharus

o-o
Reaction score
84
I believe the reason for the RemoveUnit bug is that it cleans up memory on an interval, so the memory isn't cleaned up until the end of the interval.

What this means is that if you remove a unit that is alive, it'll still be in memory while your code is running.


Now, to fix this you could make a unit dead whenever you remove a unit by overriding the native with a definition.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Now, to fix this you could make a unit dead whenever you remove a unit by overriding the native with a definition.
You've gotta understand that this is silly. The only situation UnitAlive returns true for a removed unit is straight after removing it. ...
... meaning you know it's not alive, lol. Probably, 0.0 seconds after, you would find it counts as dead. In what situation would this be a problem?
 

Nestharus

o-o
Reaction score
84
>You've gotta understand that this is silly. The only situation UnitAlive returns true for a removed unit is straight after removing it. ...
... meaning you know it's not alive, lol. Probably, 0.0 seconds after, you would find it counts as dead. In what situation would this be a problem?

You might be using a resource that runs on a custom event. You remove a unit and then you run it or w/e and the resource runs whether the unit is alive or dead, so the resource doesn't know what you did.

Here's an example-

JASS:
native UnitAlive takes unit id returns boolean

scope Demo initializer Initialization {
    private unit u
    private trigger t = CreateTrigger()

    private bool Test() {
        if UnitAlive(u) {
            printf("Alive")
        }
        else {
            printf("Dead")
        }
        return false
    }
    
    private void Testing() {
        u = CreateUnit(Player(0), 'hpea', 0, 0, 0)
        RemoveUnit(u)
        TriggerEvaluate(t)
    }
    
    private void Initialization() {
        TriggerAddCondition(t, Condition(function Test))
        TimerStart(CreateTimer(), 2, true, function Testing)
    }
}



Now, I can't even think of something where this might happen, but we all know how some people are ^_-. Where I think something may sound ludicrous, like the above, someone else might think it's the greatest idea ever, lol.

Only possible thing I can think of that encounters a scenario similar to this uses timers, so this bug wouldn't even occur ><.

Example-
JASS:
native UnitAlive takes unit id returns boolean

scope Demo initializer Initialization {
    private unit u
    private trigger t = CreateTrigger()
    private timer repeat = CreateTimer()
    
    private bool Test() {
        if UnitAlive(u) {
            printf(&quot;Alive&quot;)
        }
        else {
            printf(&quot;Dead&quot;)
        }
        return false
    }
    
    private void Testing() {
        u = CreateUnit(Player(0), &#039;hpea&#039;, 0, 0, 0)
        RemoveUnit(u)
        TimerStart(repeat, 0, false, function Test)
    }
    
    private void Initialization() {
        TriggerAddCondition(t, Condition(function Test))
        TimerStart(CreateTimer(), 2, true, function Testing)
    }
}
 

Azlier

Old World Ghost
Reaction score
461

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
JASS:
and do stuff



On another note, how does Jesus get like JASS highlighting without quote box?
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
[ljass] that is cool [/ljass]

Anyway, I guess UnitAlive is pretty good.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
I know that you should always kill destructables before removing them, because else an incoming projectile on a removed destructable would crash - maybe the same applies for units?
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
More research. Get this.

JASS:
call RemoveUnit(RAZELLE)
if GetUnitTypeId(RAZELLE) == 0 or IsUnitType(RAZELLE, UNIT_TYPE_DEAD) then
    call BJDebugMsg(&quot;DEAD&quot;)
endif

Does not display dead.

JASS:
call RemoveUnit(RAZELLE)
if GetWidgetLife(RAZELLE) &lt;= 0.405 then
    call BJDebugMsg(&quot;DEAD&quot;)
endif

Does not display dead.

So, in fact, all the methods share that one flaw of a unit not being dead immediately after removal.

I don't know why this is surprising. Your not technically killing the unit when you remove it.

Makes sense to me.
 

Azlier

Old World Ghost
Reaction score
461
It's dead 0 seconds after the trigger finished running though.
 

Nestharus

o-o
Reaction score
84
Well, RemoveUnit not displaying dead also makes 100% perfect sense to me. GetUnitTypeId with it also makes perfect sense as it's not cleared from memory yet : \.


I explained that-
What this means is that if you remove a unit that is alive, it'll still be in memory while your code is running.

: P

It's dead 0 seconds after the trigger finished running though.

Not really right to say that. It's dead at the end of while loop. Old style games like wc3 generally run on an infinite while loop.

Hell, newer games that are indie still run on infinite while loops, haha. Look at XNA.
 
General chit-chat
Help Users
  • 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