User-Profile-Image
hankin
  • 5
  • 关于
  • 分类
    • 路由器
    • 电脑相关
    • 游戏相关
    • 未分类
    • 服务器相关
    • 数据库
  • 页面
    • 关于
  • 友链
    • 华夏网盟
Help?

Please contact us on our email for need any support

Support
  • 关于
    首页   ›   游戏相关   ›   正文
游戏相关

求生之路 Hunter高扑伤害-源码

2021-02-23 08:51:45
117  0 0
#include <sourcemod>
#include <sdktools>
#define DMG_GENERIC   0

new Handle:hMaxPounceRange = INVALID_HANDLE;
new maxPounceDistance;
new Handle:hMinPounceRange = INVALID_HANDLE;
new minPounceDistance;
new Handle:hMaxPounceDamage = INVALID_HANDLE;
new maxPounceDamage;


//hunter position store
new Float:infectedPosition[MAXPLAYERS+1][3];
//support up to 32 slots on a server

//cvars + timers
new Handle:hCapDamage = INVALID_HANDLE;
new Handle:hPdpScale = INVALID_HANDLE;
new Handle:hScoredDmgEnabled = INVALID_HANDLE;
new Handle:hIncapDmg = INVALID_HANDLE;
new Handle:hIncapScale = INVALID_HANDLE;

new bool:HunterOnAir[MAXPLAYERS+1];
new bool:HunterPounced[MAXPLAYERS+1];
new Float:HunterTime[MAXPLAYERS+1];

public Plugin:myinfo =
{
 name = "hunter伤害",
 author = "小海",
 description = " ",
 version = "1.01",
 url = " "
}

public OnPluginStart()
{

 maxPounceDamage = 50;
 maxPounceDistance = 800;
 minPounceDistance = 100;

 AutoExecConfig(true,"l4d_hunterdamage");

   new h_GameMode = FindConVar("mp_gamemode");
 decl String:GameName[16];
 GetConVarString(h_GameMode, GameName, sizeof(GameName));
 new GameMode;
 if (StrEqual(GameName, "survival", false))
  GameMode = 3;
 else if (StrEqual(GameName, "versus", false) || StrEqual(GameName, "teamversus", false) || StrEqual(GameName, "scavenge", false) || StrEqual(GameName, "teamscavenge", false))
  GameMode = 2;
 else if (StrEqual(GameName, "coop", false) || StrEqual(GameName, "realism", false))
  GameMode = 1;
 else
 {
  GameMode = 0;
  }
 if(GameMode!=2)
 {
  HookEvent("lunge_pounce",Event_PlayerPounced);
  HookEvent("ability_use",Event_AbilityUse);
  HookEvent("player_death", Event_PlayerDeath);
  HookEvent("pounce_end", EventPounceEnd);
 }
}
public Action:EventPounceEnd(Handle:event, String:event_name[], bool:dontBroadcast)
{
  new userid = GetClientOfUserId(GetEventInt(event, "userid"));
  new stop = GetClientOfUserId(GetEventInt(event, "victim"));

 if(userid > 0 && HunterPounced[userid])// && HunterPounced[userid])
 {
  new class = GetEntProp(userid, Prop_Send, "m_zombieClass");
   if (class == 3)
  {
   if(!GetEntData(userid, FindSendPropInfo("CTerrorPlayer", "m_isGhost"), 1))
   {
    new flag=GetEntityFlags(userid);  //FL_ONGROUND
    if(flag & FL_ONGROUND)
    {
     HunterOnAir[userid]=false;
     HunterTime[userid]=0.0;
     HunterPounced[userid]=false;
     //PrintToChatAll("%N stop %N on ground ",stop, userid);
    }
    else
    {
     HunterTime[userid]=GetEngineTime();
     HunterOnAir[userid]=true;
     //PrintToChatAll("%N stop %N on air %f", stop, userid, HunterTime[userid]);
    }
   }
  }
 }
}
public Action:Event_PlayerDeath(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
 new ClientId   = 0;
 ClientId = GetClientOfUserId(GetEventInt(hEvent, "userid"));

 if (ClientId == 0)
 {
   return Plugin_Continue;
 }
  if(HunterPounced[ClientId] &&  HunterOnAir[ClientId] && GetClientTeam(ClientId) == 3)
 {
  new class = GetEntProp(ClientId, Prop_Send, "m_zombieClass");
  new attacker = GetClientOfUserId(GetEventInt(hEvent, "attacker"));
  if (class == 3 && attacker != 0 && GetClientTeam(attacker) ==2)
  {
   new Float:Time=GetEngineTime();
   new Float:f=Time-HunterTime[ClientId];
   if(f<0.05)
   {
    new r=GetRandomInt(0, 1);
    new bool:headshot=GetEventBool(hEvent, "headshot");
    switch(r)
    {
     case 0: Give(ClientId, "first_aid_kit");
     case 1: Give(ClientId, "pain_pills");
     case 2: Give(ClientId, "autoshotgun");
     case 3: Give(ClientId, "rifle");
     case 4: Give(ClientId, "hunting_rifle");
    }
    new Handle:h=CreateDataPack();
    WritePackCell(h, ClientId);
    WritePackCell(h, attacker);
    if(headshot)
    {
     Give(ClientId, "first_aid_kit");
     WritePackCell(h, 1);
     }
    else
    {
     WritePackCell(h, 0);
     }

    CreateTimer(1.0, Show, h);
   }
  }
 }
 HunterOnAir[ClientId]=false;
  HunterTime[ClientId]=0.0;
 HunterPounced[ClientId]=false;
 return Plugin_Continue;
}
public Action:Show(Handle:timer, Handle:h)
{
 ResetPack(h);
  new ClientId=ReadPackCell(h);
 new attacker=ReadPackCell(h);
 new headshot=ReadPackCell(h);
 CloseHandle(h);
 if(headshot==1)
 {
  PrintHintText(ClientId, "你被 %N 空中爆头了,哈哈哈", attacker);
  PrintHintText(attacker, "%N 被你空中爆头了,哈哈哈", ClientId);
 }
 else
 {
  PrintHintText(ClientId, "你被 %N 空中击毙了,哈哈哈", attacker);
  PrintHintText(attacker, "%N 被你空中击毙了,哈哈哈", ClientId);
 }
 ClientCommand(attacker, "vocalize PlayerLaugh");
}

