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
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      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