Skip to content

Commit

Permalink
Recreated Inputs from prop_dynamic_ornament
Browse files Browse the repository at this point in the history
Added 2 stocks to LMCCore.inc

Mostly recreated bsides EF_NODRAW toggle
Added SetAttached
Added Detach
  • Loading branch information
LuxLuma committed Dec 10, 2019
1 parent cdc299b commit 8c14610
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions addons/sourcemod/scripting/include/LMCCore.inc
Expand Up @@ -240,6 +240,62 @@ stock void CPrintCenterTextAll(const char[] format, any ...)
}
}

//https://github.com/alliedmodders/hl2sdk/blob/0ef5d3d482157bc0bb3aafd37c08961373f87bfd/public/const.h#L281-L298
// entity effects
enum
{
EF_BONEMERGE = 0x001, // Performs bone merge on client side
EF_BRIGHTLIGHT = 0x002, // DLIGHT centered at entity origin
EF_DIMLIGHT = 0x004, // player flashlight
EF_NOINTERP = 0x008, // don't interpolate the next frame
EF_NOSHADOW = 0x010, // Don't cast no shadow
EF_NODRAW = 0x020, // don't draw entity
EF_NORECEIVESHADOW = 0x040, // Don't receive no shadow
EF_BONEMERGE_FASTCULL = 0x080, // For use with EF_BONEMERGE. If this is set, then it places this ent's origin at its
// parent and uses the parent's bbox + the max extents of the aiment.
// Otherwise, it sets up the parent's bones every frame to figure out where to place
// the aiment, which is inefficient because it'll setup the parent's bones even if
// the parent is not in the PVS.
EF_ITEM_BLINK = 0x100, // blink an item so that the user notices it.
EF_PARENT_ANIMATES = 0x200, // always assume that the parent entity is animating
EF_MAX_BITS = 10
};

/*
* Recreated "SetAttached" entity input from "prop_dynamic_ornament"
*/
stock void SetAttached(int iEntToAttach, int iEntToAttachTo)
{
SetVariantString("!activator");
AcceptEntityInput(iEntToAttach, "SetParent", iEntToAttachTo);

SetEntityMoveType(iEntToAttach, MOVETYPE_NONE);

SetEntProp(iEntToAttach, Prop_Send, "m_fEffects", EF_BONEMERGE|EF_BONEMERGE_FASTCULL|EF_PARENT_ANIMATES);

//thanks smlib for flag understanding
int iFlags = GetEntProp(iEntToAttach, Prop_Data, "m_usSolidFlags", 2);
iFlags = iFlags |= 0x0004;
SetEntProp(iEntToAttach, Prop_Data, "m_usSolidFlags", iFlags, 2);

TeleportEntity(iEntToAttach, view_as<float>({0.0, 0.0, 0.0}), view_as<float>({0.0, 0.0, 0.0}), NULL_VECTOR);
}

/*
* Recreated "Detach" entity input from "prop_dynamic_ornament"
* I have not included the EF_NODRAW effect flag, unlike the input
*/
stock void Detach(int iEntity)
{
AcceptEntityInput(iEntToAttach, "ClearParent");

//thanks smlib for flag understanding
int iFlags = GetEntProp(iEntToAttach, Prop_Data, "m_usSolidFlags", 2);
iFlags = iFlags |= 0x0004;
SetEntProp(iEntToAttach, Prop_Data, "m_usSolidFlags", iFlags, 2);

SetEntityMoveType(iEntToAttach, MOVETYPE_NONE);
}



Expand Down

0 comments on commit 8c14610

Please sign in to comment.