Heya. I'd like to have a pile of scrap metal that an SCV can harvest either "Scrap Metal" or "Components" out of. (Renamed from Minerals and Vespene, respectively.) The way I'm thinking of doing it is having the scrap metal pile act like a normal mineral patch, which also has behaviors on it that can be used to give the unit Components instead of Scrap Metal. (Say if you toggle or cast an ability, it can mimic mining, channel a certain amount of time, and then give the SCV the "Components" resource instead of "Scrap Metal".)
The problem is, that doesn't seem to be possible. The only way for a unit to gain resources is to mine them from a unit that has a resource behavior. There seems to be no way to just give the unit the resources via data.
You can use modify player effect if manually give the player the resources similar to mining, if im understand you correctly. Otherwise you would just use a buff system to duplicate the harvest ability.
I don't mean give it to the player. I mean give it to the SCV, as if the SCV had harvested something. Then the SCV can return it to a command center or something.
The behaviors for holding a resource don't seem to have any stat in them that has to do with the number of resources held. Mining a resource simply gives that behavior to the unit, while the resource that was mined specifies how much of the resource was mined. All that the "holding resource" behavior seems to do is attach a model of the held resource to the SCV's hands. (The actor is triggered by this behavior being activated and its removal is triggered by the behavior being removed.) There's something behind the scenes determining how much minerals the SCV has and something behind the scenes taking those minerals when the SCV returns them to a base.
So it seems like the only way to give a certain number of resources to a unit, is to have that unit mine a unit that has that number set for amount mined per trip. There's no way to just give minerals to an SCV that I can see unless the SCV mines something manually.
EDIT: I just realized one hacky way I could do it is use an invisible unit that acts like a mineral patch, but for the other resource. The behavior on the scrap heap could spawn a "component" which is invisible, and then order the SCV to mine it. The mining would be set to happen instantly. That's the only way I can think of right now to do this. I'm wondering if there's a more elegant way than that.
Don't know if this will help you any, but thought I'd throw it out there. In triggers there's an action "set unit property" and you can choose things like carried minerals and carried vespene.
I have it all worked out. I used the trigger mentioned above. But I had to do some things in addition to make it work right.
Normally, a behavior gets applied to the mining unit when it finishes mining, so that the unit carries a mineral crystal, etc. The behavior automatically gets removed when the unit drops off the resource. But if you set the resource manually, you also have to set the behavior manually. And if you set the behavior manually, you have to remove it manually as well.
So what I did is set a stack of behaviors on the resource node (Scrap Heap) called Components. The SCV has an ability that steals one of those Components behaviors. Then I have a trigger that fires if the SCV gains a Component behavior. The trigger removes it and gives the SCV 10 Components and the "Carrying Components" behavior that I created. I also have another trigger that fires if the Components resource the SCV is carrying are reduced to zero. (Drop off.) This trigger removes the "Carrying Components" behavior.
(The behavior itself doesn't do anything. But there is an actor that has a couple of events that fires based on a unit gaining the behavior. If any unit gains that behavior, the actor creates. If the unit loses the behavior, the actor destroys itself. Duplicate and modify the Carrying Minerals actor to suit your needs, since it already specifies the needed attachment point and such.)
Heya. I'd like to have a pile of scrap metal that an SCV can harvest either "Scrap Metal" or "Components" out of. (Renamed from Minerals and Vespene, respectively.) The way I'm thinking of doing it is having the scrap metal pile act like a normal mineral patch, which also has behaviors on it that can be used to give the unit Components instead of Scrap Metal. (Say if you toggle or cast an ability, it can mimic mining, channel a certain amount of time, and then give the SCV the "Components" resource instead of "Scrap Metal".)
The problem is, that doesn't seem to be possible. The only way for a unit to gain resources is to mine them from a unit that has a resource behavior. There seems to be no way to just give the unit the resources via data.
Is there a way to do this that I'm not aware of?
@Amaroq64: Go
You can use modify player effect if manually give the player the resources similar to mining, if im understand you correctly. Otherwise you would just use a buff system to duplicate the harvest ability.
I don't mean give it to the player. I mean give it to the SCV, as if the SCV had harvested something. Then the SCV can return it to a command center or something.
The behaviors for holding a resource don't seem to have any stat in them that has to do with the number of resources held. Mining a resource simply gives that behavior to the unit, while the resource that was mined specifies how much of the resource was mined. All that the "holding resource" behavior seems to do is attach a model of the held resource to the SCV's hands. (The actor is triggered by this behavior being activated and its removal is triggered by the behavior being removed.) There's something behind the scenes determining how much minerals the SCV has and something behind the scenes taking those minerals when the SCV returns them to a base.
So it seems like the only way to give a certain number of resources to a unit, is to have that unit mine a unit that has that number set for amount mined per trip. There's no way to just give minerals to an SCV that I can see unless the SCV mines something manually.
EDIT: I just realized one hacky way I could do it is use an invisible unit that acts like a mineral patch, but for the other resource. The behavior on the scrap heap could spawn a "component" which is invisible, and then order the SCV to mine it. The mining would be set to happen instantly. That's the only way I can think of right now to do this. I'm wondering if there's a more elegant way than that.
Don't know if this will help you any, but thought I'd throw it out there. In triggers there's an action "set unit property" and you can choose things like carried minerals and carried vespene.
Thank you. It seems like that's what I'll have to use for now. I wish we had access to that property in data too and not just triggers.
I have it all worked out. I used the trigger mentioned above. But I had to do some things in addition to make it work right.
Normally, a behavior gets applied to the mining unit when it finishes mining, so that the unit carries a mineral crystal, etc. The behavior automatically gets removed when the unit drops off the resource. But if you set the resource manually, you also have to set the behavior manually. And if you set the behavior manually, you have to remove it manually as well.
So what I did is set a stack of behaviors on the resource node (Scrap Heap) called Components. The SCV has an ability that steals one of those Components behaviors. Then I have a trigger that fires if the SCV gains a Component behavior. The trigger removes it and gives the SCV 10 Components and the "Carrying Components" behavior that I created. I also have another trigger that fires if the Components resource the SCV is carrying are reduced to zero. (Drop off.) This trigger removes the "Carrying Components" behavior.
(The behavior itself doesn't do anything. But there is an actor that has a couple of events that fires based on a unit gaining the behavior. If any unit gains that behavior, the actor creates. If the unit loses the behavior, the actor destroys itself. Duplicate and modify the Carrying Minerals actor to suit your needs, since it already specifies the needed attachment point and such.)