Gas Bonus

MissKerrigan

Active Member
Hi Guys,

I made a map where you have a hero in the forest (envoirement with a lot trees)
In this forest appears critters at several times which you must find and kill to earn gas
Now I want make a trigger that a gas box appears in the forest in a random location and disappears after like 30 seconds if it's not found by a player
Now if a player find the gas box (bring hero to it) you must earn a bonus of 10 gas and the gas box must disappears also because you got the bonus
This gas box (bonus) must be appears every 5 minutes, so 4.30 minutes after the box disappeared
But there is an exeption, if a player found the gas box and earn the bonus, the gas box must come already after 1 minute again

How do I make this trigger?
Can anybody help me with this?

With 'gas box' I mean the unit 'gas (natural)


MissKerrigan
 

GFreak45

I didnt slap you, i high 5'd your face.
You could do something to this effect:

Trigger:
  • Random Gas Container
    • Events
      • Periodic Event - Every 300.00 seconds (5 mins)
    • Condition
    • Local Variables
      • Point Temp_Point = Random Point in (Region) (whatever region covers the area you want it in)
      • Item Temp_Item
    • Actions
      • Item - Create 1 (item) at Temp_Point
      • Set Temp_Item = Last Created Item
      • Wait 30.00 seconds
      • Item - Destroy (Temp_Item)


there may be some variations but that should give you the gist of it, thats switching from GUI World Editor (wc3) to the GUI SC2 Editor
 

Kyuft

Member
Also, You could make Temp_Item a global variable and make another trigger that look somewhat like this:
Trigger:
  • Trigger
    • Events
      • Unit is created
    • Conditions:
      • Unit Type of Unit = (item)
    • Local Variables
    • Actions
      • Attach region to (item)

then Make t=one like this:
Trigger:
  • Trigger:
    • Events:
      • Any Unit is killed/destroyed
    • Conditions:
      • Unit type of Triggering Unit = (item)
    • Local Variables:
    • Actions:
      • Remove Region (region attached to unit)

If you do this, you should change the trigger that GFreak45 put.
Create 2 Global Timers with no default.
Create Trigger:
Trigger:
  • Trigger:
    • Events:
      • Map initialization
    • Conditions:
    • Local Variables:
    • Actions:
      • Set (the first timer) 300 repeating

Now, Make the events for the trigger from GFreak.
Remove the Periodic one and add one that says this:
If (first timer) ends
Actions:
If:
Unit Enters Region (the region around the gas)
Then:
Modify Player Property (Minerals) +10
Stop (first timer)
Destroy (gas item)
Set timer (the second one) = 100 oneshot
Else:

Lastly, Make another trigger like this:
Trigger:
  • Trigger:
    • Events:
      • (second timer) ends
    • Conditions:
    • Local Variables:
    • Actions:
      • Set (first timer) 300 repeating
 

GFreak45

I didnt slap you, i high 5'd your face.
Sorry Kyuft but that was less efficient and more work... he should just use a regular object editor item that is used on pickup with 1 charge to give resources... as far as the making a timer at initialization, thats the exact same thing that the periodic event does, but its more efficient to use a periodic event because there is a difference, the event uses the code part of the timer as the way to run the code, the timer variable does not, so your way it is running a trigger every 300 seconds, my way it is only running a simple line of code
 

Siretu

Starcraft 2 Editor Moderator
Staff member
Unfortunately, in this case I think you're wrong GFreak. Using timers is more efficient than using the periodic event, at least according to my recent testing.

You're welcome to try both(but with a period of something small like... 0.01 instead of 300) and checking the trigger debug window.

After running 1m30s(game-time), the timer has a total elapsed trigger time of 5.009ms while your periodic event has a total elapsed trigger time of 7.472ms.
 

GFreak45

I didnt slap you, i high 5'd your face.
maybe the timers are different than in WC3 (not just in another language)
IE:
JASS:
call TimerStart(CreateTimer(), 300, true, function ActionFunc);

should be more efficient than:

local trigger t = CreateTrigger()
local timer ti = CreateTimer()
call TimerStart(ti, 300, true, null)
call TriggerRegisterTimerExpireEvent(t, ti)
call TriggerAddCondition(t, Filter(function ActionFunc))
set t = null
set ti = null


but in SC2 i guess it should look more like this:

JASS:
TimerStart(CreateTimer(), 300, true, function ActionFunc)

should be more efficient than:

