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

Bug in Seats.as #2037

Open
mugg91 opened this issue Apr 25, 2024 · 1 comment · May be fixed by #2038
Open

Bug in Seats.as #2037

mugg91 opened this issue Apr 25, 2024 · 1 comment · May be fixed by #2038

Comments

@mugg91
Copy link
Contributor

mugg91 commented Apr 25, 2024

Description

Seats.as has:

void onAttach(CBlob@ this, CBlob@ attached, AttachmentPoint @attachedPoint)
{
	if (attachedPoint.socket)
	{
		attached.Tag("seated");
		Sound::Play("GetInVehicle.ogg", attached.getPosition());

		if (this.getDamageOwnerPlayer() is null) {
			this.SetDamageOwnerPlayer(attached.getPlayer());
		}
	}
}

void onDetach(CBlob@ this, CBlob@ detached, AttachmentPoint@ attachedPoint)
{
	if (attachedPoint.socket)
	{
		detached.Untag("seated");

		if (!detached.getShape().isRotationsAllowed())
		{
			detached.setAngleDegrees(0.0f);
		}

		if (detached.getPlayer() is this.getDamageOwnerPlayer()) {
			this.SetDamageOwnerPlayer(null);
		}
	}
}

This code sets the sitting player as the damage owner and unsets him when he stops sitting.

However, when the sitting player dies, the code in onDetach() doesn't run and the player will still be the damage owner even when not sitting anymore.

When getting killed while sitting on a Bison, all kills the Bison does will be counted towards that player. Someone else sitting on the Bison will not override the damage owner due to the check for if (this.getDamageOwnerPlayer() is null).

Also, when the damage owner player gets killed by the Bison, the game will say that the player killed himself.

I you do this bug with a catapult, - although not tested - it may be possible that someone else riding over enemies will count towards the player that previously sat in the catapult. I did verify that a catapult I'm no longer sitting in will attribute kills to me at least.


In a match, I tamed a Bison and got killed while riding.
After respawning, I saw kills getting attributed to me which is the reason I found this.
222

@mugg91
Copy link
Contributor Author

mugg91 commented Apr 25, 2024

It looks like onDetach() does get run after all, and successfully unsets the damage player.
But then I'm not unterstanding why the bug is happening ...

The

		if (detached.getPlayer() is this.getDamageOwnerPlayer()) {
			this.SetDamageOwnerPlayer(null);
		}

code is successful on client but it fails on server.
I guess the detached blob is already treated as null.

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 a pull request may close this issue.

1 participant