Page 1 of 1
attackable ghosted buildings
Posted: 29 Nov 2011, 22:19
by knorke
When you get los on a unit/building and then lose los, you get this transparent shape where you saw the building.
Now I would like these shapes to be attackable, like normal units.
(atm rightclick on the transparent shape results in a move order)
To be precise it is for mineable minerals: those can not be "always visible" because then you can see where enemy players are harvesting resources just by seeing the minerals lose health/shrink smaller.
If minerals obey normal los rules, it is annoying that you first have to get los on them before telling a miner to harvest.
So I want it to be basically like in starcraft where you could see minerals everywhere and when you got los on mined-out minerals, they would disappear.
Ideas:
1) each mineral gets a fake unit (one per ally team) linked with it, lua makes it visible for the players as needed.
2) transform move-commands given at mineral-ghosts into attack-commands with screentrace mouse coordinates bla and manually setting tooltip etc.
Both seems pretty meh and I also vaguely remember something similiar was already done?
fun fact:
iirc in sc you could tell if minerals where still there by telling peons to harvest them. They would drive there in both cases but with slightly different behaviour...
Re: attackable ghosted buildings
Posted: 30 Nov 2011, 10:20
by Google_Frog
I thought a bit more about this and I think I have a robust and complete solution. It's basically a lot of 'fake' units without a real unit.
Each mineral 'unit' is implemented as a fake unit that is only visible and interactable with a single allyTeam. These are linked by a unit that only exists implicitly as a lua data structure.
The minerals basically exist like this:
Code: Select all
minerals = {
[mineralID] = {
units = {
[allyTeam] = unitID,
...
}
health = number
},
...
}
MineralID is just an internal thing, can be ordered 1 2 3 4 etc.
Each mineral knows it's real health and the unitIDs of units that represent it. You also need a table of fake minerals by unitID that points the fake unit back to it's mineralID and appropriate allyTeam.
Code: Select all
fakeByID = {
[unitID] = {
mineralID = number,
allyTeam = number
},
...
}
When a fake unit is damaged it should update it's mineralID's health. ie
minerals[fakeByID[attackieeID].mineralID].health = attackiee health
Fake units undergo health change iff either of these things happen:
- They enter the LOS of their associated allyTeam (and their health is not equal to mineralID health)
- mineralID health changes and they are within the LOS of their associated allyTeam
Health change also covers unit destruction. Fake units are not destroyed until they enter LOS (this is where the initial idea of merely transferring the attack command fails).
One or more of these fuctions should provide all the visibility manipulation required to make this work. If an always visible unit messes up gadget:UnitEnteredLOS then another fake unit can be used. This unit could be visible to all allyTeams and exist solely to trigger gadget:UnitEnteredLOS.
Code: Select all
Spring.SetUnitAlwaysVisible
Spring.SetUnitLosMask
Spring.SetUnitLosState
So I think I have covered everything. It looks fairly simple to implement although some testing is required to figure out how the relevant functions work. I'm pretty sure this method has no method of gaining information outside LOS.
Re: attackable ghosted buildings
Posted: 30 Nov 2011, 11:38
by knorke
MineralID is just an internal thing, can be ordered 1 2 3 4 etc.
I would rather make the mineral a real unit:
It would obey normal LOS-rules and be the unit that is visible to the player by having a real model.
So the fakeunits would be there just to provide a click-target and to be visible on minimap. Rest would work as you described.
Re: attackable ghosted buildings
Posted: 30 Nov 2011, 13:20
by Niobium
It all depends on how the units are going to interact with the 'minerals'. Through reclaiming? Through attacking/damage? Completely through lua? I think fake units is a bad idea, and definitely avoidable.
Re: attackable ghosted buildings
Posted: 30 Nov 2011, 14:28
by Google_Frog
knorke wrote:MineralID is just an internal thing, can be ordered 1 2 3 4 etc.
I would rather make the mineral a real unit:
It would obey normal LOS-rules and be the unit that is visible to the player by having a real model.
So the fakeunits would be there just to provide a click-target and to be visible on minimap. Rest would work as you described.
This has issues:
- Engine Ghost shows all model pieces, you lose your 'at a glance' minerals remaining system.
- If the minerals are actually dead the player could determine that the attack command is not on the minerals.
In short what are the limitations of my design? Yours has the clear model piece limitation that will make it hard for players to track the progress of their own patches when the miner is not providing LOS. I don't understand the thought process here as you haven't said how my design won't work and you prefer the one with limitations.
Niobium wrote:It all depends on how the units are going to interact with the 'minerals'. Through reclaiming? Through attacking/damage? Completely through lua? I think fake units is a bad idea, and definitely avoidable.
The gathering mechanic is already implemented and works the same way as in CT. Miners damage minerals and nothing else can be done to minerals.
Re: attackable ghosted buildings
Posted: 30 Nov 2011, 14:46
by knorke
Through attacking/damage?
yup. (that part is done already)
Engine Ghost shows all model pieces, you lose your 'at a glance' minerals remaining system.
Yes, but it saves on pieceount. Just one mineralunit with 8 pieces instead of (in a 4 ffa) 4*8=32 pieces.
Seeing the minerals as complete and transparent outside LOS would be "ok" I think.
If the minerals are actually dead the player could determine that the attack command is not on the minerals.
attack commands would always be on the fakeunits.
I don't understand the thought process here as you haven't said how my design won't work
It is mostly a feeling that fakeunits will bring unforeseen problems because it seems a bit hackish/dirty. I will try it out in the evening anyway but wanted to look/ask for other ideas.
Re: attackable ghosted buildings
Posted: 10 Dec 2011, 15:56
by Google_Frog
Attached working system.
Re: attackable ghosted buildings
Posted: 10 Dec 2011, 16:21
by knorke