trigger t = CreateTrigger();
timer ti = CreateTimer();
TimerStart(ti, 300, true, null);
TriggerRegisterTimerExpireEvent(t, ti);
TriggerAddCondition(t, Filter(function ActionFunc));
t = null
ti = null


but i guess it must compile different in the SC2 system, i think they re-did timers
 

Kyuft

Member
Well, I posted because I thought that your post didn't cover it all. First off, you didn't mention how the unit gets the gas if it gets near the geyser. You didn't make the geyser explode if someone got near. Lastly, You didn't make it so that if a geyser is found, it will drop the time between the next down to 100 instead of 500.

-Kyuft:shades:
 

GFreak45

I didnt slap you, i high 5'd your face.
ahh i missed that line about the 1 min if someone picks it up
nvm kyuft, my bad

other than that,

i said it should be an item, so if someone picks it up they... i mean MsKerrigan knows enough to do that part, they even had vespene gas/crystal boxes in the game, she could just change the model of it, nothing has to "explode"
as far as the geyser, who ever said anything about that but you? ...
the op didnt include anything about a geyser

oh wait
you are refering to the gas as a geyser? nvm again
 

MissKerrigan

Active Member
I created the trigger like Gfreak shown in the second reply but there is another problem!

When I move my hero to the location, the box disappears and I get 10 gas like I thought so but:

When I move my hero to that location again and again I keep getting +10 gas without there is any bonus in the location!
But I know this is because the location is still at the place where the bonus was but how can I trigger that the action only shoots when there is a bonus in the bonus location?

Pls don't explain this with variables, I know it's possible without variables

Can't I just create a timer which is 300 seconds and when hero find the bonus, I destroy timer window and create a new one which is 60 seconds right after?
The point is, if you find the bonus, there is another bonus already after 1 minute because for finding the bonus you get awarded

Help pls

MissKerrigan
 

MissKerrigan

Active Member
I seen your post and tried it, but I never said something about killing/destroying (item)

If your hero arrives at the bonus, the bonus must just disappear and a 'text message' with 'bonus 10 gas!' must be appear
So I try a trigger:

Event: unit enters region (bonus region)
Condition: unit type is 'hero'
Action: create text message 'bonus 10 gas!'
Action: remove 'item'

But here comes the problem!
Untill the next 'item' appears the location keeps hanging at the place where the last bonus was
So every time when I move my hero to there, I'm getting a bonus of 10 gas, this is wrong!

Does anybody know how to fix this?

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Staff member
Here's what I would do. There's several problems with the other solutions suggested so I made my own.

First of all, you'll need a timed life behavior. Go into the data editor and copy the "Changeling (Timed Life)" behavior. Rename it into "Gas Box (Timed Life)" and change the duration to 30.

Secondly, create a new region in the editor. Make it a circle region and change the radius to something nice like... 2. Make sure this region is in a place where the hero can never go. Call the region "GasRegion"

Okay, time for the triggers. I have the following variables.

Gas_Timer = (New timer) <Timer>
Gas_Timer 2 = (New timer) <Timer>
Gas Box = No Unit <Unit>

First of all, we start the standard timer.
Trigger:
  • Map Initialization
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Timer - Start Gas_Timer as a Repeating timer that will expire in 300.0 Game Time seconds


Then if one of the timers expire, we want to create a new gas box. "*Your Region*" is the region where the gas can spawn.

Trigger:
  • Gas Timer Expires
    • Events
      • Timer - Gas_Timer expires
      • Timer - Gas_Timer 2 expires
    • Local Variables
    • Conditions
    • Actions
      • Unit - Create 1 Gas (Neutral) for player 0 at (Random point in *Your Region*) using default facing (No Options)
      • Region - Move GasRegion to (Position of (Last created unit))
      • Variable - Set Gas Box = (Last created unit)
      • Unit - Add 1 Gas Box (Timed Life) to (Last created unit) from (Last created unit)


Finally, create the trigger that is executed when a unit comes close to the gas box. Make sure "*SAFE_POINT*" is a point where the hero can never get to:

Trigger:
  • Acquire Gas
    • Events
      • Unit - Any Unit Enters GasRegion
    • Local Variables
    • Conditions
      • ((Triggering unit) is Required: Heroic; Excluded: Missile, Dead, Hidden for player 1) == True
    • Actions
      • Text Tag - Create a text tag with the text &quot;Bonus 10 gas!&quot; for (All players), using a font size of 24, at (Position of (Triggering unit)) and height offset 1.0, initially Visible, and fog of war enforcement set to False
      • Text Tag - Set Duration time for (Last created text tag) to 1.3 seconds
      • Unit - Kill Gas Box
      • Region - Move Region 002 to (*SAFE_POINT*)
      • Timer - Start Gas_Timer 2 as a One Shot timer that will expire in 60.0 Game Time seconds


