• 🏆 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!

Sell Tower / Transmute / Problem

Status
Not open for further replies.
Level 13
Joined
Mar 19, 2010
Messages
870
A question.

In my map i sell towers with a dummy unit and transmute. All works fine.
Now i'm working on a Tower AI and the selling makes trouble :)

I debugged up to the point that it's not possible to order a dummy casting transmute if the dummy player is a computer.

here's the code snippet.
JASS:
private static method onSell takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetTrainedUnit()
			
    if GetUnitTypeId(t) == SELL then
        call SetUnitInvulnerable( u, false )
        call IssueTargetOrder( t, "transmute", u )
        call UnitApplyTimedLife(t, 'BTLF', 1.50)
        call GroupRemoveUnit(BEING_UPGRADE_UNITS, u)
    endif
            
    set u = null
    set t = null
endmethod

This code works fine for real players BUT as i said if the TrainedUnit(Dummy with the transmutre ability) is a computer player it will not work!!!
Any ideas? My idea is to sell the tower manually by remove + special effect and give wood back to the player. For this i need a special lib which gets me the tower costs. I think i saw it here on hive.

Best Reg.
 
Level 3
Joined
Mar 3, 2011
Messages
58
If you have upgraded structures or units
just give each one of them the results of "base cost" + "upgrade cost"

IIRC, the thread about AI using abilities, the AI doesn't use transmute
 
Level 12
Joined
Nov 3, 2013
Messages
989
Since it's still the same unit even if it's upgraded or morphed you could index, store in hashtable or use unit custom value to save the total gold cost.

It should be fairly easy to either use that function from the AI stuff (common.ai or something maybe?) to get the unit-type gold and lumber cost or using series of elseif
 
Level 13
Joined
Mar 19, 2010
Messages
870
we made a workaround to get the value for all tower upgrades. It's fine now but it takes a lot of time get the knowledge that the computer does not cast transmute :(

Anyway Thx all for time and help!!!

The complete Tower AI you can check soon ^^
 
Status
Not open for further replies.
Top