• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Object editor questions

Status
Not open for further replies.
Level 6
Joined
Mar 31, 2012
Messages
169
These questions all relate to the latest patch. Some of these may fall under jass/triggers, and some may be impossible with the current tools. I'm looking for the simplest, most performant methods of achieving the following:

Round 1: 11-4-19

Income multiplier for AI players -- solved!
I want to give AI players a 1.5x multiplier on gold. They should still drain the normal amount of gold from a mine, so I can't use the gold harvesting upgrade or a buffed version of the harvest ability on their workers, as that drains the gold mine faster than I want it to. The income should also apply to unit bounties and item sales, basically like an inverted upkeep system. (You can't increase gold tax above 1.00 in gameplay constants, I've already tried).

Depleted gold mines offer 25% of original yield -- pending testing
Similar to SCBW's vespene geysers, I want gold mines to offer 2.5 gold per return once emptied. Simple to write, but presumably very silly to implement.

Increase lumber amount without increasing tree health
I want trees to have 1.5x or 2x the current lumber amounts, but still die to the same number of attacks from workers, infernals, siege weapons, etc. This would be trivial if you could change their armor type but as far as I know this is impossible.

I'll post more questions as I come up with them. The project I'm working on right now is pretty vast in scale so I'll probably have quite a few.

Round 2: 14-4-19

Increase lumber harvest speed without increasing gold harvest speed
What it says on the tin. A worker that can harvest both resources should mine lumber faster than gold. I need a solution that won't remove the ability to press 'G' (gather) to target both, and preferably without a triggered solution.
 
Last edited:
Level 42
Joined
Feb 27, 2007
Messages
5,313
Depleted gold mines: good fucking luck. I can’t think of a mechanic that would allow a gold mine to be used indefinitely without messing up worker orders when it dies and is replaced with another mine. As for making it give less gold per trip, probably also impossible without an extremely fast timer to check for changes in gold gain. Gold cannot be fractional, afaik it’s an integer internally not a real.

AI gold bonus: this is very doable by tracking changes in gold with a very fast timer. This can potentially get messed up if the AI both gains gold and spends gold during a single timer period, but with a low period (0.03? idk) it would be unlikely.

  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • ———— do this but in a loop for all AI players, using array versions of the variables ————
    • Set AI = Some Player
    • Set Gained = (MULTIPLIER x ((Current gold of AI) - Last))
    • Player - Add Gained gold to AI current gold
    • Set Last = (Current gold of AI)
 
Level 6
Joined
Mar 31, 2012
Messages
169
Thanks for the reply. How would I set up an array? Not very well-versed in war3 triggers. edit: can't I run this in one trigger, for player group - all players with the controller 'computer'?

edit2: this seems like a prank, since it doesn't take into account spending as far as I can tell, so you'd lose 1.5x (at least) the gold cost when spending cash.

edit3: here's the solution I came up with.
image.png

Caveat is that the AI instantly gets the +5 when the unit exits the mine. If the worker is interrupted before they finish returning, they'll eventually get the order to return again, giving them an extra +5. It's not really that common for this to happen in my current tests, so this is the frontrunner unless someone can come up with a more elegant solution.
 
Last edited:
Level 42
Joined
Feb 27, 2007
Messages
5,313
You just need to also check that Gained is > 0. You still have the problem of spending and gaining during a single timer period. If you spend 80 and gain 10 you won’t get the bonus gold on the 10 gained since the total change was negative.

  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • Set TempForce = (All players controlled by a Computer player)
    • Player Group - Pick all players in TempForce and do (Actions)
      • Loop - Actions
        • Set AI = (Picked Player)
        • Set Gained = (MULTIPLIER x ((Current gold of AI) - Last[(Player Number of AI)]))
        • If (All conditions) then (Actions) else (Actions)
          • If - Conditions
            • Gained greater than 0
          • Then - Actions
            • Player - Add Gained gold to AI current gold
          • Else - Actions
        • Set Last[(Player number of AI)]= (Current gold of AI)
    • Custom script: call DestroyForce(udg_TempForce) //change the name here to match your variable name, but keep the udg_ prefix
