Mapbase v2.0; bulk commit

- Added custom map compile tools (vbsp, vvis, vrad)
- Changed blink fix (shouldn't change anything in-game)
- Added auto-completion to ent_create, npc_create, and the main set of "npc_" debug commands
- Added ent_create_aimed, an ent_create equivalent of npc_create_aimed
- Made hunters start using the "vs. player" melee animation against smaller NPCs that look weird with the "stab" attack
- Added "explosion_sparks" convar, which fixes broken code for giving explosions sparks (disabled by default because of how different it looks)
- Made interaction code capable of being dispatched on any entity, not just combat characters
- Added npc_barnacle_ignite convar, which lets barnacles be ignited by flares
- Fixed certain NPCs getting out of the way for the player when they hate them
- Fixed auto-generated "speak" scene responses not using parameters that work on real VCDs
- Made "stop_on_nonidle" capable of being used in any mod, not just HL2 episodic mods
- Selectable color for ragdoll boogie/point_ragdollboogie
- Fixed PickupWeaponInstant not firing weapon pickup outputs
- Introduced inputs and keyvalues for "lerping" to math_counter_advanced
- Fixed ClearConsole on logic_console
- logic_convar should now detect client convars correctly
- New NormalizeAngles input on math_vector
- logic_modelinfo LookupActivity input
- math_generate fixed and expanded to be more like math_counter
- Added a WIP game logging system for playtesting maps
- Introduced logic_playerinfo, an entity that can read a player's name or ID
- Fixed some new filters not working with filter_multi
- Added radius pickup spawnflag to func_physbox
- Added "Preserve name" spawnflag to weapons
- Added cc_achievement_debug message for when an achievement doesn't exist
- Made npc_combine_s not speak while in logic_choreographed_scenes
- Fixed zombie torsos/legs/headcrabs not being serverside when zombie is forced to server ragdoll
- Expanded and cleaned up npc_zombie_custom
- Fixed func_commandredirects not cleaning up correctly and sometimes crashing the game
- Allowed player squad commands to go through +USE-held objects
- Added a bunch of I/O/KV to trigger_waterydeath for better configuration
- Changed save comment system to use the chapter title from world properties, and the ability to suppress the title popup that normally results from it
- Adjusted game_convar_mod for MP planning
- Removed the func_precipitation custom particle/splash code for now, as it was causing problems
- Fixed env_global_light not accepting lightcolor
- Added "Additional Buttons" to player_speedmod
- Added save comment to RPC
- Added env_projectedtexture attenuation
- Added scripted_sequence OnPreIdleSequence
- Added OnCrab to zombies
- Added skill_changed game event (may need further testing)
- Added a fix for viewmodels flipping under extreme FOV values
- Added code that allows mappers to change the skin on shotgunners without it usually flipping back randomly
- Fixed a very, very, very major shader performance issue
- New SetAbsOrigin/Angles inputs on all entities, analogous to SetLocalOrigin/Angles
- Code improvements for I/O involving angles
- logic_entity_position improvements/fixes, including a new OutAngles output that outputs the angles on position calls
- Alternate collision/player avoidance spawnflag obsoletion enforcement disabled
- Enable/DisableHazardLights inputs on the EP2 jalopy, equivalent to the keyvalue
- Miscellaneous shader formatting adjustments and fixes
- Fixed AlwaysDrawOff on env_projectedtexture not being a valid input
This commit is contained in:
Blixibon
2019-12-14 04:20:02 +00:00
parent a1dba884a3
commit dc7f20acc8
97 changed files with 2845 additions and 485 deletions

View File

@@ -390,6 +390,149 @@ void CC_NPC_Focus( const CCommand &args )
static ConCommand npc_focus("npc_focus", CC_NPC_Focus, "Displays red line to NPC's enemy (if has one) and blue line to NPC's target entity (if has one)\n\tArguments: {npc_name} / {npc class_name} / no argument picks what player is looking at", FCVAR_CHEAT);
ConVar npc_create_equipment("npc_create_equipment", "");
#ifdef MAPBASE
extern int EntityFactory_AutoComplete( const char *cmdname, CUtlVector< CUtlString > &commands, CUtlRBTree< CUtlString > &symbols, char *substring, int checklen = 0 );
extern bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs );
//------------------------------------------------------------------------------
// Purpose: Create an NPC of the given type
//------------------------------------------------------------------------------
class CNPCCreateAutoCompletionFunctor : public ICommandCallback, public ICommandCompletionCallback
{
public:
virtual bool CreateAimed() { return false; }
virtual void CommandCallback( const CCommand &args )
{
MDLCACHE_CRITICAL_SECTION();
bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
CBaseEntity::SetAllowPrecache( true );
// Try to create entity
CAI_BaseNPC *baseNPC = dynamic_cast< CAI_BaseNPC * >( CreateEntityByName(args[1]) );
if (baseNPC)
{
baseNPC->KeyValue( "additionalequipment", npc_create_equipment.GetString() );
if ( args.ArgC() == 3 )
{
baseNPC->SetName( AllocPooledString( args[2] ) );
}
else if ( args.ArgC() > 3 )
{
baseNPC->SetName( AllocPooledString( args[2] ) );
// Pass in any additional parameters.
for ( int i = 3; i + 1 < args.ArgC(); i += 2 )
{
const char *pKeyName = args[i];
const char *pValue = args[i+1];
baseNPC->KeyValue( pKeyName, pValue );
}
}
DispatchSpawn(baseNPC);
// Now attempt to drop into the world
CBasePlayer* pPlayer = UTIL_GetCommandClient();
trace_t tr;
Vector forward;
QAngle angles;
pPlayer->EyeVectors( &forward );
bool bCreateAimed = CreateAimed();
if (bCreateAimed)
{
VectorAngles( forward, angles );
angles.x = 0;
angles.z = 0;
}
AI_TraceLine(pPlayer->EyePosition(),
pPlayer->EyePosition() + forward * MAX_TRACE_LENGTH,MASK_NPCSOLID,
pPlayer, COLLISION_GROUP_NONE, &tr );
if ( tr.fraction != 1.0)
{
if (baseNPC->CapabilitiesGet() & bits_CAP_MOVE_FLY)
{
Vector pos = tr.endpos - forward * 36;
baseNPC->Teleport( &pos, bCreateAimed ? &angles : NULL, NULL );
}
else
{
// Raise the end position a little up off the floor, place the npc and drop him down
tr.endpos.z += 12;
baseNPC->Teleport( &tr.endpos, bCreateAimed ? &angles : NULL, NULL );
UTIL_DropToFloor( baseNPC, MASK_NPCSOLID );
}
// Now check that this is a valid location for the new npc to be
Vector vUpBit = baseNPC->GetAbsOrigin();
vUpBit.z += 1;
AI_TraceHull( baseNPC->GetAbsOrigin(), vUpBit, baseNPC->GetHullMins(), baseNPC->GetHullMaxs(),
MASK_NPCSOLID, baseNPC, COLLISION_GROUP_NONE, &tr );
if ( tr.startsolid || (tr.fraction < 1.0) )
{
baseNPC->SUB_Remove();
DevMsg("Can't create %s. Bad Position!\n",args[1]);
NDebugOverlay::Box(baseNPC->GetAbsOrigin(), baseNPC->GetHullMins(), baseNPC->GetHullMaxs(), 255, 0, 0, 0, 0);
}
}
else if (bCreateAimed)
{
baseNPC->Teleport( NULL, &angles, NULL );
}
baseNPC->Activate();
}
CBaseEntity::SetAllowPrecache( allowPrecache );
}
virtual int CommandCompletionCallback( const char *partial, CUtlVector< CUtlString > &commands )
{
if ( !g_pGameRules )
{
return 0;
}
const char *cmdname = CreateAimed() ? "npc_create_aimed" : "npc_create";
char *substring = (char *)partial;
if ( Q_strstr( partial, cmdname ) )
{
substring = (char *)partial + strlen( cmdname ) + 1;
}
int checklen = Q_strlen( substring );
if (checklen <= 0)
{
// Only show classnames prefixed with "npc" unless the user starts typing other characters
substring = "npc";
checklen = 3;
}
CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc );
return EntityFactory_AutoComplete( cmdname, commands, symbols, substring, checklen );
}
};
static CNPCCreateAutoCompletionFunctor g_NPCCreateAutoComplete;
static ConCommand npc_create("npc_create", &g_NPCCreateAutoComplete, "Creates an NPC of the given type where the player is looking (if the given NPC can actually stand at that location).\n\tArguments: {npc_class_name}", FCVAR_CHEAT, &g_NPCCreateAutoComplete);
class CNPCCreateAimedAutoCompletionFunctor : public CNPCCreateAutoCompletionFunctor
{
public:
virtual bool CreateAimed() { return true; }
};
static CNPCCreateAimedAutoCompletionFunctor g_NPCCreateAimedAutoComplete;
static ConCommand npc_create_aimed("npc_create_aimed", &g_NPCCreateAimedAutoComplete, "Creates an NPC aimed away from the player of the given type where the player is looking (if the given NPC can actually stand at that location).\n\tArguments: {npc_class_name}", FCVAR_CHEAT, &g_NPCCreateAimedAutoComplete);
#else
//------------------------------------------------------------------------------
// Purpose: Create an NPC of the given type
//------------------------------------------------------------------------------
@@ -540,6 +683,7 @@ void CC_NPC_Create_Aimed( const CCommand &args )
CBaseEntity::SetAllowPrecache( allowPrecache );
}
static ConCommand npc_create_aimed("npc_create_aimed", CC_NPC_Create_Aimed, "Creates an NPC aimed away from the player of the given type where the player is looking (if the given NPC can actually stand at that location). Note that this only works for npc classes that are already in the world. You can not create an entity that doesn't have an instance in the level.\n\tArguments: {npc_class_name}", FCVAR_CHEAT);
#endif
//------------------------------------------------------------------------------
// Purpose: Destroy unselected NPCs
@@ -711,6 +855,134 @@ void CC_NPC_Reset( void )
}
static ConCommand npc_reset("npc_reset", CC_NPC_Reset, "Reloads schedules for all NPC's from their script files\n\tArguments: -none-", FCVAR_CHEAT);
#ifdef MAPBASE
extern bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs );
//------------------------------------------------------------------------------
// Purpose : Auto-completes with entities in the entity list, but only uses NPC-derived entities.
// Input : cmdname - The name of the command.
// &commands - Where the complete autocompletes should be sent to.
// substring - The current search query. (only pool entities that start with this)
// checklen - The number of characters to check.
// Output : A pointer to a cUtlRBTRee containing all of the entities.
//------------------------------------------------------------------------------
static int AutoCompleteNPCs(const char *cmdname, CUtlVector< CUtlString > &commands, CUtlRBTree< CUtlString > &symbols, char *substring, int checklen = 0)
{
CBaseEntity *pos = NULL;
while ((pos = gEntList.NextEnt(pos)) != NULL)
{
if (!pos->IsNPC())
continue;
const char *name = pos->GetClassname();
if (pos->GetEntityName() == NULL_STRING || Q_strnicmp(STRING(pos->GetEntityName()), substring, checklen))
{
if (Q_strnicmp(pos->GetClassname(), substring, checklen))
continue;
}
else
name = STRING(pos->GetEntityName());
CUtlString sym = name;
int idx = symbols.Find(sym);
if (idx == symbols.InvalidIndex())
{
symbols.Insert(sym);
}
// Too many
if (symbols.Count() >= COMMAND_COMPLETION_MAXITEMS)
break;
}
// Now fill in the results
for (int i = symbols.FirstInorder(); i != symbols.InvalidIndex(); i = symbols.NextInorder(i))
{
const char *name = symbols[i].String();
char buf[512];
Q_strncpy(buf, name, sizeof(buf));
Q_strlower(buf);
CUtlString command;
command = CFmtStr("%s %s", cmdname, buf);
commands.AddToTail(command);
}
return symbols.Count();
}
//------------------------------------------------------------------------------
// There's a big set of NPC debug commands that do similar operations and
// can fall under this base class for auto-completion, etc.
//------------------------------------------------------------------------------
class CNPCDebugAutoCompletionFunctor : public ICommandCallback, public ICommandCompletionCallback
{
public:
virtual const char *CommandName() { return NULL; }
virtual void CommandCallback( const CCommand &args )
{
SetDebugBits( UTIL_GetCommandClient(), args[1], OVERLAY_NPC_NEAREST_BIT );
}
virtual int CommandCompletionCallback( const char *partial, CUtlVector< CUtlString > &commands )
{
if ( !g_pGameRules )
{
return 0;
}
const char *cmdname = CommandName();
char *substring = (char *)partial;
if ( Q_strstr( partial, cmdname ) )
{
substring = (char *)partial + strlen( cmdname ) + 1;
}
int checklen = Q_strlen( substring );
if (checklen == 0 || atoi(substring) != 0)
{
// Must be the picker or an entity index
return 0;
}
CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc );
return AutoCompleteNPCs(cmdname, commands, symbols, substring, checklen);
}
};
#define NPCDebugCommand(name, functor, bit, help) class CNPC##functor##AutoCompletionFunctor : public CNPCDebugAutoCompletionFunctor \
{ \
public: \
virtual const char *CommandName() { return #name; } \
virtual void CommandCallback( const CCommand &args ) \
{ \
SetDebugBits( UTIL_GetCommandClient(), args[1], bit ); \
} \
}; \
static CNPC##functor##AutoCompletionFunctor g_NPC##functor##AutoCompletionFunctor; \
static ConCommand name(#name, &g_NPC##functor##AutoCompletionFunctor, help, FCVAR_CHEAT, &g_NPC##functor##AutoCompletionFunctor);
NPCDebugCommand( npc_nearest, Nearest, OVERLAY_NPC_NEAREST_BIT, "Draw's a while box around the NPC(s) nearest node\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at " );
NPCDebugCommand( npc_route, Route, OVERLAY_NPC_ROUTE_BIT, "Displays the current route of the given NPC as a line on the screen. Waypoints along the route are drawn as small cyan rectangles. Line is color coded in the following manner:\n\tBlue - path to a node\n\tCyan - detour around an object (triangulation)\n\tRed - jump\n\tMaroon - path to final target position\n\tArguments: {npc_name} / {npc_class_name} / no argument picks what player is looking at " );
NPCDebugCommand( npc_select, Select, OVERLAY_NPC_SELECTED_BIT, "Select or deselects the given NPC(s) for later manipulation. Selected NPC's are shown surrounded by a red translucent box\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at " );
NPCDebugCommand( npc_combat, Combat, OVERLAY_NPC_SQUAD_BIT, "Displays text debugging information about the squad and enemy of the selected NPC (See Overlay Text)\n\tArguments: {npc_name} / {npc class_name} / no argument picks what player is looking at" );
NPCDebugCommand( npc_tasks, Tasks, OVERLAY_NPC_TASK_BIT, "Displays detailed text debugging information about the all the tasks of the selected NPC current schedule (See Overlay Text)\n\tArguments: {npc_name} / {npc class_name} / no argument picks what player is looking at " );
NPCDebugCommand( npc_task_text, TaskText, OVERLAY_TASK_TEXT_BIT, "Outputs text debugging information to the console about the all the tasks + break conditions of the selected NPC current schedule\n\tArguments: {npc_name} / {npc class_name} / no argument picks what player is looking at " );
NPCDebugCommand( npc_conditions, Conditions, OVERLAY_NPC_CONDITIONS_BIT, "Displays all the current AI conditions that an NPC has in the overlay text.\n\tArguments: {npc_name} / {npc class_name} / no argument picks what player is looking at" );
NPCDebugCommand( npc_viewcone, Viewcone, OVERLAY_NPC_VIEWCONE_BIT, "Displays the viewcone of the NPC (where they are currently looking and what the extents of there vision is)\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at" );
NPCDebugCommand( npc_relationships, Relationships, OVERLAY_NPC_RELATION_BIT, "Displays the relationships between this NPC and all others.\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at" );
NPCDebugCommand( npc_steering, Steering, OVERLAY_NPC_STEERING_REGULATIONS, "Displays the steering obstructions of the NPC( used to perform local avoidance )\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at" );
// For backwards compatibility
void CC_NPC_Squads( const CCommand &args )
{
SetDebugBits( UTIL_GetCommandClient(),args[1],OVERLAY_NPC_SQUAD_BIT);
}
static ConCommand npc_squads("npc_squads", CC_NPC_Squads, "Obsolete. Replaced by npc_combat", FCVAR_CHEAT);
#else
//------------------------------------------------------------------------------
// Purpose: Show the selected NPC's nearest node
//------------------------------------------------------------------------------
@@ -805,6 +1077,7 @@ void CC_NPC_ViewSteeringRegulations( const CCommand &args )
SetDebugBits( UTIL_GetCommandClient(), args[1], OVERLAY_NPC_STEERING_REGULATIONS);
}
static ConCommand npc_steering("npc_steering", CC_NPC_ViewSteeringRegulations, "Displays the steering obstructions of the NPC (used to perform local avoidance)\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at", FCVAR_CHEAT);
#endif
void CC_NPC_ViewSteeringRegulationsAll( void )
{