Give(Client, String:itemId[])
{
 new String:command[] = "give";
 new flags = GetCommandFlags(command);
 SetCommandFlags(command, flags & ~FCVAR_CHEAT);
 FakeClientCommand(Client, "%s %s", command, itemId);
 SetCommandFlags(command, flags);
}
public Event_AbilityUse(Handle:event, const String:name[], bool:dontBroadcast)
{
 //ability_use returns ability = ability_lunge(hunter), ability_toungue(smoker), ability_vomit(boomer)
 //ability_charge(charger and ability_spit(spitter) (weirdly nothing for jockey though ;/)

 new client = GetClientOfUserId(GetEventInt(event, "userid"));
 //Save the location of the player who just pounced as hunter
 GetClientAbsOrigin(client,infectedPosition[client]);
 HunterOnAir[client]=false;
  HunterTime[client]=0.0;
 HunterPounced[client]=true;

}


public Event_PlayerPounced(Handle:event, const String:name[], bool:dontBroadcast)
{
  new Float:pouncePosition[3];
  new attackerId = GetEventInt(event, "userid");
  new victimId = GetEventInt(event, "victim");
  new attackerClient = GetClientOfUserId(attackerId);
  new victimClient = GetClientOfUserId(victimId);

  HunterOnAir[attackerClient]=false;
   HunterTime[attackerClient]=0.0;
  HunterPounced[attackerClient]=false;


  //if(IsFakeClient(attackerClient))return;



  ///////////////////////////////////////
  /////// CALCULATE INGAME DAMAGE ///////
  ///////////////////////////////////////


  //distance supplied isn't the actual 2d vector distance needed for damage calculation. See more about it at
  //http://forums.alliedmods.net/showthread.php?t=93207

  //get hunter-related pounce cvars
  new max = maxPounceDistance;
  new min = minPounceDistance;
  new maxdamage=maxPounceDamage;
  //Get current position while pounced
  GetClientAbsOrigin(attackerClient,pouncePosition);

  //Calculate 2d distance between previous position and pounce position
  new distance = RoundToNearest(GetVectorDistance(infectedPosition[attackerClient], pouncePosition));
  //PrintToChat(attackerClient, "mind %d, maxd %d, maxdamage %d, distance %d", min, max, maxdamage, distance);

  //If the jump is below the min to cause pounce damage, then stop running the plugin
  if(distance < minPounceDistance)return  ;

  //Get damage using hunter damage formula, done using floats for accuracy then rounded to an int (intDmg)
  new Float:dmg = (((distance - float(min)) / float(max - min)) * float(maxdamage)) + 1;
  new intDmg = RoundToFloor(dmg);

   DealDamage(victimClient,intDmg,attackerClient,DMG_GENERIC,"weapon hunter_claw");

  PrintHintText(attackerClient, "扑击伤害 %d", intDmg);
  PrintHintText(victimClient, "受到hunter扑击伤害 %d", intDmg);
  return;

}
DealDamage(victim,damage,attacker=0,dmg_type=DMG_GENERIC,String:weapon[]="")
{
 if(victim>0 && IsValidEdict(victim) && IsClientInGame(victim) && IsPlayerAlive(victim) && damage>0)
 {
  new String:dmg_str[16];
  IntToString(damage,dmg_str,16);
  new String:dmg_type_str[32];
  IntToString(dmg_type,dmg_type_str,32);
  new pointHurt=CreateEntityByName("point_hurt");
  if(pointHurt)
  {
   new String:N[20];
   Format(N, 20, "target%d", victim);
   DispatchKeyValue(victim,"targetname", N);
   DispatchKeyValue(pointHurt,"DamageTarget", N);
   DispatchKeyValue(pointHurt,"Damage",dmg_str);
   DispatchKeyValue(pointHurt,"DamageType",dmg_type_str);
   if(!StrEqual(weapon,""))
   {
    DispatchKeyValue(pointHurt,"classname",weapon);
   }
   DispatchSpawn(pointHurt);
   AcceptEntityInput(pointHurt,"Hurt",(attacker>0)?attacker:-1);
   DispatchKeyValue(pointHurt,"classname","point_hurt");
   //DispatchKeyValue(victim,"targetname","war3_donthurtme");
   RemoveEdict(pointHurt);
  }
 }
}