It would be better to just set the player group variable on map init and then never have to destroy it, but that’s really up to you. It’s also possible that the ‘computer players’ and ‘human players’ player group are presets like ‘all players’ that don’t leak, but I’m on mobile and can’t check the JASS breakdown of that GUI function.
 
Since you need depleted gold mines and we can keep those mines alive there's solution:
  • t
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Resource quantity contained in Gold Mine 0012 <gen>) Less than 100
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Remove Gold Mine ability from Gold Mine 0012 <gen>
      • Wait 3.00 seconds
      • Set GoldMineDepleted[(Custom value of Gold Mine 0012 <gen>)] = True
      • Floating Text - Create floating text that reads DEPLETED above Gold Mine 0012 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Unit - Add Gold Mine ability to Gold Mine 0012 <gen>
      • Neutral Building - Set Gold Mine 0012 <gen> to 100 gold
      • -------- --- --------
      • Custom script: loop
      • Wait 2.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Resource quantity contained in Gold Mine 0012 <gen>) Less than 100
        • Then - Actions
          • Neutral Building - Set Gold Mine 0012 <gen> to 100 gold
        • Else - Actions
      • Custom script: endloop
so if gold drops to, lets say, 100 we set boolean flag "depleted" to true and in loop keep gold at 100.

I've done somethis like this before in Custom Resources lib. But considering gold mines never dies it is even easier to catch an event "worker brings gold":

JASS:
globals
    constant integer        GOLD_DEPLETED = 2
    timer               g_gameTimer=CreateTimer()
    real array       g_goldGainTimeStamp    //[playerId]
    integer array  g_goldGainValue              //[playerId]
    boolean array       g_workerDepleted        //[worker id]
endglobals
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
function Trig_HarvestSmart_Cond takes nothing returns boolean
    local integer ord=GetIssuedOrderId()
    local integer id=GetUnitUserData(GetOrderedUnit())
  
    if (ord==ORDER_harvest or ord==ORDER_smart) and GetUnitAbilityLevel(GetOrderTargetUnit(), 'Agld')>0 then
        if udg_GoldMineDepleted[GetUnitUserData(GetOrderTargetUnit())] then
            set g_workerDepleted[id]=true
        else
            set g_workerDepleted[id]=false
        endif
    endif
    return false
endfunction
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
function Trig_GoldChanged takes nothing returns nothing // "udg_PRM_EVENT", EQUAL, 1.00
    local integer i = GetPlayerId(udg_PRM_Player)
    if udg_PRM_Change > 0 then  
        //it fires as 1st, after this - "order harvest"  (or other) runs, remember time-stamp for this player and value:
        set g_goldGainTimeStamp[i] = TimerGetElapsed(g_gameTimer)
        set g_goldGainValue[i]= udg_PRM_Change
        //call Msg("(PRM) time stamp: " + R2S(TimerGetElapsed(g_gameTimer)) + ", " + GetPlayerName(udg_PRM_Player) + ", value: " + I2S(udg_PRM_Change))
    endif
endfunction
//===========================================================================
//===========================================================================
// this is an EVENT "worker brings gold"
function Trig_WorkerBringsGld_Cond takes nothing returns boolean
    //if peasant recive ANY order like: harvest normal resources or player queued any order (stop, attack, move, etc) then:
    if TimerGetElapsed(g_gameTimer) == g_goldGainTimeStamp[GetPlayerId(GetOwningPlayer(GetOrderedUnit()))] then
        //worker has a "depleted" flag
        return g_workerDepleted[GetUnitUserData(GetOrderedUnit())]
        // ordered unit is 'last gold supplier' with "depleted" flag
    endif
    return false
endfunction
//------------------------------------------------------------------------------------
function Trig_WorkerBringsGld_Act takes nothing returns nothing
    local unit u = GetOrderedUnit()
    local player pla = GetOwningPlayer(u)
    local integer i = GetPlayerId(pla)
  
    set udg_PRM_FireEvent = false
    call SetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD)-g_goldGainValue[i])
    //now add reduced gold
    call SetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD)+GOLD_DEPLETED)
    set udg_PRM_FireEvent = true
  
    //call Msg(GetUnitName(u) + " brings " + I2S(g_goldGainValue[i]) + "gold, time stamp: " + R2S(TimerGetElapsed(g_gameTimer)))
    set u=null
    set pla=null
