Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
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 --------
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...
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.