Skip to content

Conversation

Luashine
Copy link
Collaborator

@Luashine Luashine commented Jul 21, 2024

This commit has the full testing code for the "delayed destructable height" bbe9760

Very much like in #148 , the created destructables delay their "final" position by one tick because it needs for the animation to play.

The why: when you create a destructable it initially spawns in its DEATH animation. If you ask the game for the Z height at that position in the same tick as spawned, it'll give you the value for the death animation height rather than alive animation that you expected

This is the map that does everything automatically and prints that Z results console. I've asked for people to run it in HD to compare against my SD results. I just want to confirm this for myself. Early on this was a major desync reason on Reforged release, actual model animations affected the surface elevation (if walkable destructable) and THAT caused different values between HD and SD players. I have no idea how they solved it exactly, but they did take agree on one value as far as I understand.

war3.w3mod\doodads\cinematic\elevatorpuzzle\elevatorpuzzle.mdx

because this SD model still has different animation heights when compared to HD. And then what if you trigger DIFFERENT animation variations, one that exists in HD but not in SD? I guess that's still a desync even today??

Feel free to review, but before merging please wait until someone has confirmed the test map output on HD.

PlatformHeightTest.zip


Result: It was manually merged

Luashine added 4 commits July 21, 2024 01:29
Full test code to showcase the desctructable animation delay that affects height immediately after creation:

```lua
-- HD Model: "Stand 1", "Death 1"
-- SD Model: "Stand", "Death"
function printLocOfUnit(u)
	local uX, uY = GetUnitX(u), GetUnitY(u)
	local loc = Location(uX, uY)
	printLocCoords(loc)
	RemoveLocation(loc)
end
function printLocCoords(loc)
	local x,y,z = GetLocationX(loc), GetLocationY(loc), GetLocationZ(loc)
	print(x,y,z)
end
function printUnitLocAndLoc(unit, staticLoc)
	local unitLoc = Location(GetUnitX(unit), GetUnitY(unit))
	local unitX,unitY,unitZ = GetLocationX(unitLoc), GetLocationY(unitLoc), GetLocationZ(unitLoc)
	local staticX,staticY,staticZ = GetLocationX(staticLoc), GetLocationY(staticLoc), GetLocationZ(staticLoc)
	print(string.format(
		"unitLoc: \037-9.4f,\037-9.4f,\037-9.4f; staticLoc: \037-9.4f,\037-9.4f,\037-9.4f",
		unitX,unitY,unitZ,
		staticX,staticY,staticZ
	))
	RemoveLocation(unitLoc)
end

testHeightTrig = CreateTrigger()
testHeightAct = TriggerAddAction(testHeightTrig, function()
	print("Creating footman and printing unitLoc & staticLoc:")
	local footman = CreateUnit(Player(0), FourCC("hfoo"), 0, -1024, 90)
	local staticLoc = GetUnitLoc(footman)
	
	printUnitLocAndLoc(footman, staticLoc)
	---
	print("Creating platform, then new unitLoc & staticLoc: (expect dead height)")
	local platform = CreateDestructable(FourCC("DTrx"), 0, -1024, 180, 1, 0)
	printUnitLocAndLoc(footman, staticLoc)
	---
	TriggerSleepAction(0)
	print("Sleep after platform creation: new unitLoc & staticLoc: (expect alive height)")
	printUnitLocAndLoc(footman, staticLoc)
	---
	TriggerSleepAction(3)
	print("Long Sleep after platform creation: new unitLoc & staticLoc: (expect alive height)")
	printUnitLocAndLoc(footman, staticLoc)
	---
	print("Killing destructable: (expect alive height)")
	KillDestructable(platform)
	printUnitLocAndLoc(footman, staticLoc)
	---
	TriggerSleepAction(0.5)
	print("Sleep after platform kill: new unitLoc & staticLoc: (expect dead animation)")
	printUnitLocAndLoc(footman, staticLoc)
	---
	TriggerSleepAction(3)
	print("Long Sleep after platform kill: new unitLoc & staticLoc: (expect dead height)")
	printUnitLocAndLoc(footman, staticLoc)
	---
	print("Removing destructable: (expect 0)")
	RemoveDestructable(platform)
	printUnitLocAndLoc(footman, staticLoc)
	---
	TriggerSleepAction(0)
	print("Sleep after platform removal: new unitLoc & staticLoc: (expect 0)")
	printUnitLocAndLoc(footman, staticLoc)
	---
	RemoveUnit(footman)
	RemoveLocation(staticLoc)
end)
TriggerExecute(testHeightTrig)
```
@lep lep closed this Jul 21, 2024
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.

2 participants