MCPcopy Create free account
hub / github.com/JACoders/OpenJK / UserSpawn

Function UserSpawn

code/game/g_cmds.cpp:615–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613extern qboolean G_CallSpawn( gentity_t *ent );
614
615void UserSpawn( gentity_t *ent, const char *name )
616{
617 vec3_t origin;
618 vec3_t vf;
619 vec3_t angles;
620 gentity_t *ent2;
621
622 //Spawn the ent
623 ent2 = G_Spawn();
624 ent2->classname = G_NewString( name );
625
626 //TODO: This should ultimately make sure this is a safe spawn!
627
628 //Spawn the entity and place it there
629 VectorSet( angles, 0, ent->s.apos.trBase[YAW], 0 );
630 AngleVectors( angles, vf, NULL, NULL );
631 VectorMA( ent->s.pos.trBase, 96, vf, origin ); //FIXME: Find the radius size of the object, and push out 32 + radius
632
633 origin[2] += 8;
634 VectorCopy( origin, ent2->s.pos.trBase );
635 VectorCopy( origin, ent2->s.origin );
636 VectorCopy( ent->s.apos.trBase, ent2->s.angles );
637
638 gi.linkentity( ent2 );
639
640 //Find a valid spawning spot
641 if ( G_CallSpawn( ent2 ) == qfalse )
642 {
643 gi.SendServerCommand( ent-g_entities, "print \"Failed to spawn '%s'\n\"", name );
644 G_FreeEntity( ent2 );
645 return;
646 }
647}
648
649/*
650-------------------------

Callers 1

Cmd_SpawnFunction · 0.70

Calls 8

VectorSetFunction · 0.85
AngleVectorsFunction · 0.85
VectorCopyFunction · 0.85
G_SpawnFunction · 0.70
G_NewStringFunction · 0.70
G_CallSpawnFunction · 0.70
G_FreeEntityFunction · 0.70
VectorMAFunction · 0.50

Tested by

no test coverage detected