I have, what seems like to me a simple problem, but given my understanding of the editor I cannot figure it out. My trigger is as follows: I need a trigger which can take items from the ground (after a button has been clicked on a building) and combine them, remove the items, and replace them with a new item, also on the ground. For example, if I have an armory which I will use to create an iron ingot, once the "Create Iron Ingot" button has been clicked, it will check that a metal scrap and a flint rock are within two range of the armory.
Basically my problem is that I don't know how to check that the required items (metal scrap and flint rock) are within two range of the armory. And then after that, how to delete those two items from the game, and how to create a new item within 1 range of the armory.
If there is any way for you to help me, it would be greatly appreciated!
It sounds like you want to keep track of your ingredients. I would use a Record called recIngredients and inside it setup something like the following:
intTimestamp - integer storing mission time when it was created
intType - integer ID of type (1= iron, 2 = gold, 3 = silver)
uUnit or aActor - reference to actual unit or actor on the map
Then create an array called recIngredients and make it big enough to hold all the ingredients you'll ever need to track. Also create a global variable called intNumIngredients. Now whenever you create an ingredient on the map, store it in the array and increment intNumIngredients.
Now that you have that basic data structure in the background, make sure it stays up to date and reflects the world state (the actual ingredients on the map). When you remove an ingredient, you'll need to loop through your array and check to see if the unit/actor matches. If it does, then generate a new ingredient and replace the old data with the new data. The editor doesn't have good array functions, so you'll have to write your own patterns to push/pop/sort.
Hope that makes sense. I highly recommend arrays of records...it's like having a database in the background. Record defines "columns", array defines "rows" and array indexes define "IDs".
Alright well the array idea sort of makes sense for tracking the items (I'm a little inexperienced with the trigger editor), so thanks for that! But I'm not really sure how to incorporate that into the calculation of the distance of the materials from the building that creates it. If anyone can explain this to me or provide a good tutorial it would really be appreciated!
Here is an example of counting marines 2 spaces away from the triggering unit.
Variable - MarineGroup = (Marine units in (Region((Position of (Triggering unit)), (((Unit type of (Triggering unit)) Radius) + 2.0))) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount)
Variable - Set marines in range = (Number of Living units in (MarineGroup))
Variable "MarineGroup" is of the type Unit Group.
Variable "marines in range" is of the type int.
so basicly after setting the needed variables with this you can do:
(This next bit is manually written and not copy/paste from the trigger editor)
if
Conditions
And
(marines in range>0)
....
Then
Actions
remove (random unit from unit group (marinegroup)) from the game
remove ....
Create 1 UpgradedMarine
Edit:
If you want to keep track of how many ingredients are ingame and where then what jcraigk says is better.
I have, what seems like to me a simple problem, but given my understanding of the editor I cannot figure it out. My trigger is as follows: I need a trigger which can take items from the ground (after a button has been clicked on a building) and combine them, remove the items, and replace them with a new item, also on the ground. For example, if I have an armory which I will use to create an iron ingot, once the "Create Iron Ingot" button has been clicked, it will check that a metal scrap and a flint rock are within two range of the armory.
Basically my problem is that I don't know how to check that the required items (metal scrap and flint rock) are within two range of the armory. And then after that, how to delete those two items from the game, and how to create a new item within 1 range of the armory.
If there is any way for you to help me, it would be greatly appreciated!
@DaBernMon: Go
It sounds like you want to keep track of your ingredients. I would use a Record called recIngredients and inside it setup something like the following:
intTimestamp - integer storing mission time when it was created
intType - integer ID of type (1= iron, 2 = gold, 3 = silver)
uUnit or aActor - reference to actual unit or actor on the map
Then create an array called recIngredients and make it big enough to hold all the ingredients you'll ever need to track. Also create a global variable called intNumIngredients. Now whenever you create an ingredient on the map, store it in the array and increment intNumIngredients.
Now that you have that basic data structure in the background, make sure it stays up to date and reflects the world state (the actual ingredients on the map). When you remove an ingredient, you'll need to loop through your array and check to see if the unit/actor matches. If it does, then generate a new ingredient and replace the old data with the new data. The editor doesn't have good array functions, so you'll have to write your own patterns to push/pop/sort.
Hope that makes sense. I highly recommend arrays of records...it's like having a database in the background. Record defines "columns", array defines "rows" and array indexes define "IDs".
Alright well the array idea sort of makes sense for tracking the items (I'm a little inexperienced with the trigger editor), so thanks for that! But I'm not really sure how to incorporate that into the calculation of the distance of the materials from the building that creates it. If anyone can explain this to me or provide a good tutorial it would really be appreciated!
@DaBernMon: Go
items on the ground are units.
Here is an example of counting marines 2 spaces away from the triggering unit.
Variable - MarineGroup = (Marine units in (Region((Position of (Triggering unit)), (((Unit type of (Triggering unit)) Radius) + 2.0))) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount)
Variable - Set marines in range = (Number of Living units in (MarineGroup))
Variable "MarineGroup" is of the type Unit Group.
Variable "marines in range" is of the type int.
so basicly after setting the needed variables with this you can do:
(This next bit is manually written and not copy/paste from the trigger editor)
Edit:
If you want to keep track of how many ingredients are ingame and where then what jcraigk says is better.
Thank you very much! That is exactly what I needed. Thanks for both of your help