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

Weapon cheating is working incorrectly. #362

Open
shamazmazum opened this issue Apr 21, 2020 · 5 comments
Open

Weapon cheating is working incorrectly. #362

shamazmazum opened this issue Apr 21, 2020 · 5 comments

Comments

@shamazmazum
Copy link
Contributor

As discovered in #360, cheating for weapons (CTRL+2) results in some problems. These problems are:

20200421_09h10m57s_grim

The code which causes problems is in src/GameSrc/hkeyfunc.c in toggle_giveall_func().

Is there any ideas how to fix it?

@shamazmazum shamazmazum changed the title Weapon cheating is working incorrect. Weapon cheating is working incorrectly. Apr 21, 2020
@donnierussellii
Copy link
Contributor

Items can't be spawned, the cheat command is simply writing over the inventory structure. This is a hard problem; we'd have to load the level where a certain weapon is, put it in the inventory, save the level, then return to the original level.

@shamazmazum
Copy link
Contributor Author

shamazmazum commented Apr 21, 2020

Do you have any ideas how to avoid both #360 and #265? Because 70371bb actually reverts your work. Also, why HUD shows incorrect ammo type for rail gun? Isn't it dangerous?

BTW, I still do not understand how to reproduce #265.

@donnierussellii
Copy link
Contributor

donnierussellii commented Apr 21, 2020

Since weapons acquired with the cheat command are not "world" objects, they aren't handled properly in some obscure ways.

I think what's causing the strange ammo type behavior is that, for example, a projectile weapon in slot 4 with these values:
player_struct.weapons[4].ammo = 50;
player_struct.weapons[4].ammo_type = 0;

is later modified with data for an energy weapon:
player_struct.weapons[4].heat = 0; //union'd with ammo
player_struct.weapons[4].setting = 40; //union'ed with ammo_type

causing the ammo type to now have a crazy value way out of bounds.

I think one thing to do would be to try to modify any held weapons so that they change into cheat weapons. But if one such weapon was then dropped, I don't know if the world object would be correct.

@shamazmazum
Copy link
Contributor Author

As a quick solution, can the cheat weapon set be replaced with non-energy weapons?

@donnierussellii
Copy link
Contributor

donnierussellii commented Apr 23, 2020

Maybe I'm wrong (it's been a long time since I went digging into the code), but I don't think that would fix it, since an energy weapon can be in a slot before the cheat is applied. When the weapon inventory is overwritten by the cheat, the world objects that were there are caught in limbo and confuse the game in peculiar ways. The cheats were probably just quick, quite broken hacks, and aren't like the ones you see in, for example, DOOM. I recall fixing another that crashed when cycling through levels.

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

No branches or pull requests

2 participants