void UI_SaberAttachToChar( itemDef_t *item ) { int numSabers = 1; int saberNum = 0; if ( trap_G2API_HasGhoul2ModelOnIndex(&(item->ghoul2),2) ) {//remove any extra models trap_G2API_RemoveGhoul2Model(&(item->ghoul2), 2); } if ( trap_G2API_HasGhoul2ModelOnIndex(&(item->ghoul2),1) ) {//remove any extra models trap_G2API_RemoveGhoul2Model(&(item->ghoul2), 1); } if ( uiInfo.movesTitleIndex == 4 /*MD_DUAL_SABERS*/ ) { numSabers = 2; } for ( saberNum = 0; saberNum < numSabers; saberNum++ ) { //bolt sabers char modelPath[MAX_QPATH]; char skinPath[MAX_QPATH]; char saber[MAX_QPATH]; UI_GetSaberForMenu( saber, saberNum ); if ( UI_SaberModelForSaber( saber, modelPath ) ) {//successfully found a model int g2Saber = trap_G2API_InitGhoul2Model( &(item->ghoul2), modelPath, 0, 0, 0, 0, 0 ); //add the model if ( g2Saber ) { int boltNum; //get the customSkin, if any if ( UI_SaberSkinForSaber( saber, skinPath ) ) { int g2skin = trap_R_RegisterSkin(skinPath); trap_G2API_SetSkin( item->ghoul2, g2Saber, 0, g2skin );//this is going to set the surfs on/off matching the skin file } else { trap_G2API_SetSkin( item->ghoul2, g2Saber, 0, 0 );//turn off custom skin } if ( saberNum == 0 ) { boltNum = trap_G2API_AddBolt( item->ghoul2, 0, "*r_hand"); } else { boltNum = trap_G2API_AddBolt( item->ghoul2, 0, "*l_hand"); } trap_G2API_AttachG2Model( item->ghoul2, g2Saber, item->ghoul2, boltNum, 0); } } } }
/*QUAKED misc_G2model (1 0 0) (-16 -16 -16) (16 16 16) "model" arbitrary .glm file to display */ void SP_misc_G2model( gentity_t *ent ) { #if 0 char name1[200] = "models/players/kyle/modelmp.glm"; trap_G2API_InitGhoul2Model(&ent->s, name1, G_ModelIndex( name1 ), 0, 0, 0, 0); trap_G2API_SetBoneAnim(ent->s.ghoul2, 0, "model_root", 0, 12, BONE_ANIM_OVERRIDE_LOOP, 1.0f, level.time, -1, -1); ent->s.radius = 150; // VectorSet (ent->mins, -16, -16, -16); // VectorSet (ent->maxs, 16, 16, 16); trap_LinkEntity (ent); G_SetOrigin( ent, ent->s.origin ); VectorCopy( ent->s.angles, ent->s.apos.trBase ); #else G_FreeEntity( ent ); #endif }
/*QUAKED worldspawn (0 0 0) ? Every map should have exactly one worldspawn. "music" music wav file "gravity" 800 is default gravity "message" Text to print during connection process */ void SP_worldspawn( void ) { char *text, temp[32]; int i; int lengthRed, lengthBlue, lengthGreen; G_SpawnString( "classname", "", &text ); if ( Q_stricmp( text, "worldspawn" ) ) { G_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" ); } //The server will precache the standard model and animations, so that there is no hit //when the first client connnects. if (!BGPAFtextLoaded) { BG_ParseAnimationFile("models/players/_humanoid/animation.cfg"); } if (!precachedKyle) { trap_G2API_InitGhoul2Model(&precachedKyle, "models/players/kyle/model.glm", 0, 0, -20, 0, 0); } if (!g2SaberInstance) { trap_G2API_InitGhoul2Model(&g2SaberInstance, "models/weapons2/saber/saber_w.glm", 0, 0, -20, 0, 0); if (g2SaberInstance) { // indicate we will be bolted to model 0 (ie the player) on bolt 0 (always the right hand) when we get copied trap_G2API_SetBoltInfo(g2SaberInstance, 0, 0); // now set up the gun bolt on it trap_G2API_AddBolt(g2SaberInstance, 0, "*flash"); } } // make some data visible to connecting client trap_SetConfigstring( CS_GAME_VERSION, GAME_VERSION ); trap_SetConfigstring( CS_LEVEL_START_TIME, va("%i", level.startTime ) ); G_SpawnString( "music", "", &text ); trap_SetConfigstring( CS_MUSIC, text ); G_SpawnString( "message", "", &text ); trap_SetConfigstring( CS_MESSAGE, text ); // map specific message trap_SetConfigstring( CS_MOTD, g_motd.string ); // message of the day G_SpawnString( "gravity", "800", &text ); trap_Cvar_Set( "g_gravity", text ); G_SpawnString( "enableDust", "0", &text ); trap_Cvar_Set( "g_enableDust", text ); G_SpawnString( "enableBreath", "0", &text ); trap_Cvar_Set( "g_enableBreath", text ); g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD; g_entities[ENTITYNUM_WORLD].classname = "worldspawn"; // see if we want a warmup time trap_SetConfigstring( CS_WARMUP, "" ); if ( g_restarted.integer ) { trap_Cvar_Set( "g_restarted", "0" ); level.warmupTime = 0; } else if ( g_doWarmup.integer && g_gametype.integer != GT_TOURNAMENT ) { // Turn it on level.warmupTime = -1; trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) ); G_LogPrintf( "Warmup:\n" ); } trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+0, defaultStyles[0][0]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+1, defaultStyles[0][1]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+2, defaultStyles[0][2]); for(i=1;i<LS_NUM_STYLES;i++) { Com_sprintf(temp, sizeof(temp), "ls_%dr", i); G_SpawnString(temp, defaultStyles[i][0], &text); lengthRed = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+0, text); Com_sprintf(temp, sizeof(temp), "ls_%dg", i); G_SpawnString(temp, defaultStyles[i][1], &text); lengthGreen = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+1, text); Com_sprintf(temp, sizeof(temp), "ls_%db", i); G_SpawnString(temp, defaultStyles[i][2], &text); lengthBlue = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+2, text); if (lengthRed != lengthGreen || lengthGreen != lengthBlue) { Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", i, lengthRed, lengthGreen, lengthBlue); } } }
void TurretClientRun(centity_t *ent) { if (!ent->ghoul2) { weaponInfo_t *weaponInfo; trap_G2API_InitGhoul2Model(&ent->ghoul2, CG_ConfigString( CS_MODELS+ent->currentState.modelindex ), 0, 0, 0, 0, 0); if (!ent->ghoul2) { //bad return; } ent->torsoBolt = trap_G2API_AddBolt( ent->ghoul2, 0, "*flash02" ); trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time ); trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_gback", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time ); trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_barrel", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time ); trap_G2API_SetBoneAnim( ent->ghoul2, 0, "model_root", 0, 11, BONE_ANIM_OVERRIDE_FREEZE, 0.8f, cg.time, 0, 0 ); ent->turAngles[ROLL] = 0; ent->turAngles[PITCH] = 90; ent->turAngles[YAW] = 0; weaponInfo = &cg_weapons[WP_TURRET]; if ( !weaponInfo->registered ) { CG_RegisterWeapon(WP_TURRET); } } if (ent->currentState.fireflag == 2) { //I'm about to blow if (ent->turAngles) { trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", ent->turAngles, BONE_ANGLES_REPLACE, NEGATIVE_Y, NEGATIVE_Z, NEGATIVE_X, NULL, 100, cg.time ); } return; } else if (ent->currentState.fireflag && ent->bolt4 != ent->currentState.fireflag) { vec3_t muzzleOrg, muzzleDir; mdxaBone_t boltMatrix; trap_G2API_GetBoltMatrix(ent->ghoul2, 0, ent->torsoBolt, &boltMatrix, /*ent->lerpAngles*/vec3_origin, ent->lerpOrigin, cg.time, cgs.gameModels, ent->modelScale); BG_GiveMeVectorFromMatrix(&boltMatrix, ORIGIN, muzzleOrg); BG_GiveMeVectorFromMatrix(&boltMatrix, NEGATIVE_X, muzzleDir); trap_FX_PlayEffectID(cgs.effects.mTurretMuzzleFlash, muzzleOrg, muzzleDir, -1, -1); ent->bolt4 = ent->currentState.fireflag; } else if (!ent->currentState.fireflag) { ent->bolt4 = 0; } if (ent->currentState.bolt2 != ENTITYNUM_NONE) { //turn toward the enemy centity_t *enemy = &cg_entities[ent->currentState.bolt2]; if (enemy) { vec3_t enAng; vec3_t enPos; VectorCopy(enemy->currentState.pos.trBase, enPos); VectorSubtract(enPos, ent->lerpOrigin, enAng); VectorNormalize(enAng); vectoangles(enAng, enAng); enAng[ROLL] = 0; enAng[PITCH] += 90; CreepToPosition(enAng, ent->turAngles); } } else { vec3_t idleAng; float turnAmount; if (ent->turAngles[YAW] > 360) { ent->turAngles[YAW] -= 361; } if (!ent->dustTrailTime) { ent->dustTrailTime = cg.time; } turnAmount = (cg.time-ent->dustTrailTime)*0.03; if (turnAmount > 360) { turnAmount = 360; } idleAng[PITCH] = 90; idleAng[ROLL] = 0; idleAng[YAW] = ent->turAngles[YAW] + turnAmount; ent->dustTrailTime = cg.time; CreepToPosition(idleAng, ent->turAngles); } if (cg.time < ent->frame_minus1_refreshed) { ent->frame_minus1_refreshed = cg.time; return; } ent->frame_minus1_refreshed = cg.time; trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", ent->turAngles, BONE_ANGLES_REPLACE, NEGATIVE_Y, NEGATIVE_Z, NEGATIVE_X, NULL, 100, cg.time ); }
void SP_worldspawn( void ) { char *text, temp[32]; int i; int lengthRed, lengthBlue, lengthGreen; //I want to "cull" entities out of net sends to clients to reduce //net traffic on our larger open maps -rww G_SpawnFloat("distanceCull", "6000.0", &g_cullDistance); trap_SetServerCull(g_cullDistance); G_SpawnString( "classname", "", &text ); if ( Q_stricmp( text, "worldspawn" ) ) { G_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" ); } for ( i = 0 ; i < level.numSpawnVars ; i++ ) { if ( Q_stricmp( "spawnscript", level.spawnVars[i][0] ) == 0 ) {//ONly let them set spawnscript, we don't want them setting an angle or something on the world. G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], &g_entities[ENTITYNUM_WORLD] ); } } //The server will precache the standard model and animations, so that there is no hit //when the first client connnects. if (!BGPAFtextLoaded) { BG_ParseAnimationFile("models/players/_humanoid/animation.cfg", bgHumanoidAnimations, qtrue); } if (!precachedKyle) { int defSkin; trap_G2API_InitGhoul2Model(&precachedKyle, "models/players/kyle/model.glm", 0, 0, -20, 0, 0); if (precachedKyle) { defSkin = trap_R_RegisterSkin("models/players/kyle/model_default.skin"); trap_G2API_SetSkin(precachedKyle, 0, defSkin, defSkin); } } if (!g2SaberInstance) { trap_G2API_InitGhoul2Model(&g2SaberInstance, "models/weapons2/saber/saber_w.glm", 0, 0, -20, 0, 0); if (g2SaberInstance) { // indicate we will be bolted to model 0 (ie the player) on bolt 0 (always the right hand) when we get copied trap_G2API_SetBoltInfo(g2SaberInstance, 0, 0); // now set up the gun bolt on it trap_G2API_AddBolt(g2SaberInstance, 0, "*blade1"); } } if (g_gametype.integer == GT_SIEGE) { //a tad bit of a hack, but.. EWebPrecache(); } // make some data visible to connecting client trap_SetConfigstring( CS_GAME_VERSION, GAME_VERSION ); trap_SetConfigstring( CS_LEVEL_START_TIME, va("%i", level.startTime ) ); G_SpawnString( "music", "", &text ); trap_SetConfigstring( CS_MUSIC, text ); G_SpawnString( "message", "", &text ); trap_SetConfigstring( CS_MESSAGE, text ); // map specific message trap_SetConfigstring( CS_MOTD, g_motd.string ); // message of the day G_SpawnString( "gravity", "800", &text ); trap_Cvar_Set( "g_gravity", text ); G_SpawnString( "enableBreath", "0", &text ); trap_Cvar_Set( "g_enableBreath", text ); G_SpawnString( "soundSet", "default", &text ); trap_SetConfigstring( CS_GLOBAL_AMBIENT_SET, text ); g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD; g_entities[ENTITYNUM_WORLD].classname = "worldspawn"; // see if we want a warmup time trap_SetConfigstring( CS_WARMUP, "" ); if ( g_restarted.integer ) { trap_Cvar_Set( "g_restarted", "0" ); level.warmupTime = 0; } //Raz: Fix warmup #if 0 /* else if ( g_doWarmup.integer && g_gametype.integer != GT_DUEL && g_gametype.integer != GT_POWERDUEL ) { // Turn it on else if ( g_doWarmup.integer && level.gametype != GT_DUEL && level.gametype != GT_POWERDUEL ) { // Turn it on level.warmupTime = -1; trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) ); G_LogPrintf( "Warmup:\n" ); } */ #else else if ( g_doWarmup.integer && g_gametype.integer != GT_DUEL && g_gametype.integer != GT_POWERDUEL && g_gametype.integer != GT_SIEGE ) { // Turn it on level.warmupTime = -1; trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) ); G_LogPrintf( "Warmup:\n" ); } #endif trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+0, defaultStyles[0][0]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+1, defaultStyles[0][1]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+2, defaultStyles[0][2]); for(i=1;i<LS_NUM_STYLES;i++) { Com_sprintf(temp, sizeof(temp), "ls_%dr", i); G_SpawnString(temp, defaultStyles[i][0], &text); lengthRed = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+0, text); Com_sprintf(temp, sizeof(temp), "ls_%dg", i); G_SpawnString(temp, defaultStyles[i][1], &text); lengthGreen = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+1, text); Com_sprintf(temp, sizeof(temp), "ls_%db", i); G_SpawnString(temp, defaultStyles[i][2], &text); lengthBlue = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+2, text); if (lengthRed != lengthGreen || lengthGreen != lengthBlue) { Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", i, lengthRed, lengthGreen, lengthBlue); } } }
void turretG2_set_models( gentity_t *self, qboolean dying ) { if ( dying ) { if ( !(self->spawnflags&SPF_TURRETG2_TURBO) ) { self->s.modelindex = G_ModelIndex( name2 ); self->s.modelindex2 = G_ModelIndex( name ); } trap_G2API_RemoveGhoul2Model( &self->ghoul2, 0 ); G_KillG2Queue( self->s.number ); self->s.modelGhoul2 = 0; /* trap_G2API_InitGhoul2Model( &self->ghoul2, name2, 0, //base->s.modelindex, //note, this is not the same kind of index - this one's referring to the actual //index of the model in the g2 instance, whereas modelindex is the index of a //configstring -rww 0, 0, 0, 0); */ } else { if ( !(self->spawnflags&SPF_TURRETG2_TURBO) ) { self->s.modelindex = G_ModelIndex( name ); self->s.modelindex2 = G_ModelIndex( name2 ); //set the new onw trap_G2API_InitGhoul2Model( &self->ghoul2, name, 0, //base->s.modelindex, //note, this is not the same kind of index - this one's referring to the actual //index of the model in the g2 instance, whereas modelindex is the index of a //configstring -rww 0, 0, 0, 0); } else { self->s.modelindex = G_ModelIndex( name3 ); //set the new onw trap_G2API_InitGhoul2Model( &self->ghoul2, name3, 0, //base->s.modelindex, //note, this is not the same kind of index - this one's referring to the actual //index of the model in the g2 instance, whereas modelindex is the index of a //configstring -rww 0, 0, 0, 0); } self->s.modelGhoul2 = 1; if ( (self->spawnflags&SPF_TURRETG2_TURBO) ) { //larger self->s.g2radius = 128; } else { self->s.g2radius = 80; } if ( (self->spawnflags&SPF_TURRETG2_TURBO) ) { //different pitch bone and muzzle flash points G2Tur_SetBoneAngles(self, "pitch", vec3_origin); self->genericValue11 = trap_G2API_AddBolt( self->ghoul2, 0, "*muzzle1" ); self->genericValue12 = trap_G2API_AddBolt( self->ghoul2, 0, "*muzzle2" ); } else { G2Tur_SetBoneAngles(self, "Bone_body", vec3_origin); self->genericValue11 = trap_G2API_AddBolt( self->ghoul2, 0, "*flash03" ); } } }
void SetupGameGhoul2Model(gclient_t *client, char *modelname) { int handle; char afilename[MAX_QPATH]; char /**GLAName,*/ *slash; char GLAName[MAX_QPATH]; vec3_t tempVec = {0,0,0}; // First things first. If this is a ghoul2 model, then let's make sure we demolish this first. if (client->ghoul2 && trap_G2_HaveWeGhoul2Models(client->ghoul2)) { trap_G2API_CleanGhoul2Models(&(client->ghoul2)); } /* Com_sprintf( afilename, sizeof( afilename ), "models/players/%s/model.glm", modelname ); handle = trap_G2API_InitGhoul2Model(&client->ghoul2, afilename, 0, 0, -20, 0, 0); if (handle<0) { Com_sprintf( afilename, sizeof( afilename ), "models/players/kyle/model.glm" ); handle = trap_G2API_InitGhoul2Model(&client->ghoul2, afilename, 0, 0, -20, 0, 0); if (handle<0) { return; } } */ //rww - just load the "standard" model for the server" if (!precachedKyle) { Com_sprintf( afilename, sizeof( afilename ), "models/players/kyle/model.glm" ); handle = trap_G2API_InitGhoul2Model(&precachedKyle, afilename, 0, 0, -20, 0, 0); if (handle<0) { return; } } if (precachedKyle && trap_G2_HaveWeGhoul2Models(precachedKyle)) { trap_G2API_DuplicateGhoul2Instance(precachedKyle, &client->ghoul2); } else { return; } // The model is now loaded. GLAName[0] = 0; if (!BGPAFtextLoaded) { //get the location of the animation.cfg //GLAName = trap_G2API_GetGLAName( client->ghoul2, 0); trap_G2API_GetGLAName( client->ghoul2, 0, GLAName); if (!GLAName[0]) { if (!BG_ParseAnimationFile("models/players/_humanoid/animation.cfg")) { Com_Printf( "Failed to load animation file %s\n", afilename ); return; } return; } Q_strncpyz( afilename, GLAName, sizeof( afilename )); slash = Q_strrchr( afilename, '/' ); if ( slash ) { strcpy(slash, "/animation.cfg"); } // Now afilename holds just the path to the animation.cfg else { // Didn't find any slashes, this is a raw filename right in base (whish isn't a good thing) return; } // Try to load the animation.cfg for this model then. if ( !BG_ParseAnimationFile( afilename ) ) { // The GLA's animations failed if (!BG_ParseAnimationFile("models/players/_humanoid/animation.cfg")) { Com_Printf( "Failed to load animation file %s\n", afilename ); return; } } } trap_G2API_AddBolt(client->ghoul2, 0, "*r_hand"); trap_G2API_AddBolt(client->ghoul2, 0, "*l_hand"); // NOTE - ensure this sequence of bolt and bone accessing are always the same because the client expects them in a certain order trap_G2API_SetBoneAnim(client->ghoul2, 0, "model_root", 0, 12, BONE_ANIM_OVERRIDE_LOOP, 1.0f, level.time, -1, -1); trap_G2API_SetBoneAngles(client->ghoul2, 0, "upper_lumbar", tempVec, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, level.time); trap_G2API_SetBoneAngles(client->ghoul2, 0, "cranium", tempVec, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_Y, POSITIVE_X, NULL, 0, level.time); if (!g2SaberInstance) { trap_G2API_InitGhoul2Model(&g2SaberInstance, "models/weapons2/saber/saber_w.glm", 0, 0, -20, 0, 0); if (g2SaberInstance) { // indicate we will be bolted to model 0 (ie the player) on bolt 0 (always the right hand) when we get copied trap_G2API_SetBoltInfo(g2SaberInstance, 0, 0); // now set up the gun bolt on it trap_G2API_AddBolt(g2SaberInstance, 0, "*flash"); } } if (g2SaberInstance) { trap_G2API_CopySpecificGhoul2Model(g2SaberInstance, 0, client->ghoul2, 1); } }