Post: How to Spawn Solid Entities and Turrets C++
01-24-2016, 04:10 PM #1
Swaqq
Professional Thanker
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys, today I'm releasing how you can spawn entities in C++. I've been using these for my bunker and it works perfectly.

So first off you need to add these structures:
    
struct gclient_s {
char unk0[0x78];
float origin[3];
char unk1[0x12C];
float viewAngles[3]; //0x353C
char unk2[0x3380];
int oldbuttons;
char unk3[0x8];
int buttons;
char unk4[0x434];
};


struct gagent_s {
char unk[0x100];
};

struct gentity_s {
char unk0[0x1C];
int contents;
char unk1[0x118];
float currentOrigin[3];
float currentAngles[3];
char unk2[0x8];
gclient_s* client;
char unk3[0x4];
gagent_s* agent;
char unk4[0x16];
short classname;
short script_classname;
short script_linkName;
short target;
short targetname;
char unk5[0x2];
unsigned int attachIgnoreCollision;
int spawnflags;
char unk6[0x19];
int health;
char unk7[0xCF];
};





Next you will need these functions
    
gentity_s* G_Spawn()
{
opd_s G_Spawn_t = { 0x00389510, TOC };
gentity_s*(*G_Spawn_f)() = (gentity_s*(*)())&G_Spawn_t;
return G_Spawn_f();
}

void G_SetModel(gentity_s* ent, char* Model)
{
opd_s G_SetModel_t = { 0x00388294, TOC };
void(*G_SetModel_f)(gentity_s* ent, char* Model) = (void(*)(gentity_s*, char*))&G_SetModel_t;
G_SetModel_f(ent, Model);
}
void SP_Script_Model(gentity_s* ent)
{
opd_s SP_Script_Model_t = { 0x0037DDD4, TOC };
void(*SP_Script_Model_f)(gentity_s* ent) = (void(*)(gentity_s*))&SP_Script_Model_t;
SP_Script_Model_f(ent);
}
void SV_LinkEntity(gentity_s* ent)
{
opd_s SV_LinkEntity_t = { 0x004737A0, TOC };
void(*SV_LinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_LinkEntity_t;
SV_LinkEntity_f(ent);
}
void SV_UnlinkEntity(gentity_s* ent)
{
opd_s SV_UnlinkEntity_t = { 0x00473720, TOC };
void(*SV_UnlinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_UnlinkEntity_t;
SV_UnlinkEntity_f(ent);
}
void SV_SetBrushModel(gentity_s* ent)
{
opd_s SV_SetBrushModel_t = { 0x00457D04, TOC };
void(*SV_SetBrushModel_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_SetBrushModel_t;
SV_SetBrushModel_f(ent);
}

void G_SpawnTurret(gentity_s* ent, const char *weaponinfoname, const int useDropPitch)
{
opd_s G_SpawnTurret_t = { 0x0039E620, TOC };
void(*G_SpawnTurret_f)(gentity_s* ent, const char *weaponinfoname, const int useDropPitch) = (void(*)(gentity_s* , const char *, const int))&G_SpawnTurret_t;
G_SpawnTurret_f(ent, weaponinfoname, useDropPitch);
}


And finally to add
    
gentity_s* SpawnEnt(char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = G_Spawn();
Ent->currentOrigin[0] = Origin[0];
Ent->currentOrigin[1] = Origin[1];
Ent->currentOrigin[2] = Origin[2];
Ent->currentAngles[0] = Angles[0];
Ent->currentAngles[1] = Angles[1];
Ent->currentAngles[2] = Angles[2];
G_SetModel(Ent, Model);
SP_Script_Model(Ent);
SV_UnlinkEntity(Ent);
SV_SetBrushModel(Ent);
SV_LinkEntity(Ent);
return Ent;
}
gentity_s* SpawnTurret(char* TurretType, char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = SpawnEnt(Model, Origin, Angles);
G_SpawnTurret(Ent, TurretType, 0);
}


To spawn a crate, you do:
    
gentity_s* Crate = SpawnEnt("com_plasticcase_green_big_us_dirt",Origin, Angles)

To spawn a Turret, do:
    
gentity_s* Turret = SpawnTurret("sentry_minigun_mp", "npc_sentry_energy_turret_base", Origin, Angles);


Model List:
    
https://pastebin.com/eeziSJTQ

Turrets: //Shark
    
turretheadmg_mp
turretheadenergy_mp
sentry_minigun_mp
remote_turret_mp
remote_energy_turret_mp
killstreak_remote_turret_mp
warbird_turret
ugv_turret_mp
warbird_remote_turret_mp
orbitalsupport_big_turret_mp
orbitalsupport_buddy_turret_mp
recon_drone_turret_mp
drone_assault_remote_turret_mp


Note: You will need to call this in a hook. I was using VM_Notify but R_SetFrameFog should work fine.

Credits:
    
Me - for developing the script
Shark - gentity and gclient struct

The following 8 users say thank you to Swaqq for this useful post:

Sabotage, gοd, SQUID-EYE, LBK, Loes, John, basshead4ever,

The following user groaned Swaqq for this awful post:

Tears
01-24-2016, 04:21 PM #2
Sabotage
Gaming Squad
such a nice work swaqq.

The following user thanked Sabotage for this useful post:

Swaqq
01-24-2016, 04:25 PM #3
Shark
Retired.
this has already been posted on older COD's Sal

The following user thanked Shark for this useful post:

SyGnUs
01-24-2016, 04:32 PM #4
Swaqq
Professional Thanker
Originally posted by Shark View Post
this has already been posted on older COD's Sal


Not in C++ tears
01-24-2016, 06:29 PM #5
SyGnUs
Give a F*** About Your Lifestyle
Originally posted by Swaqq View Post
Not in C++ tears


Doesn't really matter what language it was, but why don't you just use G_SetOrigin and G_SetAngles? I mean you might as well since you are already using the real functions for everything else.
01-24-2016, 06:31 PM #6
Swaqq
Professional Thanker
Originally posted by SyGnUs View Post
Doesn't really matter what language it was, but why don't you just use G_SetOrigin and G_SetAngles? I mean you might as well since you are already using the real functions for everything else.


Well I was using the actual functions, and I couldn't be asked to add them. And they work fine so its all good.
01-25-2016, 08:41 AM #7
Shark
Retired.
You must login or register to view this content.

good ol' memories Sal

The following user thanked Shark for this useful post:

Swaqq
01-25-2016, 09:51 AM #8
TrillBrown
< ^ > < ^ >
Originally posted by Shark View Post
You must login or register to view this content.

good ol' memories Sal


Originally posted by Swaqq View Post
Well I was using the actual functions, and I couldn't be asked to add them. And they work fine so its all good.


Originally posted by SyGnUs View Post
Doesn't really matter what language it was, but why don't you just use G_SetOrigin and G_SetAngles? I mean you might as well since you are already using the real functions for everything else.


Yall should get together and make a nice menu instead of trying to prove a point
01-25-2016, 12:24 PM #9
Swaqq
Professional Thanker
Originally posted by TrillBrown View Post
Yall should get together and make a nice menu instead of trying to prove a point


We weren't trying to prove a point, not arguing lol. And my menu is almost done lol

The following user thanked Swaqq for this useful post:

mrdarkblue
01-25-2016, 12:34 PM #10
Sabotage
Gaming Squad
Originally posted by Swaqq View Post
We weren't trying to prove a point, not arguing lol. And my menu is almost done lol


you mean "my" menu? you leeching fgt :(

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo