* Random Spells & Systems

[GUI] No Target Order

Kam · 6279

0 Members and 1 Guest are viewing this topic.

[GUI] No Target Order
on: August 05, 2012, 01:44:13 PM

This is fairly simple. I have this ability that when activated converts resources to mana for a casting structure. The primary ability is a dummy ability based on immolation. When activated it adds a dummy ability that catches a every second timed trigger that does the resource conversion.

The problem I discovered is that when you use a "no target" order event anything the structure does starts the trigger, even despite having a condition that immolation/unimmolation be the only acceptable orders.

I mostly solved this by having another trigger that removes the dummy and resets the primary abilities when another type of order is given. This works accept when the building begins construction. How can I solve this?

Trigger: Test 1628833552
   
           
  • Conversion Setup
  •     Events
  •         Unit - A unit Is issued an order with no target
  •     Conditions
  •         Or - Any (Conditions) are true
  •             Conditions
  •                 (Unit-type of (Triggering unit)) Equal to Rift
  •                 (Unit-type of (Triggering unit)) Equal to Bastion
  •                 (Unit-type of (Triggering unit)) Equal to Parapet
  •         Or - Any (Conditions) are true
  •             Conditions
  •                 (Issued order) Equal to (Order(immolation))
  •                 (Issued order) Equal to (Order(unimmolation))
  •     Actions
  •         If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  •             If - Conditions
  •                 (Level of Mana Conversion (Dummy) for (Triggering unit)) Equal to 0
  •             Then - Actions
  •                 Unit - Add Mana Conversion (Dummy) to (Triggering unit)
  •             Else - Actions
  •                 If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  •                     If - Conditions
  •                         (Level of Mana Conversion (Dummy) for (Triggering unit)) Equal to 1
  •                     Then - Actions
  •                         Unit - Remove Mana Conversion (Dummy) from (Triggering unit)
  •                     Else - Actions
           
Trigger: Test 1795266184
   
           
  • Conversion Check
  •     Events
  •         Time - Every 1.00 seconds of game time
  •     Conditions
  •     Actions
  •         Set Conversion_Group = (Units in (Playable map area) matching ((Level of Mana Conversion (Dummy) for (Matching unit)) Equal to 1))
  •         Unit Group - Pick every unit in Conversion_Group and do (Actions)
  •             Loop - Actions
  •                 If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  •                     If - Conditions
  •                         ((Owner of (Picked unit)) Current gold) Greater than or equal to 5
  •                         (Mana of (Picked unit)) Not equal to (Max mana of (Picked unit))
  •                     Then - Actions
  •                         Player - Set (Owner of (Picked unit)) Current gold to (((Owner of (Picked unit)) Current gold) - 5)
  •                         Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 1.00)
  •                     Else - Actions
  •                 If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  •                     If - Conditions
  •                         ((Owner of (Picked unit)) Current lumber) Greater than or equal to 10
  •                         (Mana of (Picked unit)) Not equal to (Max mana of (Picked unit))
  •                     Then - Actions
  •                         Player - Set (Owner of (Picked unit)) Current lumber to (((Owner of (Picked unit)) Current lumber) - 10)
  •                         Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 1.00)
  •                     Else - Actions
  •         Custom script:   call DestroyGroup (udg_Conversion_Group)
           
Trigger: Test 1466531415
   
           
  • Conversion Upgrade Reset
  •     Events
  •         Unit - A unit Begins an upgrade
  •         Unit - A unit Finishes an upgrade
  •         Unit - A unit Cancels an upgrade
  •         Unit - A unit Begins construction
  •         Unit - A unit Finishes construction
  •         Unit - A unit Begins research
  •         Unit - A unit Cancels research
  •         Unit - A unit Finishes research
  •     Conditions
  •         Or - Any (Conditions) are true
  •             Conditions
  •                 (Unit-type of (Triggering unit)) Equal to Rift
  •                 (Unit-type of (Triggering unit)) Equal to Bastion
  •                 (Unit-type of (Triggering unit)) Equal to Parapet
  •     Actions
  •         Unit - Remove Mana Conversion (Dummy) from (Triggering unit)
  •         Unit - Remove Conversion  from (Triggering unit)
  •         Unit - Add Conversion  to (Triggering unit)
           



Re: [GUI] No Target Order
Reply #1 on: August 06, 2012, 08:50:34 AM

Hmmm, as far as I understand, the buldings have an ability on/off, and if you order them to... train a unit, they stop or activate the ability...

I need to do a test and probably implement somethign in jass, because in this case the gui triggers are inneficinet as hell.


Re: [GUI] No Target Order
Reply #2 on: August 07, 2012, 12:59:26 PM

Well, I've been working on this and I have this code thus far:

Code: jass
  1. scope ConvertResourcesToMana initializer init
  2.  
  3. globals
  4.     private constant real DT = 0.5
  5.     private constant integer BUFF = 'BEim' //Ability buff rawcode
  6.     private constant integer AB_OFF = 852178 //The abilities rawcode related to unimmolation.
  7.     private constant integer RATE = 10 // set the resource rate
  8.     private constant real MANA_RATE = 1. // set the mana rate
  9.  
  10.     private timer T = CreateTimer()
  11. endglobals
  12.  
  13. private function Check takes nothing returns nothing
  14.     local unit u
  15.     local integer g
  16.     local integer l
  17.     local player p
  18.     call GroupEnumUnitsInRange(bj_lastCreatedGroup, 0,0, 9999999999., null)
  19.     loop
  20.         set u = FirstOfGroup(bj_lastCreatedGroup)
  21.         exitwhen u == null
  22.         if GetUnitAbilityLevel(u, BUFF) > 0 then
  23.             set p = GetOwningPlayer(u)
  24.             set g = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
  25.             set l = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
  26.             if GetUnitState(u, UNIT_STATE_MANA) == GetUnitState(u, UNIT_STATE_MAX_MANA) or g < 1 or l < 1 then
  27.                 call IssueImmediateOrderById(u, AB_OFF)
  28.             endif
  29.             call SetPlayerStateBJ(p, PLAYER_STATE_RESOURCE_GOLD, g - R2I(RATE * DT))
  30.             call SetPlayerStateBJ(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, l - R2I(RATE * DT))
  31.             call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + MANA_RATE * DT)
  32.         endif
  33.         call GroupRemoveUnit(bj_lastCreatedGroup, u)
  34.     endloop
  35. endfunction
  36.  
  37. private function init takes nothing returns nothing
  38.     call TimerStart(T, DT, true, function Check)
  39. endfunction
  40.  
  41. endscope

I still can't make it work when the building trains the unit. The funny thing is that it doesn't stop the order, in fact it "pauses" the building which generates conflict. I will plan to do a modification, checking all the units with the buff.


EDIT: HMMM I've improved the code much more :) Now it doesn't stop when the building trains other units but the buff is still present while the building trains. That proves the fact the buildings are paused while builds.

Compare this code with all the stuff you wrote in GUI :P

Important note: You will notice that DH will switch off the Immolation ability, it happens because I have not changed the buff ID in the custom ability. If you change it in the code and in the ability it will work fine :)
« Last Edit: August 07, 2012, 01:20:24 PM by moyack »



 

Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)