• 🏆 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-system for multiple tower

Status
Not open for further replies.
Level 2
Joined
Jun 27, 2009
Messages
10
Got a problem with this one. The sell-system works fine on one tower but when I select 2 or more towers. It only sell one tower by one tower instead of all of them straight. anything i have to adjust? :confused:
 
Level 8
Joined
Dec 8, 2007
Messages
312
what are you using to sell towers? ability or unit training?

you can make towers train unit that will get remove it self and tower after training and give you gold back. This allows selling more towers with one click. But then towers get that annoying rally point.

other way is giving them ability that will sell them after cast. if you base them on war stomp or something like that than problem is that all units don't cast it at once.
I think berserk ability is used on all units at once but personally.

if that doesn't help you should show your trigger
 
Level 8
Joined
Aug 1, 2008
Messages
420
I can give you my sell system if you want.. lemme just find it. Ill edit this post when i find it. Its MUI and uses an imported effect, but you can change that.
Edit: got it.

Name the trigger Sell, click on it, then go to Edit --> Convert to custom text, then copy/paste this.

JASS:
function Trig_Sell_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction
function Trig_Sell_Actions takes nothing returns nothing
    local effect e
    local unit shop = GetTriggerUnit()
    set e = AddSpecialEffectLoc( "war3mapImported\\StarfallCaster.mdx" , GetUnitLoc( shop ))
    call PauseUnit(shop, true)
    call TriggerSleepAction( 2.50 )
    call AdjustPlayerStateBJ( GetUnitPointValue(shop), GetOwningPlayer(shop), PLAYER_STATE_RESOURCE_GOLD )
    call KillUnit( shop )
    call DestroyEffect( e )
    set e = null
    set shop = null
endfunction
//===========================================================================
function InitTrig_Sell takes nothing returns nothing
    set gg_trg_Sell = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sell, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Sell, Condition( function Trig_Sell_Conditions ) )
    call TriggerAddAction( gg_trg_Sell, function Trig_Sell_Actions )
endfunction

This trigger makes a special effect, will give the seller the amount of gold you put in the point value box in object editor, and kill the unit.
What you need to do is make a spell called Sell, and then press CTRL+D on the "abilities" tab, then it will show the raw data. Then the 'A003', you will have to change to whatever it says in your object editor. Also you will need to change the 'war3mapImported\\StarfallCaster.mdx' to whatever effect you want. Ill attach the effect that i used, so you dont have to edit it.
Effect made by Pyritie.
 

Attachments

  • StarfallCaster.mdx
    18.2 KB · Views: 95
Last edited:
Level 2
Joined
Jun 27, 2009
Messages
10
Well i used warstomp as the base of the ability. Saw it from tutorial somewhere ><" Here's the trigger I used.

  • Sell Tower
  • Events
  • Unit - A unit Begins casting an ability
  • Conditions
  • (Ability being cast) Equal to Sell Building
  • ((Casting unit) is A structure) Equal to True
  • Actions
  • Set TempPoint = (Position of (casting unit))
  • Special Effect - Create a special effect at TempPoint using UI\Feedback\GoldCredit\GoldCredit.mdl
  • Special Effect - Destroy (Last created special effect)
  • Custom script: call RemoveLocation( udg_TempPoint)
  • Custom script: call AdjustPlayerStateBJ( (3*GetUnitPointValue(GetTriggerUnit()))/4, GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD )
  • Unit - Remove (Casting unit) from the game
That's the trigger I used ><"

Edit:
The MUI code you provide still sell the tower one by one ><"
Thanks for replying though :D
 
Last edited:
Level 2
Joined
Jun 27, 2009
Messages
10
Hmm, what spell do you based on? I copied exactly everything and only change the 'A003' to what it states in the object editor.
 
Level 8
Joined
Aug 1, 2008
Messages
420
I dont know what i based it on. I think channel...
Edit: yeah it was channel
Follow through time should be 0, or i think it will mess it up, not sure
Oh and make sure to change the condition in your GUI trigger or that will fire the same time as the JASS one..
 
Level 2
Joined
Jun 27, 2009
Messages
10
Yeah it works now since i changed it to channel :D
Thanks. Btw, Don't really get what you mean here
Oh and make sure to change the condition in your GUI trigger or that will fire the same time as the JASS one..

There's another thing i wanna ask, I want to change the special effect to Gold Coin effect but when I insert this "UI\Feedback\GoldCredit\GoldCredit.mdl"
The WE crashed. any idea why?

Edit: Never mind, i found a solution to it.
 
Level 8
Joined
Aug 1, 2008
Messages
420
Nvm about the GUI trigger now, you can delete that. (your old one)

Make sure the path is right, and it looks exactly like mine does.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
i don´t really know is this what you needed
but i will give you it as an example

  • order to all units selected
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Set UNITGROUP = (Units owned by (Owner of (Selling unit)) matching ((((Matching unit) is selected by (Owner of (Selling unit))) Equal to True) and ((Unit-type of (Matching unit)) Equal to (Unit-type of (Selling unit)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in UNITGROUP) Not equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in UNITGROUP and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to train/upgrade to a (Unit-type of (Sold unit))
        • Else - Actions
      • Custom script: call DestroyGroup(udg_UNITGROUP)
  • -------- no need to turn on (this trigger) again---------
it looks weird because of - turn off (this trigger) action but it will just stop the units to be bought more times

for example if you have 100 units of same type available to buy in shop they will be bought 100 times if the shop is once ordered by the trigger without -turn off (this trigger) action

turn off (this trigger) action is needed only when you sell a unit because selling a unit lasts for 0 seconds
 
Status
Not open for further replies.
Top