marlboro
Участник
- Сообщения
- 146
- Реакции
- 36
Требуется человек который перепишет скилл longjump из thc_rpg в smrpg
Игра CSGO
--- Добавлено позже ---
Тема более не актуальна просьба удалить тему
PHP:
/*
* ============================================================================
*
* [THC RPG] Total HardCore RPG
*
* File: longjump.inc
* Type: Upgrade
* Description: Gives you the ability to jump a longer distance
* Author: ArsiRC
*
* Copyright (C) 2009-2011 ArsiRC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================================
*/
/**
* This module's identifier.
*/
new Module:g_modulelongjump;
new g_longjumpUpgradeConfigCache[UpgradeConfigs];
/**
* Register this module.
*/
longjump_Register()
{
// Define all the module's data as layed out by enum ModuleData in project.inc.
new moduledata[ModuleData];
moduledata[ModuleData_Disabled] = false;
moduledata[ModuleData_Hidden] = false;
strcopy(moduledata[ModuleData_ShortName], MM_DATA_SHORTNAME, "longjump");
strcopy(moduledata[ModuleData_FullName], MM_DATA_FULLNAME, "LongJump");
strcopy(moduledata[ModuleData_Description], MM_DATA_DESCRIPTION, "Gives you the ability to jump a longer distance");
new Module:dependencies[MM_DATA_DEPENDENCIES];
dependencies[0] = g_moduleCore;
dependencies[1] = INVALID_MODULE;
moduledata[ModuleData_Dependencies] = dependencies;
new Module:interlocks[MM_DATA_INTERLOCKS];
interlocks[0] = INVALID_MODULE;
moduledata[ModuleData_Interlocks] = interlocks;
moduledata[ModuleData_TeamLock] = 0;
moduledata[ModuleData_MaxLevel] = 5;
moduledata[ModuleData_Cost] = 20;
moduledata[ModuleData_iCost] = 15;
// Send this array of data to the module manager.
g_modulelongjump = ModuleMgr_Register(moduledata);
// Now register the events we're going to use.
#if defined EVENT_MANAGER
EventMgr_RegisterEvent(g_modulelongjump, "Event_OnEventsRegister", "longjump_OnEventsRegister");
#endif
// Register config file(s) that this module will use.
#if defined CONFIG_MANAGER
ConfigMgr_Register(g_modulelongjump, "longjump_OnConfigReload", "configs/thc_rpg/longjump.txt");
#endif
}
/**
* Register all events here.
*/
public longjump_OnEventsRegister()
{
// Register all the events needed for this module.
EventMgr_RegisterEvent(g_modulelongjump, "Event_OnMapStart", "longjump_OnMapStart");
#if defined PROJECT_GAME_CSS
EventMgr_RegisterEvent(g_modulelongjump, "Event_PlayerJump", "longjump_PlayerJump");
#endif
}
/**
* All modules and events have been registered by this point. Event priority can be changed here.
*/
public longjump_OnEventsReady()
{
}
#if defined CONFIG_MANAGER
/**
* Called when a registered config file (by this module) is manually reloaded.
*/
public longjump_OnConfigReload(configindex)
{
#if defined LOG_MANAGER
LogMgr_Print(g_modulelongjump, LogType_Normal, "longjumpConfigReload", "Reloaded longjump module's config (index %d)", configindex);
#endif
ConfigMgr_CacheKv(g_modulelongjump, CM_CONFIGINDEX_FIRST, "longjumpModule_ConfigCache");
}
/**
* Read config values
*/
public KvCache:longjumpModule_ConfigCache(Handle:kv, sectionindex, const String:sectionname[])
{
// Read Upgrade config
if(StrEqual(sectionname, "longjump", false))
{
g_longjumpUpgradeConfigCache[UpgradeConfig_Disable] = KvGetNum(kv, "disable");
g_longjumpUpgradeConfigCache[UpgradeConfig_TeamLock] = KvGetNum(kv, "teamlock");
g_longjumpUpgradeConfigCache[UpgradeConfig_Effects] = KvGetNum(kv, "effects");
g_longjumpUpgradeConfigCache[UpgradeConfig_MaxLevel] = KvGetNum(kv, "maxlevel");
g_longjumpUpgradeConfigCache[UpgradeConfig_Cost] = KvGetNum(kv, "cost");
g_longjumpUpgradeConfigCache[UpgradeConfig_iCost] = KvGetNum(kv, "icost");
g_longjumpUpgradeConfigCache[UpgradeConfig_Percent] = KvGetFloat(kv, "percent");
if(g_longjumpUpgradeConfigCache[UpgradeConfig_Disable]==1)
ModuleMgr_Disable(g_modulelongjump);
ModuleMgr_WriteCell(g_modulelongjump, ModuleData_TeamLock, g_longjumpUpgradeConfigCache[UpgradeConfig_TeamLock]);
ModuleMgr_WriteCell(g_modulelongjump, ModuleData_MaxLevel, g_longjumpUpgradeConfigCache[UpgradeConfig_MaxLevel]);
ModuleMgr_WriteCell(g_modulelongjump, ModuleData_Cost, g_longjumpUpgradeConfigCache[UpgradeConfig_Cost]);
ModuleMgr_WriteCell(g_modulelongjump, ModuleData_iCost, g_longjumpUpgradeConfigCache[UpgradeConfig_iCost]);
}
else
ModuleMgr_Disable(g_modulelongjump);
}
#endif
/**
* The map has started.
*/
public longjump_OnMapStart()
{
#if defined CONFIG_MANAGER
ConfigMgr_CacheKv(g_modulelongjump, CM_CONFIGINDEX_FIRST, "longjumpModule_ConfigCache");
#endif
}
/**
* Client has jumped.
*
* @param client The client index.
*/
public longjump_PlayerJump(client)
{
if(IsValidPlayer(client))
if(GetClientTeam(client)!=g_longjumpUpgradeConfigCache[UpgradeConfig_TeamLock])
{
new level=GetPlayerUpgradeLevel(client,g_modulelongjump);
if(level>0)
{
new Float:velocity[3]={0.0,0.0,0.0};
GetHorizontalVelocity(client,velocity);
velocity[0]+=velocity[0]*level*g_longjumpUpgradeConfigCache[UpgradeConfig_Percent];
velocity[1]+=velocity[1]*level*g_longjumpUpgradeConfigCache[UpgradeConfig_Percent];
SetVelocityVector(client,velocity);
// Make fire-colored beam that follows the player
if(g_longjumpUpgradeConfigCache[UpgradeConfig_Effects])
{
new color[4]={66,170,255,127};
BeamFollowEffect("@all",client,0.3,1.0,1.0,color);
}
}
}
}
PHP:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma newdecls required
#include <smrpg>
#define UPGRADE_SHORTNAME "ljump"
ConVar g_hCVIncrease;
ConVar g_hCVIncreaseStart;
float g_fLJumpPreviousVelocity[MAXPLAYERS+1][3];
float g_fLJumpPlayerJumped[MAXPLAYERS+1];
public Plugin myinfo =
{
name = "SM:RPG Upgrade > Long Jump",
author = "Jannik \"Peace-Maker\" Hartung",
description = "Long Jump upgrade for SM:RPG. Boosts players jump speed.",
version = SMRPG_VERSION,
url = "http://www.wcfan.de/"
}
public void OnPluginStart()
{
HookEventEx("player_footstep", Event_OnResetJump);
HookEvent("player_spawn", Event_OnResetJump);
HookEvent("player_death", Event_OnResetJump);
LoadTranslations("smrpg_stock_upgrades.phrases");
}
public void OnPluginEnd()
{
if(SMRPG_UpgradeExists(UPGRADE_SHORTNAME))
SMRPG_UnregisterUpgradeType(UPGRADE_SHORTNAME);
}
public void OnAllPluginsLoaded()
{
OnLibraryAdded("smrpg");
}
public void OnLibraryAdded(const char[] name)
{
// Register this upgrade in SM:RPG
if(StrEqual(name, "smrpg"))
{
SMRPG_RegisterUpgradeType("Long Jump", UPGRADE_SHORTNAME, "Boosts your jump speed.", 10, true, 5, 20, 15);
SMRPG_SetUpgradeTranslationCallback(UPGRADE_SHORTNAME, SMRPG_TranslateUpgrade);
g_hCVIncrease = SMRPG_CreateUpgradeConVar(UPGRADE_SHORTNAME, "smrpg_ljump_inc", "0.10", "Percent of player's jump distance to increase per level.", 0, true, 0.01);
g_hCVIncreaseStart = SMRPG_CreateUpgradeConVar(UPGRADE_SHORTNAME, "smrpg_ljump_incstart", "0.20", "Percent of player's initial jump distance to increase per level.", 0, true, 0.01);
}
}
/**
* SM:RPG Upgrade callbacks
*/
public void SMRPG_TranslateUpgrade(int client, const char[] shortname, TranslationType type, char[] translation, int maxlen)
{
if(type == TranslationType_Name)
Format(translation, maxlen, "%T", UPGRADE_SHORTNAME, client);
else if(type == TranslationType_Description)
{
char sDescriptionKey[MAX_UPGRADE_SHORTNAME_LENGTH+12] = UPGRADE_SHORTNAME;
StrCat(sDescriptionKey, sizeof(sDescriptionKey), " description");
Format(translation, maxlen, "%T", sDescriptionKey, client);
}
}
public void OnClientDisconnect(int client)
{
g_fLJumpPlayerJumped[client] = -1.0;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
static int s_iLastButtons[MAXPLAYERS+1] = {0,...};
if(!IsClientInGame(client) || !IsPlayerAlive(client))
return Plugin_Continue;
// Make sure to reset the time when the player stops. Maybe he didn't took a step so player_footstep wasn't fired yet.
float vVelocity[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVelocity);
if(vVelocity[0] == 0.0 && vVelocity[1] == 0.0 && vVelocity[2] == 0.0)
g_fLJumpPlayerJumped[client] = -1.0;
bool bFirstJump = g_fLJumpPlayerJumped[client] < 0.0;
// Player started to press space - or what ever is bound to jump..
if(buttons & IN_JUMP && !(s_iLastButtons[client] & IN_JUMP))
{
// Make sure the player is on the ground and not on a ladder.
if(GetEntityFlags(client) & FL_ONGROUND && GetEntityMoveType(client) != MOVETYPE_LADDER)
{
g_fLJumpPreviousVelocity[client] = vVelocity;
g_fLJumpPlayerJumped[client] = GetEngineTime();
}
}
if(g_fLJumpPlayerJumped[client] > 0.0)
{
if(vVelocity[2] > g_fLJumpPreviousVelocity[client][2])
{
LJump_HasJumped(client, vVelocity, bFirstJump);
g_fLJumpPlayerJumped[client] = -1.0;
}
}
s_iLastButtons[client] = buttons;
return Plugin_Continue;
}
public void Event_OnResetJump(Event event, const char[] error, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(!client)
return;
// Don't reset the jumping right after the player jumped.
// In CSGO the player_footstep event is fired right before the player takes off. Ignore that one event.
if(g_fLJumpPlayerJumped[client] > 0.0 && (GetEngineTime() - g_fLJumpPlayerJumped[client]) > 0.003)
g_fLJumpPlayerJumped[client] = -1.0;
}
void LJump_HasJumped(int client, float vVelocity[3], bool bFirstJump)
{
if(!SMRPG_IsEnabled())
return;
int upgrade[UpgradeInfo];
SMRPG_GetUpgradeInfo(UPGRADE_SHORTNAME, upgrade);
if(!upgrade[UI_enabled])
return;
// Are bots allowed to use this upgrade?
if(IsFakeClient(client) && SMRPG_IgnoreBots())
return;
// Player didn't buy this upgrade yet.
int iLevel = SMRPG_GetClientUpgradeLevel(client, UPGRADE_SHORTNAME);
if(iLevel <= 0)
return;
if(!SMRPG_RunUpgradeEffect(client, UPGRADE_SHORTNAME))
return; // Some other plugin doesn't want this effect to run
float fMultiplicator;
// The first jump receives a bigger boost to get away from dangerous places quickly.
if(bFirstJump)
fMultiplicator = g_hCVIncreaseStart.FloatValue;
else
fMultiplicator = g_hCVIncrease.FloatValue;
float fIncrease = fMultiplicator * float(iLevel) + 1.0;
vVelocity[0] *= fIncrease;
vVelocity[1] *= fIncrease;
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVelocity);
}
--- Добавлено позже ---
Тема более не актуальна просьба удалить тему
Последнее редактирование: