From: bones_was_here Date: Sat, 15 Jul 2023 12:28:37 +0000 (+1000) Subject: Implement DP_QC_NUDGEOUTOFSOLID extension X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b44afa3d203dfd226ceab2a64522f6b45b7fef59;p=xonotic%2Fdarkplaces.git Implement DP_QC_NUDGEOUTOFSOLID extension Signed-off-by: bones_was_here --- diff --git a/clvm_cmds.c b/clvm_cmds.c index 587a31bb..05bb57a9 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -5545,7 +5545,7 @@ NULL, // #563 NULL, // #564 NULL, // #565 VM_CL_findbox, // #566 entity(vector mins, vector maxs) findbox = #566; (DP_QC_FINDBOX) -NULL, // #567 +VM_nudgeoutofsolid, // #567 float(entity ent) nudgeoutofsolid = #567; (DP_QC_NUDGEOUTOFSOLID) NULL, // #568 NULL, // #569 NULL, // #570 diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc index 558a288e..b616980a 100644 --- a/dpdefs/dpextensions.qc +++ b/dpdefs/dpextensions.qc @@ -2654,4 +2654,16 @@ entity(vector mins, vector maxs, .entity tofield) findbox_tofield = #566; //description: //Returns a chain of entities that are touching a box (a simpler findradius); supports DP_QC_FINDCHAIN_TOFIELD +//DP_QC_NUDGEOUTOFSOLID +//idea: LadyHavoc, bones_was_here +//darkplaces implementation: LadyHavoc, bones_was_here +//builtin definitions: +float(entity ent) nudgeoutofsolid = #567; +//cvar definitions: +//sv_gameplayfix_nudgeoutofsolid_separation +//description: +//Attempts to move a stuck entity out of solid brushes, returning 1 if successful, 0 if it remains stuck, -1 if it wasn't stuck. +//Note: makes only one tracebox call if the entity isn't stuck, so don't call tracebox just to see if you should call nudgeoutofsolid. + + float(float dividend, float divisor) mod = #245; diff --git a/prvm_cmds.c b/prvm_cmds.c index 9554aa44..fc39fa33 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -5563,6 +5563,41 @@ void VM_SV_getextresponse (prvm_prog_t *prog) } } +// DP_QC_NUDGEOUTOFSOLID +// float(entity ent) nudgeoutofsolid = #567; +void VM_nudgeoutofsolid(prvm_prog_t *prog) +{ + prvm_edict_t *ent; + + VM_SAFEPARMCOUNTRANGE(1, 1, VM_nudgeoutofsolid); + + ent = PRVM_G_EDICT(OFS_PARM0); + if (ent == prog->edicts) + { + VM_Warning(prog, "nudgeoutofsolid: can not modify world entity\n"); + PRVM_G_FLOAT(OFS_RETURN) = 0; + return; + } + if (ent->free) + { + VM_Warning(prog, "nudgeoutofsolid: can not modify free entity\n"); + PRVM_G_FLOAT(OFS_RETURN) = 0; + return; + } + + PRVM_G_FLOAT(OFS_RETURN) = PHYS_NudgeOutOfSolid(prog, ent); + + if (PRVM_G_FLOAT(OFS_RETURN) > 0) + { + if (prog == SVVM_prog) + SV_LinkEdict(ent); + else if (prog == CLVM_prog) + CL_LinkEdict(ent); + else + Sys_Error("PHYS_NudgeOutOfSolid: cannot be called from %s VM\n", prog->name); + } +} + /* ========= Common functions between menu.dat and clsprogs diff --git a/prvm_cmds.h b/prvm_cmds.h index a5555cde..81556d5c 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -484,6 +484,7 @@ void VM_getsurfacetriangle(prvm_prog_t *prog); void VM_physics_enable(prvm_prog_t *prog); void VM_physics_addforce(prvm_prog_t *prog); void VM_physics_addtorque(prvm_prog_t *prog); +void VM_nudgeoutofsolid(prvm_prog_t *prog); void VM_coverage(prvm_prog_t *prog); diff --git a/svvm_cmds.c b/svvm_cmds.c index 4cccd0f4..b97ee208 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -119,6 +119,7 @@ const char *vm_sv_extensions[] = { "DP_QC_LOG", "DP_QC_MINMAXBOUND", "DP_QC_MULTIPLETEMPSTRINGS", +"DP_QC_NUDGEOUTOFSOLID", "DP_QC_NUM_FOR_EDICT", "DP_QC_RANDOMVEC", "DP_QC_SINCOSSQRTPOW", @@ -3833,7 +3834,7 @@ NULL, // #563 NULL, // #564 NULL, // #565 VM_SV_findbox, // #566 entity(vector mins, vector maxs) findbox = #566; (DP_QC_FINDBOX) -NULL, // #567 +VM_nudgeoutofsolid, // #567 float(entity ent) nudgeoutofsolid = #567; (DP_QC_NUDGEOUTOFSOLID) NULL, // #568 NULL, // #569 NULL, // #570