Open shamazmazum opened 4 years ago
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.
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.
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.
As a quick solution, can the cheat weapon set be replaced with non-energy weapons?
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.
As discovered in #360, cheating for weapons (
CTRL+2
) results in some problems. These problems are:The code which causes problems is in
src/GameSrc/hkeyfunc.c
intoggle_giveall_func()
.Is there any ideas how to fix it?