Open Pulseczar1 opened 5 months ago
I have bookmarked all areas in the progs code that handle water stuff for players. I want to basically port that code over to the grunt code. I now need to study the grunt code to get a good idea about the best way to do that.
I found that the grunt has waterlevel 1 while deep underwater. I would think it should be 3. This is likely what kept the grunt from having a proper death sound, and generating bubbles, when I killed him well underwater. ArmyDeathSound() already had code to give him death sound but requires waterlevel of 3. I searched the code and didn't find anywhere that waterlevel is ever set for anything. That suggests to me that it's done in the engine, and probably only done on player entities. And this likely has a bit to do with why the summons don't have much water support, and also why the FrikBot has the function, frik_botDetermineWaterLevel() (I renamed the function to that), which I can probably just copy and paste into the grunt code to give grunts a waterlevel at the start of every frame.
I created AI_Check_Water(), in ai.cpp, to set the grunt's .waterlevel and .watertype. I call it in GruntyThink(), after AI_Check_Contents(). It correctly sets the grunt's .waterlevel and .watertype. The result is that shooting the grunt underwater gives the pain sound effects that the player gives while hurting underwater. When the grunt dies underwater, he now makes a water death sound and generates bubbles. The next time, I need to get back to looking at the places in the player entity code that I bookmarked in regard to handling water, and make sure the grunt has similar code. The next easiest thing to do is to probably make it so the grunt drowns when his head is underwater, just like a player does. Later, I could probably add frik_botAccelerateInWater() for the grunt, so that he can move in water, like a client does, as controlled by the engine.
I checked which functions in ai.cpp are used in grunty.cpp. There are probably only 3 or 4 that are used -- one that I added. The vast majority of the code in that file is not used by the grunty code, which is the main code of the mercenary soldier. fight.cpp is about a third the size of ai.cpp and none of fight.cpp is used by the grunty code. A very small amount of monsters.cpp is used by grunty.cpp. So, unless I'm missing some code somewhere that I haven't yet considered, pretty much all of the grunty's code is in grunty.cpp. army.cpp is exclusively stuff about the grunts, like the menus and stats for them and code that handles the Army job, but not code that controls the grunts.
Studied grunty.cpp. Added a lot of #define
field replacements to army.h to make the code way easier to understand, after figuring out what different fields are used for. There are still some more to add.
I did a lot to clean up the whitespace in grunty.cpp, to make it easier for me to read it.
I added gruntyData
to the Grunty module where I can place whatever data I want that will be associated with every grunty that is created in the game. I just have to call auto iter = gruntyData.find(grunty)
, where grunty
is a grunty entity
, and then use iter->second->data
to access data
that lives in the structure for grunty
. I will need to protect the access to the data by using if (iter != gruntyData.end())
to make sure it actually finds data for the grunty entity, before trying to use the data.
I noticed recently that some of the grunty's animations are jerky, like frames are being skipped or something, like his standing animation. I checked tonight on Often's server and his look the same. So, I'm just going to ignore it for now. I fixed a missing white character on grunt's menu to mark waypoints created and visible to the grunt. The missing character was also causing misalignment on the two waypoint lines (1 and 2). On the menu that lets you control which weapons the grunt can use, the yellow dot indicator character was broken and instead displayed the name of the define macro, because cutfmenu.h, where the character macro is defined, needed to be included in army.cpp, which uses the macro for this menu.
From my Discord post: https://discord.com/channels/695130119903379518/695145581621936171/1229052622498168832
Often said he thinks scrags can already go under water, at least on his version.
I think the grunty should also be able to eventually buy scuba gear as it ranks up, so that it can't drown, and swims faster. Scuba shouldn't slow it on land, to keep it from being a downgrade on land. Scuba gear should also be given a sound effect, if it doesn't have one, much like the sound in Duke Nukem 3D, a breathing sound. Maybe just take the sound(s) from Duke3D.