Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update repairer consumption when a unit dies #660

Closed

Conversation

aeoncleanse
Copy link
Member

Addresses #642

This fix is ready, but not perfect. The build bar state persists until the unit's self:Destroy() is called, so if anyone has an idea how to do that, please help out. @Crotalus?

This whole situation is a mess. For some reason, calling self:Destroy tells any repairing/capturing/assisting units to go to idle etc, or to the next thing on the queue, but self:Kill() does not. It simply links you to OnKilled in the lua, and appears to do engine checks for the unit's own consumption/building state, and for units in the guard state (Assisters), but ignores repairs.

However, since in the lua we sometimes hook into OnKilled with a long-lasting explosion, the delay between OnKilled and the final self:Destroy at the end of the sequence can be lengthy in some cases (UEF Quantum Gate, for example), with the Engineer continuing to repair and waste resources right to the end.

@@ -1211,8 +1226,8 @@ Unit = Class(moho.unit_methods) {
self:ForkThread(self.PlayAnimationThread, 'AnimationDeath')
self.DisallowCollisions = true
end

self:DoUnitCallbacks( 'OnKilled' )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please perform style changes like this in a seperate commit.

@Sheeo
Copy link
Member

Sheeo commented Jun 14, 2015

This fix is ready, but not perfect. The build bar state persists until the unit's self:Destroy() is called, so if anyone has an idea how to do that, please help out. @Crotalus?

This whole situation is a mess. For some reason, calling self:Destroy tells any repairing/capturing/assisting units to go to idle etc, or to the next thing on the queue, but self:Kill() does not. It simply links you to OnKilled in the lua, and appears to do engine checks for the unit's own consumption/building state, and for units in the guard state (Assisters), but ignores repairs.

You can't control unit order queues from lua, so unless you want to call Destroy() immediately (To invalidate the focus entity for the assister/repairer), there is no obvious workaround.

Overall I don't think this patch adds much except for additional mud to the pile that is repairing/assisting/consumption. I prefer a full rework of these odd algorithms that are in place.

The iteration of nearby ally units with Repairing state is highly suspicious, for one.

@aeoncleanse
Copy link
Member Author

I dont much like it either, but its a fairly major resource waste bug, and aside from being ugly this does fix it. If someone can find how to turn off the progress bar we are golden

@quark036
Copy link
Contributor

What if we sent the engi a move command to its current location?

@Sheeo
Copy link
Member

Sheeo commented Jun 27, 2015

You would need to issue a clearcommand first, which kills the order queue entirely -- since you can't introspect it within the sim, you can't reliably reconstruct it, unfortunately.

@aeoncleanse aeoncleanse force-pushed the repairdeathfix branch 4 times, most recently from 9ddfdee to 866b38d Compare June 27, 2015 14:25
@aeoncleanse
Copy link
Member Author

Well, that was easier to get working than I thought. Thanks Sheeo, Chris, for putting me onto IssueClearCommands() :D

@ChrisKitching
Copy link
Contributor

You can't control unit order queues from lua, so unless you want to call Destroy() immediately (To invalidate the focus entity for the assister/repairer), there is no obvious workaround.

This is probably the only way to actually handle this from lua: immediately destroy the unit and spawn an identical one with zero health in its place (which just does the whole blowing-up animation and so on).
We can't reach into native-code to manipulate the order queue, but orders referring to destroyed entities are dropped from the queue when reached.

There is likely a meaningful performance cost associated with doing this. I really don't think this bug is worth fixing for now.

@quark036
Copy link
Contributor

We could do it only for shields, as they are the most significant case (long death animation, likely to be being repaired).

@aeoncleanse
Copy link
Member Author

OK so, in this state we sit at:

The buildbeam turns off
The turret swings back, a little forced and fast but not a problem IMO
The build progress bar does NOT reset immediately
The unit doesn't move on to the next task until the death is completed

As you can see, it's possible to harvest the command table for the unit. However, I don't see any way to re-issue it in an identical state. We can issue individual commands, but not the queue for some reason. If we could, we could clear the queue then immediately re-issue it, and trust the engine to recognise the unit at the top of the list is dead now.

@Sheeo
Copy link
Member

Sheeo commented Jul 12, 2015

Needs rebase targeting debelop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants