Page 1 of 1
bl_AIHitBox
Posted: Sun Aug 01, 2021 8:55 pm
by the-epsd
Hi there,
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; }
It would be great if we could have it use the same multiplier's that other players use.
Re: bl_AIHitBox
Posted: Mon Aug 02, 2021 6:51 am
by Lovatto
Hi,
You are right, there's not multiplier value for the bots Hit Boxes, I have to change that,
as for the moment you can replace the code of bl_AIHitBox.cs with this:
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);
}
}
Then you can set the multiplier for each hitbox in the bots prefabs -> select that player model collider e.g the Head bone -> bl_AIHitBox -> modify the DamageMultiplier property as needed.
Re: bl_AIHitBox
Posted: Mon Aug 02, 2021 10:57 am
by the-epsd
Thanks lovatto. Don't think this is working though. I've set every hitbox's multiplier to many different values and the damage numbers aren't changing. I have a script that shows the numbers the weapons are damaging - they're staying the same. Is there also a way to allow the headshot damage to be part of the multiplier? Instead of always being 100.
Re: bl_AIHitBox
Posted: Mon Aug 02, 2021 5:16 pm
by Lovatto
Sorry, the abpve script will only works for knife and explosion damage, here you have the code fixed:
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);
}
}