I might've forgot something, but this should be correct.
 

MissKerrigan

Active Member
Understand almost all now Siretu but only 1 thing keeps challenging me:

In the last trigger your 3th action is 'kill gas box'
I found this is impossible because 'gas box' is not in the 'unit value list' when trying to find it
So how I actually can kill(remove) the gas box when a player find the bonus?

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Staff member
Understand almost all now Siretu but only 1 thing keeps challenging me:

In the last trigger your 3th action is 'kill gas box'
I found this is impossible because 'gas box' is not in the 'unit value list' when trying to find it
So how I actually can kill(remove) the gas box when a player find the bonus?

MissKerrigan

It is not in the unit value list. It's a variable.
 

MissKerrigan

Active Member
How do I make this unit a variable?
Sorry, but variable is the worst part I know about the sc2 editor

Can you show me how to make this?

Thx anyway

MissKerrigan
 

Kyuft

Member
Making a variable is easy. First off, a Global variable is the first one I will talk about. It is a variable that you can reference with as many triggers as you want. A Local Variable can only be referred to by the trigger that it is in. Local Variable are found here:
Trigger:
  • Trigger
    • Events
    • Local Variables *RIGHT HERE*
    • Conditions
    • Actions

Make a Local Variable just like you would an event of action.

Go to the trigger editor, right-click in the sidebar that lists all of the triggers. Click New... or Add New... and select Variable. Now, put the variable type to unit for the Gas Box one, and Timer for the Gas_timer and Gas_Timer 2.

Now, if you want a parameter to refer to one of the variables, up at the top there will be check boxes . There is Custom, Function, Preset, etc. Select the Variables one. Then select your variable. Your variable will only show up if it can be applicable to the parameter. For example, if the parameter want a unit, the timer variable will not show up under the Variables tab.

Please +rep if I have helped you in any way!
-Kyuft:shades:
 

MissKerrigan

Active Member
I create new variable and select 'unit' in it, but where can I pick the gas box?

How do you add pictures in a treath?

MissKerrigan
 

Kyuft

Member
You just leave it blank (or no value). Later on in the triggers, Siretu make an action that sets the variable as Gas Box.
If you want to put pictures in a thread, you have to first post your image on a website. IMGUR is the best IMO.

-Kyuft:shades:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Test!
  • tom_mai78101 tom_mai78101:
    I must be in a test server.
  • tom_mai78101 tom_mai78101:
    Nice, Twitter tweets embedding now works
  • Wizard Wizard:
    Yup.
  • Ghan Ghan:
    Excellent.
  • Ghan Ghan:
    @tom_mai78101 Hello there.
  • Ghan Ghan:
    Tagging works in the chat too.
  • tom_mai78101 tom_mai78101:
    @Ghan Missed it.
  • Wizard Wizard:
    Still fixing things here and there. Added widgets to the portal, will make it match the ones here on the forum index tomorrow.
  • Ghan Ghan:
    The venerable World Editor Tutorials site has been converted to HTTPS at last.
  • jonas jonas:
    cool
  • jonas jonas:
    and I can even edit my messages, nice
  • seph ir oth seph ir oth:
    GENERAL CHIT CHAT, YOU ARE A BOLD ONE
  • Ghan Ghan:
    Hello there
  • The Helper The Helper:
    this new chatbox is great and the forum software update is great too
    +1
  • The Helper The Helper:
    upgrade has fixed forum registration spam problem
  • tom_mai78101 tom_mai78101:
    Something tells me we might be able to customize the chatbox a bit, considering that there's a gap under every message.
  • Wizard Wizard:
    Going to deploy a fix soon, just had to take some time for myself this weekend.
  • Varine Varine:
    Unbelievable. Time for yourself? How dare you!
  • Wizard Wizard:
    xD
  • tom_mai78101 tom_mai78101:
    Hm, it is now harder to type anything on an Android phone. Pressing Backspace or Enter keys will dismiss the Android keyboard for some reasons.
  • tom_mai78101 tom_mai78101:
    Just noticed there's a delay of at least 2 minutes before each post. Guess I can't post Headline News quickly as I used to.
  • tom_mai78101 tom_mai78101:
    As far as I can tell, there are definitely things I need to get accustomed to first.
  • Varine Varine:
    FCC is cracking down recently

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top