How can we make it so the headshot damage for AI is a multiplier instead of a static value?
Currently, it looks like this:
Code: Select all
if (AI == null)
return;
if (isHead) { damage = 100; }
We move to Discord!
Our Discord community has grown fast and is now much more active; we decide to move entirely to our Discord server to offer support; this forum will be in read-mode only for the time being, join us on Discord: https://discord.gg/8zF5B4G
Code: Select all
if (AI == null)
return;
if (isHead) { damage = 100; }
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bl_AIHitBox : MonoBehaviour, IMFPSDamageable
{
public bl_AIShooterHealth AI;
public Collider m_Collider;
public float damageMultiplier = 1;
public bool isHead = false;
public int ID = 0;
public void DoDamage(int damage, string wn, Vector3 direction, int viewID, bool fromBot, Team team)
{
if (AI == null)
return;
damage = Mathf.FloorToInt(damage * damageMultiplier);
AI.DoDamage(damage, wn, direction, viewID, fromBot, team, isHead, ID);
}
public void ReceiveDamage(DamageData damageData)
{
if (AI == null)
return;
if (isHead) { damageData.Damage = 100; }
string weaponName = bl_GameData.Instance.GetWeapon(damageData.GunID).Name;
//if was not killed by a listed weapon
if(damageData.GunID < 0)
{
//try to find the custom weapon name
var iconData = bl_KillFeed.Instance.GetCustomIconByIndex(Mathf.Abs(damageData.GunID + 1));
if (iconData != null)
{
weaponName = $"cmd:{iconData.Name}";
}
}
AI.DoDamage(damageData.Damage, weaponName, damageData.Direction, damageData.ActorViewID, !damageData.MFPSActor.isRealPlayer, damageData.MFPSActor.Team, isHead, ID);
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bl_AIHitBox : MonoBehaviour, IMFPSDamageable
{
public bl_AIShooterHealth AI;
public Collider m_Collider;
public float damageMultiplier = 1;
public bool isHead = false;
public int ID = 0;
public void DoDamage(int damage, string wn, Vector3 direction, int viewID, bool fromBot, Team team)
{
if (AI == null)
return;
damage = Mathf.FloorToInt(damage * damageMultiplier);
AI.DoDamage(damage, wn, direction, viewID, fromBot, team, isHead, ID);
}
public void ReceiveDamage(DamageData damageData)
{
if (AI == null)
return;
damageData.Damage = Mathf.FloorToInt(damageData.Damage * damageMultiplier);
string weaponName = bl_GameData.Instance.GetWeapon(damageData.GunID).Name;
//if was not killed by a listed weapon
if(damageData.GunID < 0)
{
//try to find the custom weapon name
var iconData = bl_KillFeed.Instance.GetCustomIconByIndex(Mathf.Abs(damageData.GunID + 1));
if (iconData != null)
{
weaponName = $"cmd:{iconData.Name}";
}
}
AI.DoDamage(damageData.Damage, weaponName, damageData.Direction, damageData.ActorViewID, !damageData.MFPSActor.isRealPlayer, damageData.MFPSActor.Team, isHead, ID);
}
}