PadWorld-Entertainment / worldofpadman

World of PADMAN game repository
https://worldofpadman.net
Other
39 stars 9 forks source link

Implementation of the player breath and dust trail features from Q3 Team Arena #126

Closed kai-li-wop closed 1 year ago

kai-li-wop commented 2 years ago

Q3 Team Arena has the ability to display simple particle effects in certain maps:

  1. when the player walks over a surface with surfaceparm dust and lands after a jump, a small dust cloud is drawn at his feet. This was originally intended for terrain (see textures/common/terrain). To be activated, the worldspawn entity in a map must have enableDust 1 set.

  2. in "cold" environments, a small cloud can be drawn at the player's head position and spawned at intervals to simulate breathing condensation. To be activated, the worldspawn entity in a map must have enableBreath 1 set. This will activate the feature for the entire map.

The dust feature could be used on dusty surfaces like in the sandbox of the TrashMap and the breath feature could be used in FridgeWars, a cold environment. Both features should be implemented in World of Padman.

Tasks

Additional idea: To have more control about the breath feature, the level designer should have the possibility to activate the feature for certain regions of a map additionally of activating it globally in the worldspawn. For this purpose a brush with the property trigger_breath could be created or alternatively this brush could be provided with a shader texture with a surfaceparm breath. As long as the player touches this brush the feature would be active, otherwise inactive. Inside these "brush zones", the freeze tag behavior is overridden and the feature is always active. Outside, the freezetag behavior applies. So enableBreath overrules trigger_breath/surfaceparm breath overrules freezetag behavior. This could be another useful enhancement.

kai-li-wop commented 2 years ago

With 16d688ee11c1f28cc00097a97cebc9586a974957 the player breath function has been copied and implemented from Team Arena. WoP maps do not support the feature yet, but it can be activated via "g_enableBreath 1".

There are still some understanding problems regarding the CVARS on my part, so I'm grateful for hints here.

The code here in line 175 had one more argument in Team Arena, but it causes problems in WoP. It is not clear to me why this is so.

WoP: {&g_enableBreath, "g_enableBreath", "0", CVAR_SERVERINFO, 0, qfalse}, Q3TA: {&g_enableBreath, "g_enableBreath", "0", CVAR_SERVERINFO, 0, qtrue, qfalse},

Furthermore, the CVAR "cg_enableBreath" seems to be unknown, while "g_enableBreath" is known and works.

mgerhardy commented 2 years ago

the cvar is not known because it's called g_enableBreath - cg_enableBreath is just the variable name to access it from the code.

The Team Arena code in ioq3 defines the cvar like you did for wop - so I assume that the cvarTable_t structure contains an additional field in the original code that was removed over time. Where did you get the code from?

kai-li-wop commented 2 years ago

Thanks for the clarification. The code is directly taken from ioquake3. The missionpack code contains here an additional field and I don't know for what. https://github.com/ioquake/ioq3/blob/99b66faa0240aa9823d64ac00ef53d347a2e85e1/code/game/g_main.c#L173. Same is for enableDust one line above.

mgerhardy commented 2 years ago
  qboolean teamShader;        // track and if changed, update shader state

this field is not part of the wop cvarTable_t - TA only i suppose. If the cvar had a true here this function was called https://github.com/ioquake/ioq3/blob/99b66faa0240aa9823d64ac00ef53d347a2e85e1/code/game/g_main.c#L318 I'm not yet sure why this could be needed.

kai-li-wop commented 2 years ago

Ok, good. I will simply keep skipping it.

kai-li-wop commented 2 years ago

With e32047e332060733034a21e4da0a4a747a73a657 the player dust trail feature from Team Arena got implemented during my lunch break. WoP maps do not support this feature yet, but it can be activated via "g_enableDust 1". As far as I have seen it works only on surfaces with surfaceparm dust. I still need to create a test map to properly test this feature.