DealUnscoredDamage(victim,damage)
{
 new oldHealth = GetClientHealth(victim);
 new newHealth = oldHealth - damage;

 if(newHealth < 0)
 newHealth = 0;

 if(IsClientConnected(victim) && IsClientInGame(victim))
 SetEntityHealth(victim, newHealth);
}



//Used to set temp health, modified from code by TheDanner.
public SetTempHealth(client, hp)
{
 if(IsClientConnected(client) && IsClientInGame(client))
 {
  SetEntPropFloat(client, Prop_Send, "m_healthBufferTime", GetGameTime());

  new Float:fHp = 0.0 + hp;

  SetEntPropFloat(client, Prop_Send, "m_healthBuffer", fHp);

  return true;
 }
 else
 {
  return false;
 }
}

//Used to get temp health, modified from code by TheDanner.
public GetTempHealth(client)
{
 if(IsClientConnected(client) && IsClientInGame(client))
 {
  new Float:fullTemp = GetEntPropFloat(client, Prop_Send, "m_healthBuffer");

  new Float:tempStarted = GetEntPropFloat(client, Prop_Send, "m_healthBufferTime");

  new Float:decayRate = GetConVarFloat(FindConVar("pain_pills_decay_rate"));

  new Float:tempDuration = (tempStarted - GetGameTime()) * -1;

  new Float:fTempHp = fullTemp - (tempDuration * decayRate);

  new tempHp = RoundToFloor(fTempHp);

  if(tempHp < 0)
  tempHp = 0;

  return tempHp;
 }
 else
 {
  return 0;
 }
}
 
评论 (0)

Click here to cancel reply.

欢迎您 游客  

近期文章

  • 用于网速测试的下载测速文件合集
  • docker构建SB镜像
  • pterodactl docker install
  • OpenWRT流量实时监控插件
  • docker部署dify

近期评论

No comments to show.

归档

  • 1 月 2026
  • 8 月 2025
  • 5 月 2025
  • 4 月 2025
  • 3 月 2025
  • 2 月 2025
  • 12 月 2024
  • 4 月 2024
  • 10 月 2023
  • 8 月 2023
  • 4 月 2023
  • 3 月 2023
  • 2 月 2023
  • 10 月 2021
  • 5 月 2021
  • 3 月 2021
  • 2 月 2021

分类

  • 数据库
  • 服务器相关
  • 未分类
  • 游戏相关
  • 电脑相关
  • 路由器
Copyright © 2026
smarty_hankin 主题. Designed by hankin
主页
页面
  • 关于
博主
hkthomas 管理员
136 文章 0 评论 18367 浏览
测试
测试