• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit Refund 1.0

This bundle is marked as awaiting update. A staff member has requested changes to it before it can be approved.
This is a spell that enables the refunding of units which I made on request. It's nothing fancy but includes the possibility to change the minimum hp requirement for selling a unit and a configurable refund ratio. If the refund ratio is set to 0% the ability will be hidden. Also, changing the refund ratio or hq requirement will dynamically change the tooltip.

The default refund value is currently based on the unit-type, however, it can be overriden by setting a custom refund value for a specific unit using a unit indexer.


Setting up the spell is as easy as modifying these variables to suit your needs. UnitRefundRatio is the percentage of funds returned and UnitRefundReqHP is the percentage of HP required to sell the unit.

  • -------- Setup --------
  • -------- MODIFY THE VARIABLES BELOW --------
  • Set UnitRefundRatio = 0.50
  • Set UnitRefundReqHP = 0.80
  • Set UnitRefundAbility = Sell Unit
Note that the tooltip changes depending on the refund ratio and the configured hp requirements. If you wish to change the tooltip you must change the following section of trigger:
  • -------- - --------
  • -------- MODIFY THIS PART IF YOU WISH TO CHANGE THE TOOLTIP --------
  • -------- - --------
  • Custom script: if udg_UnitRefundReqHP > 0. then
  • Custom script: call BlzSetAbilityExtendedTooltip(udg_UnitRefundAbility, "Refunds the unit for " + I2S(R2I(udg_UnitRefundRatio * 100)) + "% of its purchasing cost. Requires " + I2S(R2I(udg_UnitRefundReqHP * 100)) + "% health.", 1)
  • Custom script: else
  • Custom script: call BlzSetAbilityExtendedTooltip(udg_UnitRefundAbility, "Refunds the unit for " + I2S(R2I(udg_UnitRefundRatio * 100)) + "% of its purchasing cost.", 1)
  • Custom script: endif
  • -------- END --------



It's possible to set a custom refund value to specific units if you use a unit indexer. Example:
  • CustomUnitCost
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Example of how to change the refund value of a unit that is not based on the unit-type cost --------
      • Set unit = Rifleman 0006 <gen>
      • Set UnitRefundGoldCost[(Custom value of unit)] = 1000
      • Set UnitRefundWoodCost[(Custom value of unit)] = 1000
      • -------- Note that you must 0 these values when the unit is deindexed --------
Contents

Unit Refund 1.1 (Map)

Reviews
Dr Super Good
Required for Approval: If a GUI trigger is as good as entirely custom script then it is a badly formatted JASS trigger and not a GUI trigger. It is not helpful for people who understand JASS due to the bad editing environment and indentation that GUI...
Level 15
Joined
Nov 30, 2007
Messages
1,202
But don't get me wrong not to make such spell, but just to maybe use those natives. :)

It's perfectly reasonable to say this is too simple, I would tend to agree. :)

I've added the natives, and changed it to be completely in GUI, one can now get the refund based on the unit-type and using a unit indexer for changed unique values. However, I've not decided on whats the best way to override the default refund value for unit-types, might bring back the hashtable for that feature.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Required for Approval:
If a GUI trigger is as good as entirely custom script then it is a badly formatted JASS trigger and not a GUI trigger. It is not helpful for people who understand JASS due to the bad editing environment and indentation that GUI provides. It is also not helpful to people who only can use GUI since practically none of it is GUI. Converting the trigger to custom script does not automatically fix the indentation.

The system revision number is inconsistent between the title and the file. Title says 1.0 but file says 1.1. This could potentially result in confusion.​

Suggestions and Comments:
From what I can tell it does not track the total cost of upgraded units. A common use case for refund systems is with maps like tower defences where the towers may go through various upgrade paths with different costs before requesting a refund and the correct behaviour would be to refund some part of the total cost and not just the cost of the last stage. This would likely need to be done on a per unit basis for best results so that branching upgrade paths with different total costs can be correctly refunded.

In 1.31 there will likely be other methods of obtaining unit costs. These might remove the need to declare the AI natives.​
 
Top