From f1e47f9ea47f3e375ebfc712c60658948de81532 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Thu, 27 Jul 2023 13:44:28 -0700 Subject: [PATCH] NSProjectile: SpawnDef/SpawnDefAtPosition/SpawnDefAttachment will now return the resulting NSProjectile --- src/shared/NSProjectile.h | 6 +++--- src/shared/NSProjectile.qc | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/shared/NSProjectile.h b/src/shared/NSProjectile.h index e093b3bf..0e2235bd 100644 --- a/src/shared/NSProjectile.h +++ b/src/shared/NSProjectile.h @@ -154,7 +154,7 @@ void NSProjectile_ReadEntity(bool); #endif #ifdef SERVER -void NSProjectile_SpawnDef(string entityDef, NSEntity theOwner); -void NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles); -void NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID); +NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner); +NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles); +NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID); #endif \ No newline at end of file diff --git a/src/shared/NSProjectile.qc b/src/shared/NSProjectile.qc index dff1e081..eefc9cba 100644 --- a/src/shared/NSProjectile.qc +++ b/src/shared/NSProjectile.qc @@ -813,18 +813,28 @@ NSProjectile_ReadEntity(bool new) #endif #ifdef SERVER -void +NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner) { entity oldself = self; + vector launchAngle; + NSProjectile rocket = spawn(NSProjectile); rocket.owner = theOwner; self = rocket; EntityDef_SpawnClassname(entityDef); self = oldself; - rocket.Launch(theOwner.GetOrigin() + theOwner.view_ofs, theOwner.GetAngles(), 0.0f, 0.0f, 0.0f); + + if (theOwner.flags & FL_CLIENT) + launchAngle = theOwner.v_angle; + else + launchAngle = theOwner.GetAngles(); + + rocket.Launch(theOwner.GetOrigin() + theOwner.view_ofs, launchAngle, 0.0f, 0.0f, 0.0f); + return rocket; } -void + +NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles) { entity oldself = self; @@ -834,8 +844,10 @@ NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecO EntityDef_SpawnClassname(entityDef); self = oldself; rocket.Launch(vecOrigin, vecAngles, 0.0f, 0.0f, 0.0f); + return rocket; } -void + +NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID) { entity oldself = self; @@ -849,5 +861,6 @@ NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachm EntityDef_SpawnClassname(entityDef); self = oldself; rocket.Launch(attachmentPos, theOwner.GetAngles(), 0.0f, 0.0f, 0.0f); + return rocket; } #endif \ No newline at end of file