NSProjectile: SpawnDef/SpawnDefAtPosition/SpawnDefAttachment will now return the resulting NSProjectile

This commit is contained in:
Marco Cawthorne 2023-07-27 13:44:28 -07:00
parent dea5168998
commit f1e47f9ea4
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 20 additions and 7 deletions

View file

@ -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

View file

@ -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