endfunction

//===========================================================================
//===========================================================================
function InitTrig_gld takes nothing returns nothing
    local trigger t
    call TimerStart(g_gameTimer, 36000.00, false, null)
  
    set t = CreateTrigger() //order "harvest" or "smart" on worker --> gold mine
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition(function Trig_HarvestSmart_Cond))
  
    set t = CreateTrigger()//----for gold has been changed event
    call TriggerRegisterVariableEvent(t, "udg_PRM_EVENT", EQUAL, 1.00)
    call TriggerAddAction(t, function Trig_GoldChanged)
  
    set t = CreateTrigger() // for worker-brings-resources event
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(t, Condition(function Trig_WorkerBringsGld_Cond))
    call TriggerAddAction(t, function Trig_WorkerBringsGld_Act)

endfunction
The only inconvinience is diplaying original "+10 gold" in game, but player gets of cource only reduced value (+2)
 

Attachments

  • Pr0nogo.w3x
    42.7 KB · Views: 35
Level 6
Joined
Mar 31, 2012
Messages
169
That sounds like a reasonable solution, though I really would like to find a way to show the accurate amount of gold. It also seems like you're actually detecting "worker returns gold", which would be useful as a condition for my gold multiplier solution for AI players. I'm still really new to jass outside of custom AI so I'll take a bit to figure out how exactly you wrote this, otherwise I'll just be plugging in your code and have no idea what to do if something goes wrong. Thanks for the help.

edit: two issues with the map you attached. When a gold mine is depleted, the workers get interrupted. They should keep mining with no issues, if tha'ts possible. I'd also like to remove the gold value from the display, so when you click on it you just see its invulnerable armor and no gold count.
 
Last edited:
Try this version, it is without an "worker brings gold" event but simpler. It switches 2 abilities: normal Ahar and custom one with edited field Data Gold Capacity (changed to 2). Also it has no requirements (before you need UnitEvent by Bribe and PlayerResourceMonitoring).

Removing gold value from the display (from Gold mine) is not possible, at least I don't know a way how to do that.
 

Attachments

  • Pr0nogo v2.w3x
    41.1 KB · Views: 34
Level 6
Joined
Mar 31, 2012
Messages
169
That works better, thanks! The only other bug I found was that ordering a peasant carrying depleted gold to harvest a full mine removed the sack. The reverse is also true. Not sure if there's a way around that?

If you are actually detecting when a resource is returned, is it possible I could get those conditions for the trigger I posted a few posts up, regarding the AI multiplier?
 
:)
Maybe first solution for AI (showing gold on worker return is not important)
The only other bug I found was that ordering a peasant carrying depleted gold to harvest a full mine removed the sack
That's true, it's because we are switching 2 diffrent harvest abilities on a worker. It works similar like if worker has a gold bag on his back and a player orders to harvest lumber, worker will lose this gold when starts choping the tree.

Increase lumber amount without increasing tree health
This is doable with 1st solution with one exception: when worker came back with lumber to Town Hall and then there are no alive trees nearby to harvest he will be stopped. In this case script won't add additional 50% lumber as you need it.
(I prevent that in my library Custom Resources by adding "dummy tree" nearby all structures able to get lumber, but in this library I order workers, which is not acceptable for AI.)
The income should also apply to unit bounties and item sales,
And this is a completely different story ;)
 
