RebornKyle Posted December 3 Posted December 3 Was wondering if its possible to prevent an NPC from using ragdoll upon being killed. Preferably it would be a scripted behavior that I could assign to any NPC, but I didn't see any that sounded like that when I perused Behaved.
RebornKyle Posted December 21 Author Posted December 21 2 hours ago, Linken said: Type "broadsword 0" Possible to make this scriptable? Only want it to occur in a specific situation. Even just toggling this on/off would work, but I'm not looking for cheats
Linken Posted December 21 Posted December 21 Are you looking for it to be global or only impact specific npcs?
RebornKyle Posted December 21 Author Posted December 21 2 minutes ago, Linken said: Are you looking for it to be global or only impact specific npcs? In this case either would be fine, it would be during a duel and going back to what it was after the duel
Linken Posted December 21 Posted December 21 11 hours ago, RebornKyle said: In this case either would be fine, it would be during a duel and going back to what it was after the duel Alright, I'll leave it up to you on how to implement or how to call it. So I'll write some simple tutorials. I'm going light on the details since I know you have a coding background, but let me know if you need screenshots. 1. In Q3_Interface.h, declare your new script command. 2. In Q3_Interface.cpp, add your command to the Enum2String and the Set method in the appropriate spot (would recommend making it a Boolean) 3. IF Making Global: have it change the value of the "g_broadsword" cvar to 0 (turned off) or 1 (turned on) depending if set to true or false. You can stop here. 4. IF Making NPC Specific, declare a new NPC scriptFlag (in b_public.h). In this example I'll just call it SCF_NO_RAGDOLL, make sure its Hexadecimal value is correct. An unmodified OpenJK source code should probably be 0x100000000. 5. To apply to an NPC, create a new function somewhere called by your script command and write something like this: static void Q3_SetRagdoll(int entID, qboolean ragDoll) { gentity_t *ent = &g_entities[entID]; if ( !ent ) { Quake3Game()->DebugPrint( IGameInterface::WL_WARNING, "Q3_SetRagdoll: invalid entID %d\n", entID); return; } if(ragDoll) ent->NPC->scriptFlags |= SCF_NO_RAGDOLL; else ent->NPC->scriptFlags &= ~SCF_NO_RAGDOLL; } 6. Lastly go to the function G_RagDoll (in g_main.cpp) and add a check near the beginning of the function to verify if the NPC has this scriptFlag applied, and if they do, return qfalse. DISCLAIMER: I wrote this code on the fly and didn't personally test.
RebornKyle Posted December 22 Author Posted December 22 On 12/21/2024 at 12:41 PM, Linken said: Alright, I'll leave it up to you on how to implement or how to call it. So I'll write some simple tutorials. I'm going light on the details since I know you have a coding background, but let me know if you need screenshots. 1. In Q3_Interface.h, declare your new script command. 2. In Q3_Interface.cpp, add your command to the Enum2String and the Set method in the appropriate spot (would recommend making it a Boolean) 3. IF Making Global: have it change the value of the "g_broadsword" cvar to 0 (turned off) or 1 (turned on) depending if set to true or false. You can stop here. 4. IF Making NPC Specific, declare a new NPC scriptFlag (in b_public.h). In this example I'll just call it SCF_NO_RAGDOLL, make sure its Hexadecimal value is correct. An unmodified OpenJK source code should probably be 0x100000000. 5. To apply to an NPC, create a new function somewhere called by your script command and write something like this: static void Q3_SetRagdoll(int entID, qboolean ragDoll) { gentity_t *ent = &g_entities[entID]; if ( !ent ) { Quake3Game()->DebugPrint( IGameInterface::WL_WARNING, "Q3_SetRagdoll: invalid entID %d\n", entID); return; } if(ragDoll) ent->NPC->scriptFlags |= SCF_NO_RAGDOLL; else ent->NPC->scriptFlags &= ~SCF_NO_RAGDOLL; } 6. Lastly go to the function G_RagDoll (in g_main.cpp) and add a check near the beginning of the function to verify if the NPC has this scriptFlag applied, and if they do, return qfalse. DISCLAIMER: I wrote this code on the fly and didn't personally test. Well hey I greatly appreciate this! I'll be sure to give this a go when I have some time soonish. I'll probably opt for the specific NPC one since setting it globally would probably get messy if other users prefer it differently and having to change it back afterwards could alter those preferences. Happy Holidays! Linken likes this
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now