Помощь по избавлению от Orpheu.

Сообщения
108
Реакции
109
Этот плагин возвращает много игровой механики от Counter-Strike 1.3. Раньше использовали Orpheu, есть ли способы избавить его от Orpheu. Сразу скажу, что в скриптинге 0. Описание исправь там или там я не пойму)
Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <orpheu>
#include <orpheu_memory>
#include <orpheu_advanced>



#define PLUGIN "Counter-Strike 1.3"
#define VERSION "0.11"
#define AUTHOR "dook"

#define WEAPON_C4    "weapon_c4"
#define WEAPON_AWP    "weapon_awp"

#define CS13_AIR_PISTOLS    "cs13_air_pistols"
#define CS13_C4_JUMP        "cs13_c4_jump"
#define CS13_C4_MOVE        "cs13_c4_move"
#define CS13_AWP_DELAY        "cs13_awp_delay"
#define CS13_BUNNY_HOP        "cs13_bunny_hop"
#define CS13_AUTO_BUNNY_HOP    "cs13_auto_bunny_hop"
#define CS13_USE_SLOWDOWN    "cs13_use_slowdown"

#define BUNNY_HOP_REGULAR    1
#define BUNNY_HOP_ACCELRATE    2

#define MAXSPEED_C4        250.0
#define DELAY_AWP        "0.75"
#define USE_SLOWDOWN    0.3

#define DIFF_LINUX_ENT        4
#define DIFF_LINUX_PLAYER    5

#define m_pPlayer                41
#define m_flNextAttack            83
#define m_flNextPrimaryAttack    46
#define m_flNextSecondaryAttack    47



new const Float:zeroVector[] = {0.0, 0.0, 0.0};
new const pistols[][] = {"weapon_p228", "weapon_elite", "weapon_fiveseven", "weapon_usp", "weapon_glock18", "weapon_deagle"};



new cs13_air_pistols;
new cs13_c4_jump;
new cs13_c4_move;
new cs13_awp_delay;
new cs13_bunny_hop;
new cs13_auto_bunny_hop;
new cs13_use_slowdown;



new Float:oldVelocity[3];
new oldFlags;
new playerEntityId;
new Float:oldMaxSpeed;

new bunnyValue;
new OrpheuStruct:ppmove;



public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
  
    registerCVars();

    hookPistols();
  
    // C4 Hooks
    RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_C4, "onC4PrimaryAttackPre", 0);
    RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_C4, "onC4PrimaryAttackPost", 1);
  
    // AWP Hooks
    RegisterHam(Ham_Item_Deploy, WEAPON_AWP, "onAWPDeployPost", 1);
  
    OrpheuRegisterHook(OrpheuGetFunction("PM_Duck"), "onPMDuckPost", OrpheuHookPost);
    OrpheuRegisterHook(OrpheuGetFunction("PM_Move"), "onPMMove");
    OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "onPMJumpPre", OrpheuHookPre);
    OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "onPMJumpPost", OrpheuHookPost);
    OrpheuRegisterHook(OrpheuGetFunction("KickBack", "CBasePlayerWeapon"), "onKickBack");
}

public OrpheuHookReturn:onKickBack(weaponId, Float:upBase, Float:latBase, Float:upMod, Float:latMod, Float:upMax, Float:latMax, dirChange) {
/*
    client_print(0, print_chat, "upBase: %f, latBase: %f, upMod: %f, latMod: %f, upMax: %f, latMax: %f, dirChange: %d", upBase, latBase, upMod, latMod, upMax, latMax, dirChange);
  
    OrpheuSetParam(2, 0.0);
    OrpheuSetParam(3, 0.0);
    OrpheuSetParam(4, 0.0);
    OrpheuSetParam(5, 0.0);
    OrpheuSetParam(6, 0.0);
    OrpheuSetParam(7, 0.0);
*/
  
    return OrpheuIgnored;
}