Level 6
Joined
Mar 31, 2012
Messages
169
You just need to also check that Gained is > 0. You still have the problem of spending and gaining during a single timer period. If you spend 80 and gain 10 you won’t get the bonus gold on the 10 gained since the total change was negative.
Here's the trigger I came up with based on that (had to convert between int and real since it's a 1.5x multiplier), but I'm getting 10 gold returned for AI players. Maybe it's a simple error that you can find easily, but I haven't been able to find it.

  • GoldMultiplier
    • Events
      • Time - Elapsed game time is 0.03 seconds
    • Conditions
    • Actions
      • Set TempForce = (All players controlled by a Computer player)
      • Player Group - Pick every player in TempForce and do (Actions)
        • Loop - Actions
          • Set AI = (Picked player)
          • Set GoldGained = (Integer(((Real(((AI Current gold) - GoldLast[(Player number of AI)]))) x 1.50)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldGained Greater than 0
            • Then - Actions
              • Player - Add GoldGained to AI Current gold
            • Else - Actions
          • Set GoldLast[(Player number of AI)] = (AI Current gold)
      • Custom script: call DestroyForce(udg_TempForce)
It works similar like if worker has a gold bag on his back and a player orders to harvest lumber, worker will lose this gold when starts choping the tree.
In the case of lumber/gold being carried, the resource doesn't get removed until the worker enters the mine or chops the tree. In this case it's instant upon order.
 
Since your topic inspired me, I decided to edit my previous solution if you're still interested. If you accept fact that depleted gold mine displays non-zero gold value, there are no other issues.
Solution contains:
  • depleted gold mine script (for players and AI)
  • 50% more gold for AI from non-depleted mines
  • in trigger "AILumberGained" 100% more lumber for AI
Script requires: Unit Event by Bribe, PRM , library Order
GUI Unit Event v2.5.2.0
Player Resource Monitoring v1.01
Order Ids
Lumber:
  • AILumberGained
    • Events
      • Game - PRM_EVENT becomes Equal to 2.00
    • Conditions
      • (PRM_Player controller) Equal to Computer
      • PRM_Change Greater than 0
    • Actions
      • Set PRM_FireEvent = False
      • -------- it adds the same lumber amount, so the real income is x2 --------
      • Player - Add PRM_Change to PRM_Player Current lumber
      • Set PRM_FireEvent = True
tthis keeps Gold Mines alive with gold value: 100
JASS:
globals
    unit            g_tempGoldMine=null
    boolean array               g_goldMineDepleted // [unit id]
endglobals
//-----------------------------------------------------------------------------
function Trig_GoldMineTrack_Act takes nothing returns nothing
    local unit u=g_tempGoldMine
    local real delay=5.00
    loop
        if GetResourceAmount(u)<300 then
            set delay=1.00
        endif
        exitwhen GetResourceAmount(u)<100
        call TriggerSleepAction(delay)
    endloop
      
    set g_goldMineDepleted[GetUnitUserData(u)] = true
    call CreateTextTagUnitBJ( "DEPLETED", u, 0, 10, 100, 100, 100, 0 )
    call SetResourceAmount(u, 100)
    loop
        call TriggerSleepAction(1.00)
        if GetResourceAmount(u) < 100 then
            call SetResourceAmount(u, 100)
        endif
    endloop
endfunction
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
function Trig_GoldMineEnters_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(udg_UDexUnits[udg_UDex], 'Agld') > 0
endfunction
function Trig_GoldMineEnters_Actions takes nothing returns nothing
    local unit u=udg_UDexUnits[udg_UDex]
    local trigger t=CreateTrigger()
    set g_tempGoldMine=u
    call TriggerAddAction(t, function Trig_GoldMineTrack_Act)
    call TriggerExecute(t)
    set t=null
endfunction
//===========================================================================
function InitTrig_GoldMineEnters takes nothing returns nothing
    set gg_trg_GoldMineEnters = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_GoldMineEnters, "udg_UnitIndexEvent", EQUAL, 1.00 )
    call TriggerAddCondition( gg_trg_GoldMineEnters, Condition( function Trig_GoldMineEnters_Conditions ) )
    call TriggerAddAction( gg_trg_GoldMineEnters, function Trig_GoldMineEnters_Actions )
endfunction

main script that supports depleted gold mines and bonus gold for AI

JASS:
//script works for GoldMines with ability 'Agld'
//requires Unit Event , PRM , library Order
// by ZibiTheWand3r3r  15.04.2019
globals
    constant integer        ABI_HARVEST_DEPLETED = 'A002' //ability for harvest from depleted gold mines
                                                                                            //with "Data Gold Capacity = 2"
    constant real              AI_GOLD_FACTOR = 0.50    //50% more gold for AI from non-depleted mines
  
    timer               g_gameTimer=CreateTimer()
    real array       g_goldGainTimeStamp    //[playerId]
    integer array  g_goldGainValue              //[playerId]
    boolean array       g_workerDepleted        //[worker id]
    boolean array       g_hasGoldBag            //[worker id]
    hashtable                              g_hash = InitHashtable()
endglobals
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
function SetWorkerDepletedFlag_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer h_id=GetHandleId(t)
    local integer id = LoadInteger(g_hash, h_id, 0)
    local boolean b = LoadBoolean(g_hash, h_id, 1)
    local unit u=udg_UDexUnits[id]
    if b and GetUnitAbilityLevel(u, ABI_HARVEST_DEPLETED)==0 then
        call UnitRemoveAbility(u, 'Ahar')
        call UnitAddAbility(u, ABI_HARVEST_DEPLETED)
    elseif (not b) and GetUnitAbilityLevel(u, 'Ahar')==0 then
        call UnitRemoveAbility(u, ABI_HARVEST_DEPLETED)
        call UnitAddAbility(u, 'Ahar')
    endif
    set g_workerDepleted[id]=b
    call FlushChildHashtable(g_hash, h_id)
    call DestroyTimer(t)
    set t = null
    set u=null
endfunction
function SetWorkerDepletedFlag takes integer unitId, boolean flag returns nothing
    local timer t=CreateTimer()
    local integer h_id=GetHandleId(t)
    call SaveInteger(g_hash, h_id, 0, unitId)
    call SaveBoolean(g_hash, h_id, 1, flag)
    call TimerStart(t, 0.00, false, function SetWorkerDepletedFlag_Child)
    set t=null
endfunction
//--------------------------------------------------------------------------------
// set boolean flag and harvest-ability for worker who targets Gold Mine (normal or depleted)
function Trig_HarvestSmart_Cond takes nothing returns boolean
    local integer ord=GetIssuedOrderId()
    local integer id=GetUnitUserData(GetOrderedUnit())
    local boolean goldMineDepleted=g_goldMineDepleted[GetUnitUserData(GetOrderTargetUnit())]  
    if GetUnitAbilityLevel(GetOrderTargetUnit(), 'Agld')>0 then  
        if (ord==ORDER_smart) and (not g_hasGoldBag[id]) then
            call SetWorkerDepletedFlag(id, goldMineDepleted)
        elseif ord==ORDER_harvest then
            call SetWorkerDepletedFlag(id, goldMineDepleted)
        endif
    endif
    return false
endfunction
//--------------------------------------------------------------------------------
// for worker-gets out from Gold Mine (or resumeharvesting clicked)
function Trig_WorkerGetOutFromMine_Cond takes nothing returns boolean
    if GetIssuedOrderId()==ORDER_resumeharvesting then
        set g_hasGoldBag[GetUnitUserData(GetOrderedUnit())]=true
    endif
    return false
endfunction
//--------------------------------------------------------------------------------
function Trig_GoldChanged takes nothing returns nothing // "udg_PRM_EVENT", EQUAL, 1.00
    local integer i = GetPlayerId(udg_PRM_Player)
    if udg_PRM_Change > 0 then
        //it fires as 1st, after this - "order harvest"  (or other) runs, it saves time-stamp for this player and value:
        set g_goldGainTimeStamp[i] = TimerGetElapsed(g_gameTimer)
        set g_goldGainValue[i]= udg_PRM_Change
    endif
endfunction
//===========================================================================
// this is an EVENT "worker brings gold"
function Trig_WorkerBringsGld_Cond takes nothing returns boolean
    local player pla=GetOwningPlayer(GetOrderedUnit())
    local integer i=GetPlayerId(pla)
    local integer id=GetUnitUserData(GetOrderedUnit())  
    //if peasant recive ANY order like: harvest or player queued any order (stop, attack, move, repair etc) then:
    if TimerGetElapsed(g_gameTimer) == g_goldGainTimeStamp[i] then //ordered unit is 'last gold supplier'
        set g_hasGoldBag[id]=false
        if not g_workerDepleted[id] then //if worker comes from not depleted mine, add 50% more for AI:
            if GetPlayerController(pla)==MAP_CONTROL_COMPUTER then
                set udg_PRM_FireEvent = false
                call SetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD)+R2I((AI_GOLD_FACTOR*g_goldGainValue[i])))
                set udg_PRM_FireEvent = true
            endif
        endif
    endif
    set pla=null
    return false
