bl_AIHitBox

General support.
Post Reply
User avatar
the-epsd
New Member
New Member
Posts: 4
Joined: Sun Dec 13, 2020 7:11 pm

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.

Image
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

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.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
the-epsd
New Member
New Member
Posts: 4
Joined: Sun Dec 13, 2020 7:11 pm

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.
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

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);
    }
}
How to find your Invoice Number: Here
How to find your Order Number: Here
Post Reply