Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
|
08-30-2015
, 08:46
[TF2] Make a completely custom projectile that hits players and the world
|
#1
|
I want to make a projectile that can hit both the world and players.
I'm using a stock from super zombie fortress.
The models I'm testing are:
"models/effects/bday_gib04.mdl",
"models/player/items/scout/soccer_ball.mdl"
For some reason, the soccer ball makes the world shake every time it hits the world, so I can't really use it.
The bday gib is shaped like a circular cake.
The problem is that neither of these will contact players - they just move through them. Ideally, I want them to be able to trigger Touch functions on players, and still move through them.
I'm trying to make the thrown projectiles be able to hit players directly:
https://www.youtube.com/watch?v=sKPxNQ0clDg
Spoiler
PHP Code:
enum // Collision_Group_t in const.h
{
COLLISION_GROUP_NONE = 0,
COLLISION_GROUP_DEBRIS, // Collides with nothing but world and static stuff
COLLISION_GROUP_DEBRIS_TRIGGER, // Same as debris, but hits triggers
COLLISION_GROUP_INTERACTIVE_DEBRIS, // Collides with everything except other interactive debris or debris
COLLISION_GROUP_INTERACTIVE, // Collides with everything except interactive debris or debris
COLLISION_GROUP_PLAYER,
COLLISION_GROUP_BREAKABLE_GLASS,
COLLISION_GROUP_VEHICLE,
COLLISION_GROUP_PLAYER_MOVEMENT, // For HL2, same as Collision_Group_Player, for
// TF2, this filters out other players and CBaseObjects
COLLISION_GROUP_NPC, // Generic NPC group
COLLISION_GROUP_IN_VEHICLE, // for any entity inside a vehicle
COLLISION_GROUP_WEAPON, // for any weapons that need collision detection
COLLISION_GROUP_VEHICLE_CLIP, // vehicle clip brush to restrict vehicle movement
COLLISION_GROUP_PROJECTILE, // Projectiles!
COLLISION_GROUP_DOOR_BLOCKER, // Blocks entities not permitted to get near moving doors
COLLISION_GROUP_PASSABLE_DOOR, // ** sarysa TF2 note: Must be scripted, not passable on physics prop (Doors that the player shouldn't collide with)
COLLISION_GROUP_DISSOLVING, // Things that are dissolving are in this group
COLLISION_GROUP_PUSHAWAY, // ** sarysa TF2 note: I could swear the collision detection is better for this than NONE. (Nonsolid on client and server, pushaway in player code)
COLLISION_GROUP_NPC_ACTOR, // Used so NPCs in scripts ignore the player.
COLLISION_GROUP_NPC_SCRIPTED, // USed for NPCs in scripts that should not collide with each other
LAST_SHARED_COLLISION_GROUP
};
enum // SolidFlags_t
{
FSOLID_CUSTOMRAYTEST = 0x0001, // Ignore solid type + always call into the entity for ray tests
FSOLID_CUSTOMBOXTEST = 0x0002, // Ignore solid type + always call into the entity for swept box tests
FSOLID_NOT_SOLID = 0x0004, // Are we currently not solid?
FSOLID_TRIGGER = 0x0008, // This is something may be collideable but fires touch functions
// even when it's not collideable (when the FSOLID_NOT_SOLID flag is set)
FSOLID_NOT_STANDABLE = 0x0010, // You can't stand on this
FSOLID_VOLUME_CONTENTS = 0x0020, // Contains volumetric contents (like water)
FSOLID_FORCE_WORLD_ALIGNED = 0x0040, // Forces the collision rep to be world-aligned even if it's SOLID_BSP or SOLID_VPHYSICS
FSOLID_USE_TRIGGER_BOUNDS = 0x0080, // Uses a special trigger bounds separate from the normal OBB
FSOLID_ROOT_PARENT_ALIGNED = 0x0100, // Collisions are defined in root parent's local coordinate space
FSOLID_TRIGGER_TOUCH_DEBRIS = 0x0200, // This trigger will touch debris objects
FSOLID_MAX_BITS = 10
};
enum //SolidType_t
{
SOLID_NONE = 0, // no solid model
SOLID_BSP = 1, // a BSP tree
SOLID_BBOX = 2, // an AABB
SOLID_OBB = 3, // an OBB (not implemented yet)
SOLID_OBB_YAW = 4, // an OBB, constrained so that it can only yaw
SOLID_CUSTOM = 5, // Always call into the entity for tests
SOLID_VPHYSICS = 6, // solid vphysics object, get vcollide from the model and collide with that
SOLID_LAST,
};
stock fxCreateModelThrown(
const String:strModel[],
client,
// bool:isOwned,
// bool:isSolid,
const Float:pos[3] = {0.0, ...},
const Float:ang[3] = {0.0, ...},
Float:force = 0.0,
const color[4] = {255, ...})
{
new ent = CreateEntityByName("prop_physics_multiplayer");
if(IsValidEntity(ent))
{
// Pre-configure prop.
SetEntPropEnt(ent, Prop_Data, "m_hOwnerEntity", client);
SetEntProp(ent, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_DEBRIS);
SetEntProp(ent, Prop_Data, "m_usSolidFlags", FSOLID_TRIGGER|FSOLID_NOT_STANDABLE);
SetEntProp(ent, Prop_Data, "m_nSolidType", SOLID_VPHYSICS);
SetEntPropFloat(ent, Prop_Data, "m_flFriction", 10000.0);
SetEntPropFloat(ent, Prop_Data, "m_massScale", 100.0); // Keep low to prevent physics damage
SetEntityMoveType(ent, MOVETYPE_VPHYSICS);
SetEntityModel(ent, strModel);
SetEntityRenderColor(ent, color[0], color[1], color[2], color[3]);
// Spawn prop.
DispatchSpawn(ent);
// Post-configure prop.
AcceptEntityInput(ent, "DisableDamageForces");
AcceptEntityInput(ent, "DisableShadow");
// Orient and teleport prop.
decl Float:vec[3];
GetAngleVectors(ang, vec, NULL_VECTOR, NULL_VECTOR);
ScaleVector(vec, force);
TeleportEntity(ent, pos, ang, vec);
SDKHook(ent, SDKHook_StartTouch, OnSpectreSlimeTouch);
SDKHook(ent, SDKHook_Touch, OnSpectreSlimeTouch);
}
else
{
LogError("[ZF] fxCreateModelThrown (%s, %d) failed.", strModel, client);
}
return ent;
}
public Action:OnSpectreSlimeTouch(iSlime, iOther)
{
if (IsLivingPlayer(iOther))
{
CPrintToChdata("slimeball hits %N", iOther); // THIS NEVER FIRES, NO MESSAGE PRINTS
}
return Plugin_Continue;
}
__________________
Last edited by Chdata; 08-30-2015 at 11:26.
|
|