endfunction
//===========================================================================
//===========================================================================
function InitTrig_GoldDepletedScript takes nothing returns nothing
    local trigger t
    call TimerStart(g_gameTimer, 36000.00, false, null)
  
    set t = CreateTrigger() //worker ordered "harvest" or "smart"  --> gold mine
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition(function Trig_HarvestSmart_Cond))
  
    set t = CreateTrigger()// gold has been changed event
    call TriggerRegisterVariableEvent(t, "udg_PRM_EVENT", EQUAL, 1.00)
    call TriggerAddAction(t, function Trig_GoldChanged)
  
    set t = CreateTrigger() // worker-brings-resources event
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(t, Condition(function Trig_WorkerBringsGld_Cond))
  
    set t = CreateTrigger() // worker-gets out from Gold Mine
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER) //resumeharrvesting may be instant or target-order
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(t, Condition(function Trig_WorkerGetOutFromMine_Cond))
endfunction
 

Attachments

  • Pr0nogo v3.w3x
    39.4 KB · Views: 39
Last edited:
Level 6
Joined
Mar 31, 2012
Messages
169
For round 2, have you tried using Attack Speed Bonus? I'm not sure if they actually use the attack speed, but worth a shot.
Attack speed for the worker's secondary attack is used when they're ordered to attack trees, not when they're ordered to harvest them.

