• 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.

Cancel last building?

Status
Not open for further replies.
Level 2
Joined
May 31, 2012
Messages
16
Ive been trying to look for a way to make the last created structure to be destroyed or removed from the game (Cancel last built farm)

Ive been looking around in the GUI and I couldnt find any possible way to achieve this. Can anyone help?

What I want to achieve:

Give a unit an ability to cancel the last farm they built (Still constructing or not)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Test map uploaded.

Well, I think I'm the coder for your custom map, LOL..

Please edit the code to this:

  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • LastBuilding[(Player number of (Triggering player))] Not equal to No unit
      • Then - Actions
        • Unit - Kill LastBuilding[(Player number of (Triggering player))]
        • Set LastBuilding[(Player number of (Triggering player))] = No unit
      • Else - Actions
        • Set PlayerGroup = (Player group((Triggering player)))
        • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
        • Sound - Play Error <gen>
        • Custom script: endif
        • Game - Display to >>>>>PlayerGroup<<<<< the text: You have destroyed ...
        • Custom script: call DestroyForce(udg_PlayerGroup)
That way, it only play Error Sound for only that player
Use Custom script, type that functions yourself, just copy it

Also, I forgot to use PlayerGroup variable in showing the message
 

Attachments

  • Map.w3x
    67.5 KB · Views: 63
Level 2
Joined
May 31, 2012
Messages
16
LOL seems so... I actually have alot I cant seem to get, and its probably because they need a custom script on it.

How long did it take you to be comfortable making new maps, and how did you learn it?
Did you keep asking question on the forums or did you just read the tutorial?

Oh and how did you get the JASS commands so I can start making my own.
 
Level 2
Joined
May 31, 2012
Messages
16
By the way... This trigger you made seems so hard for me to understand how it works lol
So if its okay, can you explain it? I cant see any "last created unit" on it or anything that would involve the last building to be destroyed.

I want to be able to make my own not just keep getting someone else's trigger on my map


Edit: Im starting to see how it was made, you used the variable LastBuilding to Constructed Structure
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
To start off, I learned few things and always keep asking questions to moderators and such (through Private Message, mostly)

And some tutorials, lessons and advices from threads to threads

You can use the 'Search' button up there to search whatever you like, first, start off with simple triggering, then go to moderate ones, and lastly, you'll be able to create a MUI trigger

There are many tutorials at this Hive, just search for it :)

Get used to Object Editor and know every possible spells that can solve many problems at instant

On to the trigger;
Custom script is simply a JASS built-in function in GUI which allows you to manually call a function that is not normally within GUI capabilities

It's not for you yet to learn Custom script function to its finest, just focus on removing leaks and you'll be fine

There 2 different things on triggers; Systems | Spells

Well, this thread is focused on Systems not Spells, you have to truly understand the nature of these two concepts before making a decision to trigger it

I can't really explain each trigger that I did in that test map, but I'll do my best

  • Set Last Building
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set LastBuilding[(Player number of (Triggering player))] = (Constructed structure)
In this trigger, I used "Finishes construction" as my Event to catch the last finished structure and save it in a Unit variable (for future usage, to kill it)

You cannot use the (Last created unit) because the building is not "created", but more or less "constructed", therefore your event plays important role

I used an array variable of LastBuilding because I want to save each Player's Last Building (in other words, they call this MPI - Multi-player Instanceability (12 units each 1 from 12 players can cast fire the trigger without bugging it))


  • Cancel Last Building
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Cancel Farm
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LastBuilding[(Player number of (Triggering player))] Not equal to No unit
        • Then - Actions
          • Unit - Kill LastBuilding[(Player number of (Triggering player))]
          • Set LastBuilding[(Player number of (Triggering player))] = No unit
        • Else - Actions
          • Set PlayerGroup = (Player group((Triggering player)))
          • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
          • Sound - Play Error <gen>
          • Custom script: endif
          • Game - Display to PlayerGroup the text: You have destroyed ...
          • Custom script: call DestroyForce(udg_PlayerGroup)
To kill the last building, we need a Spell to fire the Event (check the Event, I used "Starts the effect of an ability") and some Conditions to only respond if that ability is "Cancel Farm", only then the trigger would fire

On to the condition, if my saved variable is still a valid unit (I did not kill my last building yet), therefore the trigger will kill my last building and set it to "No unit"

This is to give a warning message for a player that activates the ability twice and have none left for his "last building" because he has destroyed it

The function GetLocalPlayer() is a special function which is used to do things that is only affected by the player

Meaning, the "Error" sound will only be heard by that activating unit, others cannot hear it

An unproper usage of this function will cause the game to desync and will cause disconnections among players


That's all I should say, oh and to answer this;
How long did it take you to be comfortable making new maps, and how did you learn it?
6 months more or less

Oh, I did not create maps, I just designed systems and spells for others, I am mainly not a Map Creator, but a Spell Maker or System Maker
I did not have any creative idea how to make the map interesting whatsoever, that's my weakness :(

And, practice makes perfect :)
 
Level 2
Joined
May 31, 2012
Messages
16
Hey, its me again lol, sorry but I just found a problem with the trigger.

Can you make the "Cancel Farm" Ability to cancel the farm during or after construction, just the last constructed structure the unit build. I tried editing the trigger myself but I fail at it.

I tried this way lol.
I tried setting the "LastBuilding" array to 2 but wasnt working.
I clearly do not understand how to use an array in this way.
  • Set Last Building
    • Events
      • Unit - A unit Begins construction
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set LastBuilding[(Player number of (Triggering player))] = (Constructed structure)
      • Set LastBuilding[(Player number of (Triggering player))] = (Constructing structure)
 
Status
Not open for further replies.
Top