一键导入
amxx-modding-kit-api-entity-force
Helps with Entity Force API usage for applying forces to entities including pushing, momentum transfer, and physics simulation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Helps with Entity Force API usage for applying forces to entities including pushing, momentum transfer, and physics simulation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guide for implementing custom weapons using OOP-style patterns in AMX Mod X. Use when creating new weapons or extending existing ones with the Custom Weapons API.
This skill is describing how to use AMXX Modding Kit for AMX Mod X plugin development.
Helps with AMX Mod X (Pawn) coding conventions and best practices.
Best practices for organizing large AMX Mod X projects with multiple plugins sharing entities, weapons, events, and other definitions. Use when creating mod-scale projects that need consistent namespace patterns and shared constants.
Guide for Assets API usage managing models, sounds, and resources from JSON configuration files.
Guide for implementing custom entities using OOP-style patterns in AMX Mod X. Use when creating projectiles, pickups, NPCs, or any custom game entity with the Custom Entities API.
| name | amxx-modding-kit-api-entity-force |
| description | Helps with Entity Force API usage for applying forces to entities including pushing, momentum transfer, and physics simulation. |
api_entity_force)The Entity Force API provides physics-based force application to entities, supporting pushing, momentum transfer, and advanced force calculations.
Reference: See api_entity_force.inc for all available natives.
This API allows you to:
// Add force vector to entity
new Float:vecForce[3] = {0.0, 0.0, 500.0}; // Upward force
EntityForce_Add(pEntity, vecForce);
// Forces are accumulated and applied together
EntityForce_Add(pEntity, vecForce1);
EntityForce_Add(pEntity, vecForce2);
EntityForce_Apply(pEntity); // Apply all accumulated forces
// Clear all pending forces without applying
EntityForce_Clear(pEntity);
// Push target entity away from source entity
EntityForce_AddFromEntity(pTarget, pSourceEntity, flForce);
// Push entity away from a point
new Float:vecExplosionOrigin[3] = {100.0, 200.0, 50.0};
EntityForce_AddFromOrigin(pEntity, vecExplosionOrigin, 500.0);
For more complex push calculations based on overlap depth:
// Push entity based on overlap with a bounding box
EntityForce_AddFromBBox(
pEntity,
vecAbsMin, // BBox min corner
vecAbsMax, // BBox max corner
flForce, // Force magnitude
EntityForce_Flag_None,
0.0, // Min depth ratio
1.0, // Max depth ratio
0.0, // Soft min (gradual force start)
1.0 // Soft max (gradual force end)
);
Transfer velocity/momentum from one entity to another:
// Transfer momentum from projectile to target
EntityForce_TransferMomentum(pProjectile, pTarget, 1.0); // Full transfer
// Partial transfer (knockback effect)
EntityForce_TransferMomentum(pProjectile, pTarget, 0.5); // 50% transfer
Use flags to modify force application behavior:
enum EntityForce_Flags {
EntityForce_Flag_None = 0,
EntityForce_Flag_Set, // Replace existing forces
EntityForce_Flag_Overlap, // Overlap mode
EntityForce_Flag_ForceSetOutOfSoft,
EntityForce_Flag_Launch, // Launch entity
EntityForce_Flag_Attack // Attack impulse
};
// Set force (replace existing)
EntityForce_Add(pEntity, vecForce, EntityForce_Flag_Set);
// Launch entity upward
new Float:vecLaunch[3] = {0.0, 0.0, 800.0};
EntityForce_Add(pEntity, vecLaunch, EntityForce_Flag_Launch);
CreateExplosion(const Float:vecOrigin[3], Float:flRadius, Float:flForce) {
for (new pPlayer = 1; pPlayer <= MaxClients; ++pPlayer) {
if (!is_user_alive(pPlayer)) continue;
static Float:vecPlayerOrigin[3]; pev(pPlayer, pev_origin, vecPlayerOrigin);
static Float:flDistance; flDistance = get_distance_f(vecOrigin, vecPlayerOrigin);
if (flDistance > flRadius) continue;
// Scale force by distance
static Float:flScaledForce; flScaledForce = flForce * (1.0 - (flDistance / flRadius));
EntityForce_AddFromOrigin(pPlayer, vecOrigin, flScaledForce);
EntityForce_Apply(pPlayer);
}
}
@Projectile_Touch(const this, const pTarget) {
CE_CallBaseMethod(pTarget);
if (IS_PLAYER(pTarget)) {
// Transfer projectile momentum to target
EntityForce_TransferMomentum(this, pTarget, 0.3);
EntityForce_Apply(pTarget);
}
}
@TriggerPush_Touch(const this, const pTarget) {
static Float:vecPushDir[3]; pev(this, pev_movedir, vecPushDir);
static Float:flSpeed; pev(this, pev_speed, flSpeed);
static Float:vecForce[3];
xs_vec_mul_scalar(vecPushDir, flSpeed, vecForce);
EntityForce_Add(pTarget, vecForce);
EntityForce_Apply(pTarget);
}
Hook into force events:
// Called when force is added to entity
public EntityForce_OnForceAdd(const pEntity, const Float:vecForce[3], EntityForce_Flags:iFlags) {
// Modify or block force...
}
// Called when forces are applied
public EntityForce_OnForceApply(const pEntity, const Float:vecForce[3]) {
// React to force application...
}
EntityForce_Add to accumulate forcesEntityForce_Apply to apply accumulated forcesEntityForce_AddFromOrigin for explosion-style knockbackEntityForce_TransferMomentum for projectile impacts