Since your topic inspired me, I decided to edit my previous solution if you're still interested. If you accept fact that depleted gold mine displays non-zero gold value, there are no other issues.
Pardon if this is a base-level question, but this solution you've provided requires the two addons you've linked; are there downsides to using them, e.g. performance hits? Thank you very much for all the work you've done, it's much appreciated. I'll start working on implementation soon and post my results.

edit:
to clarify, I only wanted a gold multiplier, which Pyrogasm supplied. Lumber is fine as-is, but I'll keep your solution for that in mind if I decide to include it going forward. This also means I don't need any gold multiplier, since Pyro's solution handles all gold gained. If I'm just trying to turn near-empty gold mines into depleted gold mines that return showing +2 and maybe tap into the 'gold mine collapsed' alert system, what should I be grabbing?
 
Last edited:
downsides to using them, e.g. performance hits
But not at all! 0.03sec periodics are more dangerous for performance.
I only wanted a gold multiplier, which Pyrogasm supplied
Oh, I see. Im sorry I didn't read your first post excatly. So you need bonus gold for AI from all possible sources? Its easy to implement: use as a base my lumber trigger, use event PRM_EVENT becomes Equal to 1.00, and add value you want to current gold (instead of lumber).

To disable 0.50 gold multipler in script comment these lines:
JASS:
if not g_workerDepleted[id] then //if worker comes from not depleted mine, add 50% more for AI:
            if GetPlayerController(pla)==MAP_CONTROL_COMPUTER then
                set udg_PRM_FireEvent = false
                call SetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(pla, PLAYER_STATE_RESOURCE_GOLD)+R2I((AI_GOLD_FACTOR*g_goldGainValue[i])))
                set udg_PRM_FireEvent = true
            endif
        endif

If I'm just trying to turn near-empty gold mines into depleted gold mines
Would't be enough to just change Gold Mine name? call BlzSetUnitName(u, "Depleted Gold Mine"), play a sound and/or play effect on gold mine?
 
Level 42
Joined
Feb 27, 2007
Messages
5,313
But not at all! 0.03sec periodics are more dangerous for performance.
This is incredibly naive. It's not the frequency of the timer, it's how efficient the code you run is. Maps can run 100+ object physics systems with collision detection fine on a 0.03 or faster timer... and this simple trigger will lag the everloving FUCK out of your map (ignore it leaking, i'm not saying the leaks cause the lag):

  • Events
    • Time - Ever 0.03 seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in (Playble Map Area) matching ((Power((Current life of (matching unit)), 3)) less than 100000.00) //the power operation is very bad
      • Loop - Actions
        • Unit Group - Pick every unit in (Units within 300.00 of (Position of Picked Unit) matching ((Owner of (Matching Unit)) is an enemy of (Owner of (Picked Unit)) equal to true) and do (Actions)
          • Loop - Actions
            • Special Effect - Create a special effect attached to the Overhead of (picked Unit) using Some/Model.mdx
            • Special Effect - Destroy (last created special effect)
 
Status
Not open for further replies.
Top