public registerCVars() {
    cs13_air_pistols = register_cvar(CS13_AIR_PISTOLS, "1", FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_c4_jump = register_cvar(CS13_C4_JUMP, "1", FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_c4_move = register_cvar(CS13_C4_MOVE, "1", FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_awp_delay = register_cvar(CS13_AWP_DELAY, DELAY_AWP, FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_bunny_hop = register_cvar(CS13_BUNNY_HOP, "1", FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_auto_bunny_hop = register_cvar(CS13_AUTO_BUNNY_HOP, "0", FCVAR_SERVER | FCVAR_ARCHIVE);
    cs13_use_slowdown = register_cvar(CS13_USE_SLOWDOWN, "1", FCVAR_SERVER | FCVAR_ARCHIVE);
}

// Hook all pistols
public hookPistols() {
    new ndx;
  
    for (ndx = 0; ndx < sizeof pistols; ndx++) {
        RegisterHam(Ham_Weapon_PrimaryAttack, pistols[ndx], "onPistolPrimaryAttackPre", 0);
        RegisterHam(Ham_Weapon_PrimaryAttack, pistols[ndx], "onPistolPrimaryAttackPost", 1);
    }
}



/* Pistol Accuracy */

public onPistolPrimaryAttackPre(weaponId) {
    playerEntityId = get_pdata_cbase(weaponId, m_pPlayer, DIFF_LINUX_ENT);
  
    if (get_pcvar_num(cs13_air_pistols)) {
      
        oldFlags = entity_get_int(playerEntityId, EV_INT_flags);
        entity_get_vector(playerEntityId, EV_VEC_velocity, oldVelocity);
      
        // Make the attack function think we're on the ground
        entity_set_int(playerEntityId, EV_INT_flags, oldFlags | FL_ONGROUND);
      
        // If we're already in the air, make the attack function think we're not moving.
        // Not sure if this needs to be here.
        if (oldFlags & FL_ONGROUND) {
            entity_set_vector(playerEntityId, EV_VEC_velocity, zeroVector);
        }
      
        return HAM_HANDLED;
    }
  
    return HAM_IGNORED;
}

public onPistolPrimaryAttackPost(weaponId) {
    if (get_pcvar_num(cs13_air_pistols)) {
        //Restore old values
        entity_set_int(playerEntityId, EV_INT_flags, oldFlags);
        entity_set_vector(playerEntityId, EV_VEC_velocity, oldVelocity);
      
        return HAM_HANDLED;
    }
  
    return HAM_IGNORED;
}



/* Planting */

public onC4PrimaryAttackPre(weaponId) {
    playerEntityId = get_pdata_cbase(weaponId, m_pPlayer, DIFF_LINUX_ENT);
  
    if (get_pcvar_num(cs13_c4_jump)) {
        oldFlags = entity_get_int(playerEntityId, EV_INT_flags);
      
        // Make the plant function think we're on the ground
        entity_set_int(playerEntityId, EV_INT_flags, oldFlags | FL_ONGROUND);
      
        return HAM_HANDLED;
    }

    return HAM_IGNORED;
}

public onC4PrimaryAttackPost(weaponId) {
    if (get_pcvar_num(cs13_c4_jump)) {
        // Restore old value
        entity_set_int(playerEntityId, EV_INT_flags, oldFlags);
    }
  
    if (get_pcvar_num(cs13_c4_move)) {
        // Allow player to move while planting
        entity_set_float(playerEntityId, EV_FL_maxspeed, MAXSPEED_C4);
    }
  
    return HAM_HANDLED;
}



/* AWP */

public onAWPDeployPost(weaponId) {
    static Float:delay;
  
    delay = get_pcvar_float(cs13_awp_delay);
  
    if (delay > 0.0) {
        playerEntityId = get_pdata_cbase(weaponId, m_pPlayer, DIFF_LINUX_ENT);
      
        // Decrease the awp delay
        set_pdata_float(weaponId, m_flNextPrimaryAttack, delay + 0.01, DIFF_LINUX_ENT);
        set_pdata_float(weaponId, m_flNextSecondaryAttack, delay, DIFF_LINUX_ENT);
        set_pdata_float(playerEntityId, m_flNextAttack, delay, DIFF_LINUX_PLAYER);
    }
  
    return HAM_HANDLED;
}

/* Bunny Hop */

public OrpheuHookReturn:onPMMove(OrpheuStruct:pmove,server) {
    ppmove = pmove;
}

public OrpheuHookReturn:onPMJumpPre(id) {
    static autoBunnyValue;

    autoBunnyValue = get_pcvar_num(cs13_auto_bunny_hop);
    bunnyValue = get_pcvar_num(cs13_bunny_hop);
  
    if (autoBunnyValue) {
        OrpheuSetStructMember(ppmove, "oldbuttons", OrpheuGetStructMember(ppmove, "oldbuttons") & ~IN_JUMP);
    }
  
    if (bunnyValue) {
        if (bunnyValue == BUNNY_HOP_ACCELRATE) {
            oldMaxSpeed = Float:OrpheuGetStructMember(ppmove, "maxspeed");
            OrpheuSetStructMember(ppmove, "maxspeed", 0.0);
        }
    }
  
    return OrpheuIgnored;
}

public OrpheuHookReturn:onPMJumpPost(id) {
    if (bunnyValue) {
        OrpheuSetStructMember(ppmove, "fuser2", 0.0);

        if (bunnyValue == BUNNY_HOP_ACCELRATE) {
            OrpheuSetStructMember(ppmove, "maxspeed", oldMaxSpeed);
        }
    }

    return OrpheuIgnored;
}

/* Use slowdown */

public OrpheuHookReturn:onPMDuckPost() {
    static useSlowdownValue;
    static Float:velocity[3];
  
    useSlowdownValue = get_pcvar_num(cs13_use_slowdown);
  
    if (useSlowdownValue && OrpheuGetStructMember(ppmove, "onground") != -1 &&
     OrpheuGetStructMember(OrpheuStruct:OrpheuGetStructMember(ppmove, "cmd"), "buttons") & IN_USE) {
        OrpheuGetStructMember(ppmove, "velocity", velocity);
      
        velocity[0] *= USE_SLOWDOWN;
        velocity[1] *= USE_SLOWDOWN;
      
        OrpheuSetStructMember(ppmove, "velocity", velocity);
    }
}
 

Вложения

Последнее редактирование:
Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
Функции по оружию и бомбе - можно на замену сделать нынче.
По прыжкам так сразу не скажу, но хуки duck & jump так же уже присутствуют.
 
Сообщения
584
Реакции
1,006
Помог
18 раз(а)
В reapi на данный момент только PM_Move, PM_AirMove есть. В хаме не изменишь pm_
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу