For the Tower Defense I've come across a problem: giving resources to the player. Since there is no PlayerSetResource() function yet, this is pretty hard. Here is a little recap of my findings.
The function MeleeInitResource gives the amount of mineral and vespene you want but it does it only one time. This is really strange but works that way. So it can't really be used.
Mineral
A way to get mineral is to gather it from a mineral field. I haven't managed to build a MineralField from a building. The solution is to make a unit gatherable. This is done adding those 3 lines inside UnitData.xml
Since you don't want your worker to get back and forth to the main building, you can set the worker to be a resource dropping site.
<ResourceDropOffindex="Minerals"value="1"/>
Now, the unit will act like a coin. You click on it, the worker will collect it and get money.
Spawn the unit
You can now order any AI to train the harvestable unit using that Galaxy line:
// player, priority, town, unit, countAITrain(2,1,0,"Larva",1);
In the Tower Defense perspective, it would be nice to have the mineral pop when the unit dies. It is possible! We are going to use the Zerg Building. There are many layers of XML to get this working, this is kinda complicated to edit it without the editor.
There is a <RequiredAlliance value="Control"/> field. However, the only possible values are (Passive, Vision, Control, Spend, Trade, SeekHelp, GiveHelp, Chat, Defeat, Pushable). None of them include being enemy.
It is possible to set an alliance between an AI and a player. The bad thing is that it cannot be done inside the map, you have to do through the launcher. And at the moment there is no command line launcher that is able to do it. Also, we don't want to be dependant from a particular launcher.
A possible lead would be to use an ability to take control of the enemy unit. However it would require too much interaction and many layers of XML.
Solution
Arthas- just gave me a solution: In the <CEffectCreateUnit node we can add this magic line:
<SpawnOwnerValue="Neutral"/>
This allow us to make a coin spawn on unit death. The unit will be neutral therefore harvestable. You can now give money to the player ! This involves many XML editing but it is possible and in an user friendly process.
Technically, it might be possible to auto span a unit on death that is then given an order to take the coin. I guss you could make it that the Pylon can right click through mineral coins, which would respond with a smart cast that spawns a mule like unit that is then ordered to gather target and then die a few seconds after.
You would need:
Autocast ability that call a "spawn unit" effect
Order spawned unit to pick up the gold (you can use mule spawn as basis for this, it is very easy)
give it a timed life of x seconds.
Hello,
For the Tower Defense I've come across a problem: giving resources to the player. Since there is no PlayerSetResource() function yet, this is pretty hard. Here is a little recap of my findings.
MeleeInitResource
The function MeleeInitResource gives the amount of mineral and vespene you want but it does it only one time. This is really strange but works that way. So it can't really be used.
Mineral
A way to get mineral is to gather it from a mineral field. I haven't managed to build a MineralField from a building. The solution is to make a unit gatherable. This is done adding those 3 lines inside UnitData.xml
You want to get the resources instantly:
Since you don't want your worker to get back and forth to the main building, you can set the worker to be a resource dropping site.
Now, the unit will act like a coin. You click on it, the worker will collect it and get money.
Spawn the unit
You can now order any AI to train the harvestable unit using that Galaxy line:
In the Tower Defense perspective, it would be nice to have the mineral pop when the unit dies. It is possible! We are going to use the Zerg Building. There are many layers of XML to get this working, this is kinda complicated to edit it without the editor.
Can't harvest enemy units
There is a
<RequiredAlliance value="Control"/>
field. However, the only possible values are (Passive, Vision, Control, Spend, Trade, SeekHelp, GiveHelp, Chat, Defeat, Pushable). None of them include being enemy.It is possible to set an alliance between an AI and a player. The bad thing is that it cannot be done inside the map, you have to do through the launcher. And at the moment there is no command line launcher that is able to do it. Also, we don't want to be dependant from a particular launcher.
A possible lead would be to use an ability to take control of the enemy unit. However it would require too much interaction and many layers of XML.
Solution
Arthas- just gave me a solution: In the
<CEffectCreateUnit
node we can add this magic line:This allow us to make a coin spawn on unit death. The unit will be neutral therefore harvestable. You can now give money to the player ! This involves many XML editing but it is possible and in an user friendly process.
Here is a little demonstration video:
You can test it adding the files attached inside the Tutorial
Look for the
comments in the following files: UnitData.xml, EffectData.xml, BehaviorData.xml and AbilData.xmlThat is awesome, i really like it :)
@vjeux: Go
Technically, it might be possible to auto span a unit on death that is then given an order to take the coin. I guss you could make it that the Pylon can right click through mineral coins, which would respond with a smart cast that spawns a mule like unit that is then ordered to gather target and then die a few seconds after.
You would need:
Autocast ability that call a "spawn unit" effect Order spawned unit to pick up the gold (you can use mule spawn as basis for this, it is very easy) give it a timed life of x seconds.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
Add a line to a unit : <KillResource index="Minerals" value="1"/>
is a better way.
o_O? So, when you kill the unit, it grants 1 Mineral? Is that how that function works?
Yep, I can confirm that this works.
Really nice. Thanks for the tip