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

ammo/clip count system

Status
Not open for further replies.
Level 2
Joined
Aug 13, 2011
Messages
10
ive been looking around and haven't found a tread like this yet soo....
is there a way make the resources is SC2 become like the ammo/clip count form Notdam in w3? i think there is i just wanna see if anyone has found out how before i spend days at trying to make one?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
This is very easy in SC2. No more messing around with the trigger editor for you!
Simply add a Cost - Technology Resource Cost value to the weapons you want to have costing resource.
This will automatically deduct resources every attack. If the player does not have enough resources then the unit will be unable to fire the weapon (and thus attack). Negative values can even be used to regenerate ammo.

A weapon provides a unit with an attack option. Weapons are their own separate catalogue type in the data editor. Their purpose is to create an attack option which will fire a certain effect chain on every attack (this may or may not deal damage).
 
Level 2
Joined
Aug 13, 2011
Messages
10
pt2

hey thanks! that make things really easy from now on! which brings up the second part of the question: when resources hit "mineral" resouces hit 0 how can i subtract one "vespian" to make the "minerals" go back to 50

thanks in advance for the help!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
If you are immitating the clip system from various WC3 maps... Then this is also doable.

A way using the data editor alone probably exists however that is probably overly complicated and bug prone. I would advise using trigger script for this.

The socekt you want to hook the trigger to (via an event) is the player property change. For efficiency hook it to minerals amd gas on players which are effected by this ammo system (everyone will do fine if no other players use minerals or gas). The trigger handler function should then check if minerals is 0 for the effected player. If minerals are 0, you need to then check if gas for the player is larger than 0. If gas is larger than 0, simply add 50 minerals to the player and remove 1 gas from the player.

This will work even if gas is 0 and minerals is 0 and you gain new gas because it would still check minerals and deduct any gas you gain to replenish it (as the trigger fires when you gain gas as well). A smaller scope solution does exist but that adds extra triggering complexity for minimal gain (as it is performance will not be a problem for this).

As for reload delay...

You have 2 choices.
1. Use waits in the trigger after gas is removed but before minerals are added. Unlike WC3, waits in SC2 are accurate. Just simply inseart a reload dealy (possibly from an array mapping player slots to delays) into the wait. This method would eat threads and you would have to add some check to stop the trigger firing multiple times if gas is gained during a reload.
2. A system involving timers. Saves threads from being put onhold but adds extra trigger and code complexity.

Note that both methods are limited to the game frame rate in accuracy. That is iternal frame rate of 10-15 frames per second and not graphic frame rate (which interpolates results between internal frames).

You might want to turn off the check trigger when chancing player attributes inside the trigger handler. It might otherwise cause an infinite loop (as the trigger could fire itself).
 
Level 27
Joined
Jul 6, 2008
Messages
11,326
This is how I imagine how you can do the "clip reload" command:

There is an ability that costs 1 clip resource and -[ammo amount], it's "effect instant (Or effect no target, I don't remember)", and so when unit casts it the ammo count is restored at cost at the one ammo clip. You can use upgrades to change amount of ammo added on each reload.
 
Level 2
Joined
Aug 13, 2011
Messages
10
This is how I imagine how you can do the "clip reload" command:

There is an ability that costs 1 clip resource and -[ammo amount], it's "effect instant (Or effect no target, I don't remember)", and so when unit casts it the ammo count is restored at cost at the one ammo clip. You can use upgrades to change amount of ammo added on each reload.

hey thanks that will help when i make my machine gunner hero ^^
also this is kinda related but: in the weapons section of the data tab:Weapons:(selected Weapon):Stats:period

period is related to how fast a unit fires one shot right? so then whats equated to real world time. so what im asking is 1second in real time is how many periods or is that a 1:1 ratio?

@Dr super good
i follow you untill
The trigger handler function should then check if minerals is 0 for the effected player. If minerals are 0, you need to then check if gas for the player is larger than 0. If gas is larger than 0, simply add 50 minerals to the player and remove 1 gas from the player.

should i put in a actual "function" or did i miss a builtin trigger/condition?

captur10.png
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Obviously it has to be in a function, how else do you plan to hook a trigger to run that script...

In GUI it is porbably a trigger you are after as GUI probably does not support triggers very well.

Period is how many seconds between shots. Do be aware that this is game time and not real time. In faster game speeds, 1 game time second is less than 1 real time second. The opposite is the case for slower game speeds.
 
Level 2
Joined
Aug 13, 2011
Messages
10
hey i dont exactly think this is what u meant but my brain isnt working atm:goblin_jawdrop: ... but i tested this trigger and it works :) i just need to add the as you suggested "reload" timer.


my next question is should: do you see any forseeable bugs?
captur11.png
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Simply add 1 event for each player. Then instead of modifying player 1's resources, modify triggering player's resources.

Also cache triggering player in a local and use that as it redurces coupling.

Also that trigger will bug in the case the player has 0 gas and 0 minerals as he will not gain minerals even if he gets some gas.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Tleno, the problem is there are no validators for resource quantity. Yes your idea would work but what would stop the player casting the ability 7 or 20 times to convert all his gas (clips) into minerals (rounds) so he never has to reload? Also you have to remember that a force reload ability must also clear the remaining minerals (rounds) as you are meant to be changing a partially or fully used clip for a new one (any remaining rounds in it are lost).
 
Level 27
Joined
Jul 6, 2008
Messages
11,326
Tleno, the problem is there are no validators for resource quantity. Yes your idea would work but what would stop the player casting the ability 7 or 20 times to convert all his gas (clips) into minerals (rounds) so he never has to reload? Also you have to remember that a force reload ability must also clear the remaining minerals (rounds) as you are meant to be changing a partially or fully used clip for a new one (any remaining rounds in it are lost).

Oh right... well I guess then this could be done: ability costs only 1 gas, and when you use it your Minerals are set to [Insert amount here].
 
Status
Not open for further replies.
Top