Unit Morphing at selectable location
Posted: 12 Mar 2012, 10:37
This issue relates to Conflict Terra, Issue 207
Concept:
Essentially the idea is that a unit can be given the order to morph into another unit, but to do so at a specific location. The location is also checked for being a valid location for the resulting unit to be created (i.e. if you morph into a ship, did you specify a location in water).
This could be used in instances beyond that envisioned for CT. For example, to ability to create a unit that acts like a construction kit, deploying into a structure.
Problem:
I am a bit lost as to what would be the best approach for tackling this. As per Sanada's suggestion in the link, I want to approach this as two separate items, namely a unsynced widget (for selecting the morph location) and a synced gadget (for (re-)checking the validity of the placement, and issuing the resulting move/morph order).
That way it is more modular and more in line with what I understand the coding approach to be.
I've taken a look at the current morph code, as well as some widgets from the widget library that display some form of ghosted image (Got "Show Build" and "Ghost Site" as examples).
I'm a bit overwhelmed at the moment by it all, so let's just start off with which (if any) of these options is better.
Approaches:
1. Widget uses current build system
1.1 Ties into build menu (Make the morph choices build-able unit/structure options, with the morphing unit essentially a constructor).
1.2 Intercepts such 'build' commands, removing them and calling the gadget with the "morph into ID" and the "morph at coordinates/orientation" data.
[Easier? Current build system will allow for image ghosting and placement testing.
Hacky?
Support for multiple morph possibilities with pictures, maybe?]
2. Widget defines new command
2.1 Ties into command menu [could this tie into the build menu? I.E. brings up a 'buildlist' of morph choices?]
2.2 Requires user to then specify location
2.3 Displays ghost image at location, with orientation changeable as with normal building.
2.4 [Does possible validation check of location?]
2.5 Passes data to gadget.
[More work?
Limited?]
3. Gadget as command queuer
3.1 Validates target location
3.2 Adds move command to morphing unit's queue.
3.3 Adds existing morph command to morphing unit's queue.
[Possible problem with unit that fails to reach destination?
Very Hacky?
Easy?]
4. Gadget as new single command
3.1 Validates target location
3.2 Adds single command to morphing unit's queue, namely: Morph at location
3.3 New command requests a move command to location (inserted before itself into queue)
3.4 When new command tries to execute (I.E. presumably because destination was reached) it first check location, and re-issues move command if not. [Possible limit on re-issues?]
3.5 If at location, issues morph command with orientation.
[More work?
Feasible?]
Disclaimer:
I've got minimal lua experience, so stupidity in above approaches is likely.
Other:
Suggestions of more examples I can look at would be welcome.
I'll probably start with the widget, and work on it until it can spit out a debug message that correctly gives [unitID, unitDefID, x, y, z, orientation, teamID], then I'll tackle the gadget side.
Concept:
Essentially the idea is that a unit can be given the order to morph into another unit, but to do so at a specific location. The location is also checked for being a valid location for the resulting unit to be created (i.e. if you morph into a ship, did you specify a location in water).
This could be used in instances beyond that envisioned for CT. For example, to ability to create a unit that acts like a construction kit, deploying into a structure.
Problem:
I am a bit lost as to what would be the best approach for tackling this. As per Sanada's suggestion in the link, I want to approach this as two separate items, namely a unsynced widget (for selecting the morph location) and a synced gadget (for (re-)checking the validity of the placement, and issuing the resulting move/morph order).
That way it is more modular and more in line with what I understand the coding approach to be.
I've taken a look at the current morph code, as well as some widgets from the widget library that display some form of ghosted image (Got "Show Build" and "Ghost Site" as examples).
I'm a bit overwhelmed at the moment by it all, so let's just start off with which (if any) of these options is better.
Approaches:
1. Widget uses current build system
1.1 Ties into build menu (Make the morph choices build-able unit/structure options, with the morphing unit essentially a constructor).
1.2 Intercepts such 'build' commands, removing them and calling the gadget with the "morph into ID" and the "morph at coordinates/orientation" data.
[Easier? Current build system will allow for image ghosting and placement testing.
Hacky?
Support for multiple morph possibilities with pictures, maybe?]
2. Widget defines new command
2.1 Ties into command menu [could this tie into the build menu? I.E. brings up a 'buildlist' of morph choices?]
2.2 Requires user to then specify location
2.3 Displays ghost image at location, with orientation changeable as with normal building.
2.4 [Does possible validation check of location?]
2.5 Passes data to gadget.
[More work?
Limited?]
3. Gadget as command queuer
3.1 Validates target location
3.2 Adds move command to morphing unit's queue.
3.3 Adds existing morph command to morphing unit's queue.
[Possible problem with unit that fails to reach destination?
Very Hacky?
Easy?]
4. Gadget as new single command
3.1 Validates target location
3.2 Adds single command to morphing unit's queue, namely: Morph at location
3.3 New command requests a move command to location (inserted before itself into queue)
3.4 When new command tries to execute (I.E. presumably because destination was reached) it first check location, and re-issues move command if not. [Possible limit on re-issues?]
3.5 If at location, issues morph command with orientation.
[More work?
Feasible?]
Disclaimer:
I've got minimal lua experience, so stupidity in above approaches is likely.
Other:
Suggestions of more examples I can look at would be welcome.
I'll probably start with the widget, and work on it until it can spit out a debug message that correctly gives [unitID, unitDefID, x, y, z, orientation, teamID], then I'll tackle the gadget side.