Mineral cost of unit?

X-maul

AKA: Demtrod
Reaction score
201
What value is the value loaded by the "Mineral cost of unit" action?
I need it for a "Sell Tower" ability, and it gives the correct value (the value i spent on building it), but when I upgrade it (with a morph ability with a mineral cost) it gives 0 minerals back (even though the cost of the unit it 20?
 

MissKerrigan

Active Member
Reaction score
23
you have to make a value that goes below 'zero'

If you spent 300 on a unit, then make an ability that costs -300
When you upgrade the unit with a morph ability, you have to make a new ability which cost more minerals
 

X-maul

AKA: Demtrod
Reaction score
201
Uhm - Well I already did create the ability and the cost - the problem is that when I call the mineral cost of a unit, it does not give the correct value.
 

Dave312

Censored for your safe viewing
Reaction score
269
That function returns the value specified in the Cost: Cost+ property of the unit. It does not return the actual value spent on upgrading the unit.

What I suggest you do, is specify the actual cost of the upgrade in the Ability: Info+ property (use the sub-property Info - Technology Resource Cost) and also check Ignore Unit Cost in the Stats: Flags + on the morph ability. Then use the Cost: Cost + property on the unit to determine how much the tower will sell for.
 

X-maul

AKA: Demtrod
Reaction score
201
hmm - well I tried to set the mineral cost of the unit to 20 - but it still leaves me with 0?
I might work around this - The units I want to sell are all invulnerable, so I might just set their HP to my cost value and call that value instead.
Even though it still bothers me that I cant figure this outo_O

EDIT: I'm not able to call the amount of HP a unit have?
EDIT 2: I'll post my trigger, so you can see if I did something wrong:
Code:
Sell Tower
    Events
        Unit - Any Unit uses  Sell Tower at Generic6 - Complete stage (Ignore shared abilities)
    Local Variables
    Conditions
    Actions
        Unit - Pause (Triggering unit)
        General - Wait 0.5 Game Time seconds
        Unit - Kill (Triggering unit)
        Player - Modify player (Owner of (Triggering unit)) Minerals: Add ((Minerals cost of (Unit type of (Triggering unit))) / 2)
        Environment - Create a Large Protoss explosion at (Position of (Triggering unit))
        Text Tag - Create a text tag with the text ("+" + ((Text(((Minerals cost of (Unit type of (Triggering unit))) / 2))) + "</c>")) for (Player group((Owner of (Triggering unit)))), using a font size of 24, at (Position of (Triggering unit)) and height offset 1.0, initially Visible, and fog of war enforcement set to False
        Text Tag - Set Duration time for (Last created text tag) to 1.5 seconds
        Text Tag - Set Fade Duration time for (Last created text tag) to 2.0 seconds
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I think the wait is causing problems. I've had problems where the reference to the Triggering Unit is lost when you use waits. Save the triggering unit in a local variable and refer to the local variable instead of the triggering unit. It should work better.

I think that might also be the reason that the mineral cost action didn't work for you.
 

X-maul

AKA: Demtrod
Reaction score
201
hmm - well I will try that, but the trigger works for every unit but not the morphed unit.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Modify the minerals BEFORE you kill the unit, im pretty sure the kill unit function removes the unit and plays a generic death, but if the unit is already gone, you cant use that unit properly as an argument to another function, ie:
Code:
Player - Modify player (Owner of (Triggering unit)) Minerals: Add ((Minerals cost of (Unit type of (Triggering unit))) / 2)
You do this when the triggering unit no longer exists, unless it is like wc3 where the unit exists until it decays.
 

MissKerrigan

Active Member
Reaction score
23
lol what you guys doing all difficould with triggers, just set the 'cost' to -300 and you'll get 300 minerals when use the ability
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
but then he needs to make an ability for every tower and set it correctly with the mineral cost... like this he doesnt need to make all those abilities, just 1 and give it to all the towers
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Modify the minerals BEFORE you kill the unit, im pretty sure the kill unit function removes the unit and plays a generic death, but if the unit is already gone, you cant use that unit properly as an argument to another function, ie:
Code:
Player - Modify player (Owner of (Triggering unit)) Minerals: Add ((Minerals cost of (Unit type of (Triggering unit))) / 2)
You do this when the triggering unit no longer exists, unless it is like wc3 where the unit exists until it decays.
Ah right, that's what I was getting at but I was focused on the wait instead of the kill unit.
 

X-maul

AKA: Demtrod
Reaction score
201
Ah, will try this when I get time :) It does make sense, but I still dont understand why it works for units not being morphed.

But thank you anyway guys :)
 
General chit-chat
Help Users

      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