L4D2 Vscript Helpers: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Sometimes an idea for a function is not immediately available in the List of VScript Functions. This function library was built to help you get more functions for your code....") |
No edit summary |
||
Line 3: | Line 3: | ||
This function library was built to help you get more functions for your code. | This function library was built to help you get more functions for your code. | ||
<source lang=cpp> | |||
/* | |||
Eyal282's helper scripts: | |||
*/ | |||
/** | /** | ||
* Checks whether or not an entity is in the starting safe room | * Checks whether or not an entity is in the starting safe room | ||
Line 78: | Line 83: | ||
return false; | return false; | ||
} | } | ||
/* | |||
Anonymous's helper scripts: | |||
*/ | |||
function IsMissionFinale() | |||
{ | |||
if(IsMissionFinalMap()) | |||
{ | |||
return true; | |||
} | |||
return false; | |||
} | |||
</source> |
Revision as of 10:35, 19 March 2022
Sometimes an idea for a function is not immediately available in the List of VScript Functions.
This function library was built to help you get more functions for your code.
/*
Eyal282's helper scripts:
*/
/**
* Checks whether or not an entity is in the starting safe room
*
* @param entity Entity to check
* @return true if entity is in start safe room, false otherwise.
* @notes This works for the safe area on the first chapter of a campaign.
*/
function IsEntityInStartSafeRoom(entity)
{
local origin = entity.GetOrigin();
local navArea = NavMesh.GetNearestNavArea(origin, 2048, true, true);
if(navArea != null)
{
// https://developer.valvesoftware.com/wiki/List_of_L4D_Series_Nav_Mesh_Attributes
if(navArea.HasSpawnAttributes(2048) && GetFlowPercentForPosition(origin, false) <= 50.0)
{
return true;
}
}
return false;
}
/**
* Checks whether or not an entity is in the ending safe room
*
* @param entity Entity to check
* @return true if entity is in end safe room, false otherwise.
* @notes It is unknown whether or not this works for rescue vehicles.
*/
function IsEntityInEndSafeRoom(entity)
{
local origin = entity.GetOrigin();
local navArea = NavMesh.GetNearestNavArea(origin, 2048, true, true);
if(navArea != null)
{
// https://developer.valvesoftware.com/wiki/List_of_L4D_Series_Nav_Mesh_Attributes
if(navArea.HasSpawnAttributes(2048) && GetFlowPercentForPosition(origin, false) >= 50.0)
{
return true;
}
}
return false;
}
/**
* Checks whether or not an player owns a weapon by its classname
*
* @param player player to check
* @param classname classname string to check
* @return true if player has the weapon in inventory, false otherwise
*/
function DoesPlayerHaveWeapon(player, classname)
{
local ent = null;
while ( ent = Entities.FindByClassname( ent, classname ) )
{
if(ent.GetOwnerEntity() == player)
{
return true;
}
}
return false;
}
/*
Anonymous's helper scripts:
*/
function IsMissionFinale()
{
if(IsMissionFinalMap())
{
return true;
}
return false;
}