kai-li-wop commented 2 years ago
To enable both features in your maps you need to add to the worldspawn of your maps the following parameters: key value
enabledust 1
enablebreath 1

It is also possible to enable/disable both features with the CVARS

The dust trail feature needs surfaces with texture shader containing surfaceparm dust.

3aTmE commented 2 years ago

Hey, got a bit hyped and just wanted to try this for myself.

Grabbed the build #78 made a little testmap, wrote a small shader with the surfaceparm dust added enabledust 1 enablebreath 1 to my worldspawn and nothing happned.

Did i something wrong?

shader:

textures/sand/sand_dusty
{
    surfaceparm dust
    qer_editorimage textures/sand/sand.jpg
    {
        map textures/sand/sand.jpg
        rgbgen identity
    }
    {
        map $lightmap
        blendfunc GL_DST_COLOR GL_ZERO
    }
}

worldspawn: worldspawn

video:

https://user-images.githubusercontent.com/84514074/154279083-146a18ab-53c3-41ca-8233-c2fc093a61df.mp4

I tried both opengl1 and opengl2 just couldn't make it work.

g_enablebreath and g_enabledust were both set to 1

kai-li-wop commented 2 years ago

Yeah, that's a bummer. Usually the worlspawn entity keys should enable the cvars so it shoudn't be necessary to enable the cvars. The problem is that I could not find any mapping tutorial covering this feature but this is how I understood it from the code to be applied. So far I could only get the breath feature working by simply starting a map, going into thirdpersonview and entering g_enableBreath 1 into the console. This works for sure. If not, please make sure that sv_pure is set to 0 and the QVMs are loaded correctly.

ghost commented 2 years ago

Just for reference, this was the official manual: https://icculus.org/gtkradiant/documentation/Terrain_Manual/pages/table_of_contents.html

kai-li-wop commented 2 years ago

And I know this document but totally forgot about it. The worldspawn features are described here https://icculus.org/gtkradiant/documentation/Terrain_Manual/pages/terrain_related_worldspawn_features.html

kai-li-wop commented 2 years ago

Proof that g_enableBreath works via console. shot0002

kai-li-wop commented 2 years ago

Question: Does the surfaceparm dust possibly only work with the outdated q3map_terrain?

ghost commented 2 years ago

Answer: by default, no, afaik. It should work for any surface as long as the map is compiled correctly. The problem is that someone removed Team Arena related code in a very 'rough' way. Some parts are still there, some are missing. I don't know the current WoP game code by heart anymore, but iirc you have to somehow call 'CG_DustTrail' or something. For example: https://github.com/ioquake/ioq3/blob/main/code/cgame/cg_players.c#L2584 I think this was removed, though I'm not sure if this will fix your problem. By the way, if you want to restore the broken bits in the current WoP code I recommend some tool to compare code, this way you can easily restore the missing code (e.g.: https://winmerge.org/, assuming you are on Windows).

kai-li-wop commented 2 years ago

Wow, I think you nailed it! I forgot to copy and paste that exact line from the TA code. I hope I didn't miss other lines as well. Should be fixed with 55fea86c6439cb7b3b82750da26e5a21441818e4.

3aTmE commented 2 years ago

Wow, I think you nailed it! I forgot to copy and paste that exact line from the TA code. I hope I didn't miss other lines as well. Should be fixed with 55fea86.

Can confirm the fix! Both g_enableBreath and g_enableDust The reason why it did not worked for me at my first attempt was simply me not understanding properly how GitHub worked. But hey, at least i learned now something!

itworks I tried to highlight the Dust effect. Sadly you still can see it only veeery faintly due the brightness of the Texture I've used. But it's there, i swear! :)

kai-li-wop commented 2 years ago

Good! The shaders for both effects still need to be created. This is just a placeholder, so it will be better visible in future. I am simply happy that it works.

kai-li-wop commented 1 year ago

Latest changes:

Further development of those features will be documented in other issues/pr's.