| 1982 | } |
| 1983 | |
| 1984 | void G_ChangePlayerModel( gentity_t *ent, const char *newModel ) |
| 1985 | { |
| 1986 | if ( !ent || !ent->client || !newModel ) |
| 1987 | { |
| 1988 | return; |
| 1989 | } |
| 1990 | |
| 1991 | G_RemovePlayerModel( ent ); |
| 1992 | if ( Q_stricmp( "player", newModel ) == 0 ) |
| 1993 | { |
| 1994 | G_InitPlayerFromCvars( ent ); |
| 1995 | return; |
| 1996 | } |
| 1997 | |
| 1998 | //attempt to free the string (currently can't since it's always "player" ) |
| 1999 | if( ent->NPC_type && gi.bIsFromZone(ent->NPC_type, TAG_G_ALLOC) ) { |
| 2000 | gi.Free(ent->NPC_type); |
| 2001 | } |
| 2002 | ent->NPC_type = G_NewString( newModel ); |
| 2003 | G_RemoveWeaponModels( ent ); |
| 2004 | |
| 2005 | if ( strchr(newModel,'|') ) |
| 2006 | { |
| 2007 | char name[MAX_QPATH]; |
| 2008 | strcpy(name, newModel); |
| 2009 | char *p = strchr(name, '|'); |
| 2010 | *p=0; |
| 2011 | p++; |
| 2012 | |
| 2013 | if ( strstr(p, "model_default" ) ) |
| 2014 | G_SetG2PlayerModel( ent, name, NULL, NULL, NULL ); |
| 2015 | else |
| 2016 | G_SetG2PlayerModel( ent, name, p, NULL, NULL ); |
| 2017 | } |
| 2018 | else |
| 2019 | { |
| 2020 | //FIXME: everything but force powers gets reset, those should, too... |
| 2021 | // currently leaves them as is except where otherwise noted in the NPCs.cfg? |
| 2022 | //FIXME: remove all weapons? |
| 2023 | if ( NPC_ParseParms( ent->NPC_type, ent ) ) |
| 2024 | { |
| 2025 | G_AddWeaponModels( ent ); |
| 2026 | NPC_SetAnim( ent, SETANIM_LEGS, ent->client->ps.legsAnim, SETANIM_FLAG_NORMAL|SETANIM_FLAG_RESTART ); |
| 2027 | NPC_SetAnim( ent, SETANIM_TORSO, ent->client->ps.torsoAnim, SETANIM_FLAG_NORMAL|SETANIM_FLAG_RESTART ); |
| 2028 | ClientUserinfoChanged( ent->s.number ); |
| 2029 | //Ugh, kind of a hack for now: |
| 2030 | if ( ent->client->NPC_class == CLASS_BOBAFETT |
| 2031 | || ent->client->NPC_class == CLASS_ROCKETTROOPER ) |
| 2032 | { |
| 2033 | //FIXME: remove saber, too? |
| 2034 | Boba_Precache(); // player as boba? |
| 2035 | } |
| 2036 | } |
| 2037 | else |
| 2038 | { |
| 2039 | gi.Printf( S_COLOR_RED"G_ChangePlayerModel: cannot find NPC %s\n", newModel ); |
| 2040 | G_ChangePlayerModel( ent, "stormtrooper" ); //need a better fallback? |
| 2041 | } |
no test coverage detected