Beispiel #1
0
 public HammerEvent(HitInfo info, BasePlayer player)
 {
     _info = info;
     basePlayer = player;
     string bonename = StringPool.Get(info.HitBone);
     HitBone = bonename == "" ? "unknown" : bonename;
 }
Beispiel #2
0
 private EventManager()
 {
     this.initializedFlag = false;
     this.initializedListener = null;
     this.hitInfoListener = null;
     this.lastHitInfo = null;
 }
Beispiel #3
0
 public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
 {
     RealHitInfo realHit = new RealHitInfo();
     realHit.HitStuff = Surface;
     realHit.Pigment = Pigment;
     realHit.Normal = new Line();
     realHit.Normal.Start = by.Project(hit.HitDist);
     realHit.Normal.Direct.Dx = 0;
     realHit.Normal.Direct.Dy = 0;
     realHit.Normal.Direct.Dz = 0;
     switch (hit.SurfaceIndex)
     {
         case 0:
             Point hitLoc2 = inv.Apply(realHit.Normal.Start);
             realHit.Normal.Direct.Dx = hitLoc2.X;
             realHit.Normal.Direct.Dy = hitLoc2.Y;
             realHit.Normal.Direct.Dz = hitLoc2.Z;
             break;
         default:
             throw new InvalidOperationException("Invalid surface index in hitdata");
     }
     Vector before = realHit.Normal.Direct;
     realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
     if (realHit.Normal.Direct.Dot(by.Direct) > 0)
     {
         realHit.Normal.Direct.ScaleSelf(-1.0);
     }
     return realHit;
 }
	public void killedPlayer(HitInfo hit)
	{
		totalKills++; // increment total kills
		if (hit.player.nickname != null)
			playerKills [hit.player.nickname]++; // increment player kills - use nickname
		translateKillToScore (hit.pokemon.level); // transalte kill to score
	}
Beispiel #5
0
 public override void Kill()
 {
     var info = new HitInfo();
     info.damageTypes.Add(Rust.DamageType.Suicide, 100f);
     info.Initiator = baseNPC as BaseEntity;
     baseNPC.Die(info);
 }
	public override void OnFire(HitInfo hit)
	{
		bool canFire = true;

		if(interval)
		{
			if(Time.time - lastGunshotTime < gunshotInterval)
			{
				canFire = false;
			}
			else
			{
				lastGunshotTime = Time.time;
			}
		}

		if(canFire)
		{		
			AudioChannel audioChannel = audioManager.PlayAt(gunshot, ((Firearm)Weapon).Position);
			if(audioChannel != null)
			{
				audioChannel.Pitch = Random.Range(gunshotPitchRange.x, gunshotPitchRange.y);
				SetSpatialBlend(audioChannel);
			}
		}
	}
	private void Kill()
	{
		HitInfo hitInfo = new HitInfo(Entity, Entity, Vector3.zero, Vector3.zero, "Untagged");
		DamageInfo damageInfo = new DamageInfo(hitInfo, health.CurrentHealth);

		GlobalEvents.Invoke(new WeaponDamageEvent(null, damageInfo));
	}
	private void Damage(float damage)
	{
		HitInfo hitInfo = new HitInfo(Entity, Entity, Vector3.zero, Vector3.zero, "Untagged");
		DamageInfo damageInfo = new DamageInfo(hitInfo, damage);

		GlobalEvents.Invoke(new WeaponDamageEvent(null, damageInfo));
	}
 public BuildingPartDestroyedEvent(BuildingBlock buildingBlock, HitInfo info)
 {
     BuildingPart = new BuildingPart(buildingBlock);
     Info = info;
     string bonename = StringPool.Get(info.HitBone);
     HitBone = bonename == "" ? "unknown" : bonename;
 }
Beispiel #10
0
    /// <summary>
    /// Recieve an attackValue.
    /// </summary>
    /// <param name="sender">Who sent the attackValue.</param>
    /// <param name="hitInfo">Attack info associated with the attackValue.</param>
    public virtual void RecieveHit(List<object> senders, int hitID, HitInfo hitInfo)
    {
        if (hitID == lastHitID) return;

        if (invincible) return;

        lastHitID = hitID;

        int damage = hitInfo.damage;

        // status effect
        if (hitInfo.effect != HitInfo.Effects.None)
        {
            damage = Mathf.CeilToInt(damage * statusEffectivenesses[(int)hitInfo.effect]);
            if (damage > 0)
            {
                Log(hitInfo.effect + ":" + (int)hitInfo.effect, Debugger.LogTypes.Combat);
                StopAllCoroutines();
                StartCoroutine(statusMethods[(int)hitInfo.effect], damage);
            }
        }

        ChangeHealth(-damage);
        CreateIndicator(damage);

        //if (HitEvent != null)
        //{
        //    HitEvent(senders, new HitEventArgs(hitInfo, currentHealth, damage));
        //}
        if (HitEvent != null)
        {
            HitEvent(senders, new HitEventArgs(hitInfo, currentHealth, damage));
        }
    }
Beispiel #11
0
	protected override void PrimaryFire()
	{

		for (int i = 0; i < pelletCount; i++) //for each pellet, shoot one in a random direction based off the cone
		{

			RaycastHit hit;

			//Bullet recoil stuff and it's direction
			Quaternion fireRot = Quaternion.LookRotation(transform.forward);
			Quaternion randomRot = Random.rotation;
			float currentSpread = bulletSpreadCurve.Evaluate(fireTime / timeTillMaxSpreadAngle) * maxBulletSpreadAngle; //changes bulllet angle
			fireRot = Quaternion.RotateTowards(fireRot, randomRot, Random.Range(0.0f, currentSpread)); //randomises it within said cone


			if (Physics.Raycast(transform.position, fireRot * Vector3.forward, out hit, Mathf.Infinity))
			{
				HitInfo hitInfo = new HitInfo(); //send hitInfo stuff
				hitInfo.damage = damage;
				hitInfo.raycastHit = hit;
				hit.collider.gameObject.SendMessage("GunHitInfo", hitInfo, SendMessageOptions.DontRequireReceiver); //send damage and position of hit

			}
		}
		
	}
	public override void PlayHitAnimation(int totalHealth, HitInfo hitInfo) {
		if (_animator.GetCurrentAnimatorStateInfo(0).IsName(_animationClipName[EUnitAnimationState.Skill_ClipDischarge]) ||
			_animator.GetCurrentAnimatorStateInfo(0).IsName(_animationClipName[EUnitAnimationState.Skill_StunGrenade])) {
				return;
		}

		base.PlayHitAnimation(totalHealth, hitInfo);
	}
Beispiel #13
0
	public override void OnFire(HitInfo hit)
	{
		Remaining--;

		if(Remaining <= 0)
		{
			Weapon.Wielder.Events.Invoke(new MagazineEmptyEvent());
			Weapon.StopFire(true);
		}
	}
Beispiel #14
0
        public CombatEntityHurtEvent(BaseCombatEntity combatEnt, HitInfo info)
            : base(info)
        {
            var block = combatEnt.GetComponent<BuildingBlock>();

            if (block != null)
                Victim = new BuildingPart(block);
            else
                Victim = new Entity(combatEnt);
        }
Beispiel #15
0
        public bool Check()
        {
            var hit = LocalCache.TryGet<object>(this.CacheKey) as HitInfo;

            if (hit != null)
            {
                return hit.Counter++ < this.Limit;
            }

            hit = new HitInfo { Counter = 1 };
            Dependency.Resolve<ILocalCache>().Add(this.CacheKey, hit, this.Duration);
            return true;
        }
Beispiel #16
0
 protected override void OnCollisionEnter2D(Collision2D collision)
 {
     m_animator.SetBool(m_hitHash, true);
     GetComponent<Rigidbody2D>().isKinematic = true;
     HitInfo info = new HitInfo();
     info.hitEnergy=Damage;
     foreach(GameObject x in m_targets)
     {
         if(x!= null)
             x.SendMessage("OnHit", info);
     }
     m_hit = true;
 }
	public override void OnFire(HitInfo hit)
	{
		burstId++;

		switch(current)
		{
		case FireMode.SemiAutomatic:
			Weapon.StopFire(true);
			break;
		case FireMode.Burst3:
			UpdateBurst();
			break;
		}
	}
	public override float GetDamage(HitInfo hit, float damage)
	{
		switch(hit.tag)
		{
		case "Head":
			return damage * head;
		case "Body":
			return damage * body;
		case "Limbs":
			return damage * limbs;
		}

		return damage;
	}
Beispiel #19
0
    /// <summary>
    /// Create a new hitbox with new data.
    /// </summary>
    /// <param name="sender">Character who sent the attackValue.</param>
    /// <param name="hitInfo">HitInfo to pass along to the reciever's Health.</param>
    /// <param name="time">How long the hitbox should last.</param>
    /// <param name="hitNumber">How many hits to perform. Usually 1.</param>
    /// <param name="oneShot">Does the hitbox get destroyed after landing one hit?</param>
    public void Initialize(List<object> senders, HitInfo hitInfo, float time, int hitNumber, bool oneShot = false)
    {
        this.senders = senders;
        this.hitInfo = hitInfo;
        this.oneShot = oneShot;

        tag = (senders[0] as MonoBehaviour).tag;
        SetHitID();
        if (hitNumber > 1)
        {
            StartCoroutine(MultiHit(time, hitNumber));
        }

        InvokeMethod("End", time);
    }
Beispiel #20
0
 protected override void OnCollisionEnter2D(Collision2D collision)
 {
     float hitEnergy = Mathf.Abs(m_energy - Mass * rigidbody2D.velocity.SqrMagnitude() / 2);
     if (hitEnergy > 1)
     {
         Strength -= hitEnergy;
         HitInfo info = new HitInfo();
         info.velocity = rigidbody2D.velocity;
         info.mass = Mass;
         info.hitEnergy = hitEnergy;
         collision.collider.SendMessage("OnHit", info);
     }
     if (Strength <= 0)
         Destroy(gameObject);
 }
 public DeadPlayerInfo(BasePlayer victim, HitInfo info)
 {
     UserId = victim.userID.ToString();
     Name = victim.displayName;
     Reason = victim.lastDamage.ToString();
     if (info != null)
     {
         var attacker = info.Initiator as BasePlayer;
         if (info.Initiator)
         {
             Reason = info.Initiator.LookupPrefabName();
             if (attacker && attacker != victim) Reason = attacker.displayName;
         }
     }
     Position = new LocationInfo(victim.transform.position);
 }
Beispiel #22
0
        public bool Check()
        {
            var hit = Dependency.Resolve<ILocalCache>().Get<object>(this.CacheKey) as HitInfo;
            if (hit == null)
            {
                hit = new HitInfo { Counter = 1 };
                Dependency.Resolve<ILocalCache>().Add(this.CacheKey, hit, this.Duration);
            }
            else
            {
                if (hit.Counter++ >= this.Limit)
                    return false;
            }

            return true;
        }
Beispiel #23
0
        public bool Check()
        {
            var hit = LocalCache.TryGet<HitInfo>(this.CacheKey);
            if (hit == null)
            {
                hit = new HitInfo { Counter = 1 };
                LocalCache.Add(this.CacheKey, hit, this.Duration);
            }
            else
            {
                if (hit.Counter++ >= this.Limit)
                    return false;
            }

            return true;
        }
Beispiel #24
0
    public override void Kick(PhysicsObject target)
    {
        if(m_kickTime>0)return;
        if (target.GetExtents().min.x-GetComponent<Collider2D>().bounds.max.x > HitRange)
        {

            PushForward(0.5f);
        }
        else
        {
            HitInfo info = new HitInfo();
            info.hitEnergy = m_kickEnergy;
            target.OnHit(info);
            rigidbody2D.velocity = -transform.right.normalized;
            m_kickTime = m_kickCooldown;
        }
    }
Beispiel #25
0
    /// <summary>
    /// Create a new hitbox with new data.
    /// </summary>
    /// <param name="senders">Characters who sent the attackValue.</param>
    /// <param name="hitInfo">HitInfo to pass along to the reciever's Health.</param>
    /// <param name="time">How long the hitbox should last.</param>
    /// <param name="hitNumber">How many hits to perform. Usually 1.</param>
    /// <param name="oneShot">Does the hitbox get destroyed after landing one hit?</param>
    public void Initialize(List<Character> senders, HitInfo hitInfo, float time, int hitNumber, bool oneShot = false)
    {
        this.senders = senders;
        this.hitInfo = hitInfo;
        this.oneShot = oneShot;

        tag = senders[0].gameObject.tag;
        SetHitID();
        if (hitNumber > 1)
        {
            StartCoroutine(MultiHit(time, hitNumber));
        }

        //hitInfo.FactorAttackStats(senders.Select(s => s.myStats));

        InvokeMethod("End", time);
    }
Beispiel #26
0
        public static bool Check(ThrottleLimit limit)
        {
            var cache = HostingEnvironment.Cache;

            var cacheKey = limit.CacheKey;
            var hit = (HitInfo)(cache[cacheKey]);
            if (hit == null)
            {
                hit = new HitInfo { Counter = 1 };
                cache.Add(cacheKey, hit, null, DateTime.Now.Add(limit.Duration),
                    Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.BelowNormal, null);
            }
            else 
            {
                if (hit.Counter++ > limit.Limit)
                    return false;
            }

            return true;
        }
Beispiel #27
0
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            var tick = DateTime.Now;
            try
            {
                if (!hitInfo.damageTypes.Has(Rust.DamageType.Decay)) return;

                var block = entity as BuildingBlock;
                if (entity.LookupShortPrefabName().StartsWith("campfire_deployed"))
                    ProcessCampfireDamage(hitInfo);
                else if (block != null)
                    ProcessBuildingDamage(block, hitInfo);
                else
                    Puts($"Unsupported decaying entity detected: {entity.LookupShortPrefabName()} --- please notify author");
            }
            finally
            {
                var ms = (DateTime.Now - tick).TotalMilliseconds;
                if (ms > 10) Puts($"NoDecay.OnEntityTakeDamage took {ms} ms to execute.");
            }
        }
Beispiel #28
0
	protected override void PrimaryFire()
	{
		for (int i = 0; i < pelletCount; i++)
		{
			RaycastHit hit; //for raycast hit
			Quaternion fireRot = Quaternion.LookRotation(transform.forward);
			Quaternion randomRot = Random.rotation;
			fireRot = Quaternion.RotateTowards(fireRot, randomRot, Random.Range(0.0f, spreadAngle));
			if (Physics.SphereCast(transform.position,0.05f, fireRot * Vector3.forward, out hit, Mathf.Infinity))
			{
				HitInfo hitInfo = new HitInfo();
				hitInfo.damage = damage;
				hitInfo.raycastHit = hit;
				hitInfo.bulletForce = _bulletForce;
				hitInfo.shooterPos = gameObject.transform.position;
				SpawnFakeBullet(hitInfo);
			//	hit.collider.gameObject.SendMessage("GunHitInfo", hitInfo, SendMessageOptions.DontRequireReceiver);
				SpawnParticles(hitInfo);
			}
		}
	}
Beispiel #29
0
	protected override void PrimaryFire()
	{
		RaycastHit hit;
		//Basic firing stuff, should have NO recoil, but in case of recoil,
		Quaternion fireRot = Quaternion.LookRotation(transform.forward);
		Quaternion randomRot = Random.rotation;
		float currentSpread = bulletSpreadCurve.Evaluate(fireTime / timeTillMaxSpreadAngle) * maxBulletSpreadAngle; //Uses curves to determine accuracy while firing
		fireRot = Quaternion.RotateTowards(fireRot, randomRot, Random.Range(0.0f, currentSpread));

		if (Physics.SphereCast(transform.position,0.05f, fireRot * Vector3.forward, out hit, Mathf.Infinity))
		{
			HitInfo lexHit = new HitInfo();
			lexHit.damage = damage;
			lexHit.raycastHit = hit;
			lexHit.shooterPos = gameObject.transform.position;
			lexHit.bulletForce = _bulletForce;
		//	hit.collider.gameObject.SendMessage("GunHitInfo", hitInfo, SendMessageOptions.DontRequireReceiver);
			SpawnParticles(lexHit);
			SpawnFakeBullet(lexHit);
			Debug.Log(lexHit.raycastHit.collider.gameObject.name);
		}
	}
Beispiel #30
0
	protected override void PrimaryFire()
	{
		RaycastHit hit;

		//Bullet recoil stuff (DIFFERENT FROM SHOTGUNS)
		Quaternion fireRot = Quaternion.LookRotation(transform.forward);
		Quaternion randomRot = Random.rotation;
		float currentSpread = bulletSpreadCurve.Evaluate(fireTime / timeTillMaxSpreadAngle) * maxBulletSpreadAngle; //uses curve to change gun's accuracy while firing
		fireRot = Quaternion.RotateTowards(fireRot, randomRot, Random.Range(0.0f, currentSpread));
		
		if (Physics.SphereCast(transform.position,0.05f, fireRot * Vector3.forward, out hit, Mathf.Infinity)) //EDIT
		{
			HitInfo hitInfo = new HitInfo();
			hitInfo.damage = damage;
			hitInfo.raycastHit = hit;
			hitInfo.bulletForce = _bulletForce;
			hitInfo.shooterPos = gameObject.transform.position;
			//hit.collider.gameObject.SendMessage("GunHitInfo", hitInfo, SendMessageOptions.DontRequireReceiver);
			SpawnParticles(hitInfo);
			SpawnFakeBullet(hitInfo);
		//	DrawLine(hitInfo);
			//if(hit.collider.gameObject.GetComponent<NormalZombie>())
		}
	}
 private static bool IsRadiation(HitInfo hit) => hit.damageTypes.GetMajorityDamageType() == DamageType.Radiation || (!hit.damageTypes.IsBleedCausing() && hit.damageTypes.Has(DamageType.Radiation));
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if ((m_Cameras == null) || (m_Cameras.Length != allCamerasCount))
            {
                m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(m_Cameras);
            for (int i = 0; i < m_CurrentHit.Length; i++)
            {
                m_CurrentHit[i] = new HitInfo();
            }
            if (!s_MouseUsed)
            {
                foreach (Camera camera in m_Cameras)
                {
                    if (((camera != null) && ((skipRTCameras == 0) || (camera.targetTexture == null))) && camera.pixelRect.Contains(mousePosition))
                    {
                        GUILayer component = camera.GetComponent <GUILayer>();
                        if (component != null)
                        {
                            GUIElement element = component.HitTest(mousePosition);
                            if (element != null)
                            {
                                m_CurrentHit[0].target = element.gameObject;
                                m_CurrentHit[0].camera = camera;
                            }
                            else
                            {
                                m_CurrentHit[0].target = null;
                                m_CurrentHit[0].camera = null;
                            }
                        }
                        if (camera.eventMask != 0)
                        {
                            Ray        ray      = camera.ScreenPointToRay(mousePosition);
                            float      z        = ray.direction.z;
                            float      distance = !Mathf.Approximately(0f, z) ? Mathf.Abs((float)((camera.farClipPlane - camera.nearClipPlane) / z)) : float.PositiveInfinity;
                            GameObject obj2     = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                            if (obj2 != null)
                            {
                                m_CurrentHit[1].target = obj2;
                                m_CurrentHit[1].camera = camera;
                            }
                            else if ((camera.clearFlags == CameraClearFlags.Skybox) || (camera.clearFlags == CameraClearFlags.Color))
                            {
                                m_CurrentHit[1].target = null;
                                m_CurrentHit[1].camera = null;
                            }
                            GameObject obj3 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                            if (obj3 != null)
                            {
                                m_CurrentHit[2].target = obj3;
                                m_CurrentHit[2].camera = camera;
                            }
                            else if ((camera.clearFlags == CameraClearFlags.Skybox) || (camera.clearFlags == CameraClearFlags.Color))
                            {
                                m_CurrentHit[2].target = null;
                                m_CurrentHit[2].camera = null;
                            }
                        }
                    }
                }
            }
            for (int j = 0; j < m_CurrentHit.Length; j++)
            {
                SendEvents(j, m_CurrentHit[j]);
            }
            s_MouseUsed = false;
        }
Beispiel #33
0
            bool SimulateProjectile(FiredProjectile firedProjectile, float dt)
            {
                if (firedProjectile.travelTime == 0)
                {
                    dt = Time.realtimeSinceStartup - firedProjectile.firedTime;
                }
                else if (firedProjectile.travelTime > 8.0f)
                {
                    return(false);
                }

                Vector3 gravity     = UnityEngine.Physics.gravity * firedProjectile.projectilePrefab.gravityModifier;
                Vector3 oldPosition = firedProjectile.position;

                firedProjectile.position   += firedProjectile.velocity * dt;
                firedProjectile.velocity   += gravity * dt;
                firedProjectile.velocity   -= firedProjectile.velocity * firedProjectile.projectilePrefab.drag * dt;
                firedProjectile.travelTime += dt;

                //Line(andrew, oldPosition, firedProjectile.position, (toggle) ? Color.red : Color.blue, 1);
                toggle = !toggle;

                Vector3 vec  = firedProjectile.position - oldPosition;
                var     list = new List <RaycastHit>();

                GamePhysics.TraceAll(new Ray(oldPosition, vec), 0f, list, vec.magnitude, 1219701521, QueryTriggerInteraction.Ignore);

                bool didntHit = true;

                foreach (var hit in list)
                {
                    BaseEntity ent = hit.GetEntity();

                    didntHit = false;

                    HitInfo hitInfo = new HitInfo();
                    hitInfo.ProjectilePrefab   = firedProjectile.projectilePrefab;
                    hitInfo.Initiator          = firedProjectile.owner.Get(true);
                    hitInfo.HitEntity          = ent;
                    hitInfo.HitPositionWorld   = hit.point;
                    hitInfo.HitNormalWorld     = hit.normal;
                    hitInfo.PointStart         = firedProjectile.initialPosition;
                    hitInfo.ProjectileDistance = (firedProjectile.position - firedProjectile.initialPosition).magnitude;

                    hitInfo.ProjectilePrefab.CalculateDamage(hitInfo, firedProjectile.projectileModifier, 1);
                    firedProjectile.itemMod.ServerProjectileHit(hitInfo);
                    Effect.server.ImpactEffect(hitInfo);

                    if (ent == null)
                    {
                        return(false);
                    }

                    ent.OnAttacked(hitInfo);

                    if (ent.ShouldBlockProjectiles())
                    {
                        break;
                    }
                }

                return(didntHit);
            }
Beispiel #34
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

        object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if ((entity.name.Contains("foundation")) & (!entity.name.Contains("triangle")) & (!entity.name.Contains("steps")))
            {
                if ((ProtectFoundation == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("foundation.triangle"))
            {
                if ((ProtectFoundationTriangle == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("foundation.steps"))
            {
                if ((ProtectFoundationSteps == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("wall.window"))
            {
                if ((ProtectWindowWall == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("wall.doorway"))
            {
                if ((ProtectDoorway == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if ((entity.name.Contains("floor")) & (!entity.name.Contains("triangle")))
            {
                if ((ProtectFloor == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("floor.triangle"))
            {
                if ((ProtectFloorTriangle == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("pillar"))
            {
                if ((ProtectPillar == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("stairs.l"))
            {
                if ((ProtectStairsLShaped == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("stairs.u"))
            {
                if ((ProtectStairsUShaped == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("roof"))
            {
                if ((ProtectRoof == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("wall.low"))
            {
                if ((ProtectLowWall == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if ((entity.name.Contains("wall")) & (!entity.name.Contains("wall.low")) & (!entity.name.Contains("wall.doorway")) & (!entity.name.Contains("wall.window")))
            {
                if ((ProtectWall == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("wall.frame"))
            {
                if ((ProtectWallFrame == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            if (entity.name.Contains("floor.frame"))
            {
                if ((ProtectFloorFrame == true) & (entity is BuildingBlock))
                {
                    return(false);
                }
            }
            return(null);
        }
Beispiel #35
0
 private object IOnBaseCombatEntityHurt(BaseCombatEntity entity, HitInfo hitInfo)
 {
     return(entity is BasePlayer ? null : Interface.CallHook("OnEntityTakeDamage", entity, hitInfo));
 }
 private void OnKilledByEnt(BaseEntity attacker, BasePlayer victim, HitInfo hitInfo)
 {
     _killQueue.OnDeath(victim, null, string.Format(_($"MsgFeedKill{attacker.GetType()}"), SanitizeName(victim.displayName)));
 }
Beispiel #37
0
        void OnEntityTakeDamage(BaseEntity entity, HitInfo info)
        {
            var target   = entity.PrefabName;
            var attacker = info.Initiator;

            if (purgeActive)
            {
                var player = entity.ToPlayer();
                if (player != null && !permission.UserHasPermission(player.UserIDString, permProtect))
                {
                    return;
                }

                if (purgeAnimal && (target.Contains("animals") || target.Contains("corpse") || (attacker != null && attacker.name.Contains("animals"))))
                {
                    return;
                }
                if (purgeHeli && (entity is BaseHelicopter || attacker is BaseHelicopter))
                {
                    return;
                }
                if (purgeLoot && (target.Contains("loot") || target.Contains("box") || target.Contains("barrel")))
                {
                    return;
                }
                if (purgeMonumentBarricade && target.Contains("door barricades"))
                {
                    return;
                }
                if (purgeStructure && attacker != null && (entity is Barricade || entity is BuildingBlock || entity is Door || entity is SimpleBuildingBlock))
                {
                    return;
                }
                if (purgeTrap && entity is BasePlayer && (attacker is Barricade || attacker is BaseTrap || attacker.PrefabName.Contains("wall.external.high")))
                {
                    return;
                }
                if (purgeTurret && (entity is AutoTurret || attacker is AutoTurret || entity is FlameTurret || attacker is FlameTurret))
                {
                    return;
                }
                if (purgeWorld && (entity is BasePlayer && attacker == null))
                {
                    return;
                }
            }
            else
            {
                var owner = attacker?.ToPlayer();
                if (owner != null && entity.OwnerID == owner.userID)
                {
                    return;
                }

                if (safeAnimal && (target.Contains("animals") || target.Contains("corpse") || (attacker != null && attacker.name.Contains("animals"))))
                {
                    return;
                }
                if (safeHeli && (entity is BaseHelicopter || attacker is BaseHelicopter))
                {
                    return;
                }
                if (safeLoot && (target.Contains("loot") || target.Contains("box") || target.Contains("barrel")))
                {
                    return;
                }
                if (safeMonumentBarricade && target.Contains("door barricades"))
                {
                    return;
                }
                if (safeSelf && entity == attacker)
                {
                    return;
                }
                if (safeStructure && attacker != null && (entity is Barricade || entity is BuildingBlock || entity is Door || entity is SimpleBuildingBlock))
                {
                    return;
                }
                if (safeTrap && entity is BasePlayer && (attacker is Barricade || attacker is BaseTrap || attacker.PrefabName.Contains("wall.external.high")))
                {
                    return;
                }
                if (safeTurret && (entity is AutoTurret || attacker is AutoTurret || entity is FlameTurret || attacker is FlameTurret))
                {
                    return;
                }
                if (safeWorld && (entity is BasePlayer && attacker == null))
                {
                    return;
                }
            }

            info.damageTypes = new DamageTypeList();
            info.PointStart  = Vector3.zero;
            info.HitMaterial = 0;
        }
Beispiel #38
0
 private object IOnBasePlayerHurt(BasePlayer basePlayer, HitInfo hitInfo)
 {
     return(isPlayerTakingDamage ? null : Interface.CallHook("OnEntityTakeDamage", basePlayer, hitInfo));
 }
        static void DoSendMouseEvents(int skipRTCameras)
        {
            UpdateMouse();
            var mousePosition = s_MousePosition;

            int camerasCount = Camera.allCamerasCount;

            if (m_Cameras == null || m_Cameras.Length != camerasCount)
            {
                m_Cameras = new Camera[camerasCount];
            }

            // Fetch all cameras.
            Camera.GetAllCameras(m_Cameras);

            // Clear the HitInfos from last time
            for (var hitIndex = 0; hitIndex < m_CurrentHit.Length; ++hitIndex)
            {
                m_CurrentHit[hitIndex] = new HitInfo();
            }

            // If UnityGUI has the mouse over, we simply don't do any mouse hit detection.
            // That way, it will appear as if the mouse has missed everything.
            if (!s_MouseUsed)
            {
                foreach (var camera in m_Cameras)
                {
                    // we do not want to check cameras that are rendering to textures, starting with 4.0
                    if (camera == null || skipRTCameras != 0 && camera.targetTexture != null)
                    {
                        continue;
                    }

                    int displayIndex = camera.targetDisplay;

                    var eventPosition = Display.RelativeMouseAt(mousePosition);

                    if (eventPosition != Vector3.zero)
                    {
                        // We support multiple display and display identification based on event position.
                        int eventDisplayIndex = (int)eventPosition.z;

                        // Discard events that are not part of this display so the user does not interact with multiple displays at once.
                        if (eventDisplayIndex != displayIndex)
                        {
                            continue;
                        }

                        // Multiple display support only when not the main display. For display 0 the reported
                        // resolution is always the desktop resolution since it's part of the display API,
                        // so we use the standard non multiple display method.
                        float w = Screen.width;
                        float h = Screen.height;
                        if (displayIndex > 0 && displayIndex < Display.displays.Length)
                        {
                            w = Display.displays[displayIndex].systemWidth;
                            h = Display.displays[displayIndex].systemHeight;
                        }

                        Vector2 pos = new Vector2(eventPosition.x / w, eventPosition.y / h);

                        // If the mouse is outside the display bounds, do nothing
                        if (pos.x < 0f || pos.x > 1f || pos.y < 0f || pos.y > 1f)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // The multiple display system is not supported on all platforms, when it is not supported the returned position
                        // will be all zeros so when the returned index is 0 we will default to the mouse position to be safe.
                        eventPosition = mousePosition;
                        if (Display.activeEditorGameViewTarget != displayIndex)
                        {
                            continue;
                        }
                        eventPosition.z = Display.activeEditorGameViewTarget;
                    }

                    // Is the mouse inside the cameras viewport?
                    var rect = camera.pixelRect;
                    if (!rect.Contains(eventPosition))
                    {
                        continue;
                    }

                    // There is no need to continue if the camera shouldn't be sending out events
                    if (camera.eventMask == 0)
                    {
                        continue;
                    }

                    // Calculate common physics projection and distance.
                    var screenProjectionRay = camera.ScreenPointToRay(eventPosition);
                    var projectionDirection = screenProjectionRay.direction.z;
                    var distanceToClipPlane = Mathf.Approximately(0.0f, projectionDirection) ? Mathf.Infinity : Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / projectionDirection);

                    // Did we hit any 3D colliders?
                    var hit3D = CameraRaycastHelper.RaycastTry(camera, screenProjectionRay, distanceToClipPlane, camera.cullingMask & camera.eventMask);
                    if (hit3D != null)
                    {
                        m_CurrentHit[m_HitIndexPhysics3D].target = hit3D;
                        m_CurrentHit[m_HitIndexPhysics3D].camera = camera;
                    }
                    // We did not hit anything with a raycast from this camera. But our camera
                    // clears the screen and renders on top of whatever was below, thus making things
                    // rendered before invisible. So clear any previous hit we have found.
                    else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.SolidColor)
                    {
                        m_CurrentHit[m_HitIndexPhysics3D].target = null;
                        m_CurrentHit[m_HitIndexPhysics3D].camera = null;
                    }

                    // Did we hit any 2D colliders?
                    var hit2D = CameraRaycastHelper.RaycastTry2D(camera, screenProjectionRay, distanceToClipPlane, camera.cullingMask & camera.eventMask);
                    if (hit2D != null)
                    {
                        m_CurrentHit[m_HitIndexPhysics2D].target = hit2D;
                        m_CurrentHit[m_HitIndexPhysics2D].camera = camera;
                    }
                    // We did not hit anything with a raycast from this camera. But our camera
                    // clears the screen and renders on top of whatever was below, thus making things
                    // rendered before invisible. So clear any previous hit we have found.
                    else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.SolidColor)
                    {
                        m_CurrentHit[m_HitIndexPhysics2D].target = null;
                        m_CurrentHit[m_HitIndexPhysics2D].camera = null;
                    }
                }
            }

            // Send hit events.
            for (var hitIndex = 0; hitIndex < m_CurrentHit.Length; ++hitIndex)
            {
                SendEvents(hitIndex, m_CurrentHit[hitIndex]);
            }

            s_MouseUsed = false;
        }
Beispiel #40
0
            public AggressiveAction(HitInfo info)
            {
                if (info == null)
                {
                    return;
                }

                // Get the source of the aggression
                if (info.Initiator != null)
                {
                    if (info.InitiatorPlayer != null)
                    {
                        aggression_initiator = new Resident(info.InitiatorPlayer);
                    }
                    else
                    {
                        aggression_initiator = new Entity(info.Initiator);
                    }
                }


                // Get the target of the agression
                BasePlayer player = info.HitEntity?.GetComponent <BasePlayer>();

                if (player != null)
                {
                    aggression_target = new Resident(player);
                }
                else if (info.HitEntity != null)
                {
                    aggression_target = new Entity(info.HitEntity);
                }

                // Get the weapons name
                if (info.Weapon.ShortPrefabName != null)
                {
                    weapon_name   = info.Weapon.ShortPrefabName;
                    weapon_prefab = info.Weapon.PrefabName;
                }

                if (info.material != null)
                {
                    material_name = info.material.name;
                }

                if (info.hasDamage)
                {
                    damage_name = info.damageProperties.name;
                    damage_type = info.damageTypes.GetMajorityDamageType().ToString();
                    damage_delt = (int)info.damageTypes.Total();
                    is_attack   = info.damageTypes.IsConsideredAnAttack();
                }

                did_gather  = info.DidGather;
                is_headshot = info.isHeadshot;
                if (info.IsProjectile())
                {
                    is_projectile       = info.IsProjectile();
                    projectile_distance = info.ProjectileDistance;
                }
            }
 private static bool IsFlame(HitInfo hit) => hit.damageTypes.GetMajorityDamageType() == DamageType.Heat || (!hit.damageTypes.IsBleedCausing() && hit.damageTypes.Has(DamageType.Heat));
Beispiel #42
0
 private object OnMeleeAttack(BaseMelee melee, HitInfo hitinfo)
 {
     return(Interface.CallHook("OnPlayerAttack", melee.ownerPlayer, hitinfo));
 }
Beispiel #43
0
 public HurtEvent(HitInfo info)
 {
     _info = info;
 }
Beispiel #44
0
        /******************************************************
        ** Multi Resident Event Serializable Object Classes **
        ******************************************************/


        // On Player Attack
        // Useful for modifying an attack before it goes out hitInfo.HitEntity should be the
        void OnPlayerAttack(BasePlayer attacker, HitInfo info)
        {
            CreateLogEntry("on_player_attack.log", new ResidentAttack(attacker, info));
        }
Beispiel #45
0
        void CreateReplenishableContainer(BasePlayer player, ReplenishPlayer rPlayer, StorageContainer container, HitInfo info, string type)
        {
            if (GetReplenishableContainer(container.inventory) != null)
            {
                containers.Remove(GetReplenishableContainer(container.inventory));
                ReplyPlayer(player, "AlreadyReplenishing");
            }

            ReplenishableContainer repl = new ReplenishableContainer(container.inventory.uid, rPlayer.timer);

            repl.type = Lang(type);
            repl.SaveItems(container.inventory);
            var worldPos = info.HitEntity.GetEstimatedWorldPosition();

            repl.pos = new Pos(worldPos.x, worldPos.y, worldPos.z);
            containers.Add(repl);
            ReplyFormatted(player, String.Format(Lang("BoxAdded"), repl.type, repl.uid, repl.timer));
        }
Beispiel #46
0
 // On Player Death
 // Called when the player is about to die. HitInfo may be null sometimes
 object OnPlayerDeath(BasePlayer player, HitInfo info)
 {
     CreateLogEntry("on_player_death.log", new ResidentDead(player, info));
     return(null);
 }
 private static bool IsExplosion(HitInfo hit) => (hit.WeaponPrefab != null && (hit.WeaponPrefab.ShortPrefabName.Contains("grenade") || hit.WeaponPrefab.ShortPrefabName.Contains("explosive"))) ||
 hit.damageTypes.GetMajorityDamageType() == DamageType.Explosion || (!hit.damageTypes.IsBleedCausing() && hit.damageTypes.Has(DamageType.Explosion));
Beispiel #48
0
 public override void OnSuccessfulHit(HitInfo info)
 {
     FSMUtility.SendEventToGameObject(info.Attacker, "HIT LANDED", false);
 }
Beispiel #49
0
            internal override void OnEventPlayerDeath(EventManager.BaseEventPlayer victim, EventManager.BaseEventPlayer attacker = null, HitInfo hitInfo = null)
            {
                if (victim == null)
                {
                    return;
                }

                victim.OnPlayerDeath(attacker, Configuration.RespawnTime);

                if (attacker != null && victim != attacker)
                {
                    if (Configuration.ResetHealthOnKill)
                    {
                        attacker.Player.health = attacker.Player.MaxHealth();
                        attacker.Player.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                    }

                    attacker.OnKilledPlayer(hitInfo);

                    string attackersWeapon = GetWeaponShortname(hitInfo);

                    if (!string.IsNullOrEmpty(attackersWeapon))
                    {
                        if (KilledByRankedWeapon(attacker as GunGamePlayer, attackersWeapon))
                        {
                            (attacker as GunGamePlayer).Rank += 1;

                            if ((attacker as GunGamePlayer).Rank > weaponSet.Count)
                            {
                                winner = attacker;
                                InvokeHandler.Invoke(this, EndEvent, 0.1f);
                                return;
                            }
                            else
                            {
                                (attacker as GunGamePlayer).RemoveRankWeapon();
                                (attacker as GunGamePlayer).GiveRankWeapon(weaponSet.CreateItem((attacker as GunGamePlayer).Rank));
                            }
                        }
                        else if (KilledByDowngradeWeapon(attackersWeapon))
                        {
                            (victim as GunGamePlayer).Rank = Mathf.Clamp((victim as GunGamePlayer).Rank - 1, 1, weaponSet.Count);
                        }
                    }
                }

                UpdateScoreboard();
                base.OnEventPlayerDeath(victim, attacker);
            }
Beispiel #50
0
 public bool ShouldReportEvent(WebInterface.ACTION_BUTTON buttonId, HitInfo hit)
 {
     return(IsAtHoverDistance(hit.distance) &&
            (model.button == "ANY" || buttonId.ToString() == model.button));
 }
Beispiel #51
0
 public override void OnKilled(HitInfo info)
 {
     this.DropItems();
     base.OnKilled(info);
 }
Beispiel #52
0
        public static void ImpactEffect(HitInfo info)
        {
            Vector3 vector3;
            string  str      = StringPool.Get(info.HitMaterial);
            string  particle = EffectDictionary.GetParticle(info.damageTypes.GetMajorityDamageType(), str);
            string  decal    = EffectDictionary.GetDecal(info.damageTypes.GetMajorityDamageType(), str);

            if (TerrainMeta.WaterMap != null && info.HitMaterial != Projectile.WaterMaterialID() && info.HitMaterial != Projectile.FleshMaterialID() && info.HitPositionWorld.y < TerrainMeta.WaterMap.GetHeight(info.HitPositionWorld))
            {
                return;
            }
            if (!info.HitEntity.IsValid())
            {
                Vector3 hitPositionWorld = info.HitPositionWorld;
                Vector3 hitNormalWorld   = info.HitNormalWorld;
                vector3 = new Vector3();
                Effect.client.Run(particle, hitPositionWorld, hitNormalWorld, vector3);
                Vector3 hitPositionWorld1 = info.HitPositionWorld;
                Vector3 hitNormalWorld1   = info.HitNormalWorld;
                vector3 = new Vector3();
                Effect.client.Run(decal, hitPositionWorld1, hitNormalWorld1, vector3);
            }
            else
            {
                GameObjectRef impactEffect = info.HitEntity.GetImpactEffect(info);
                if (impactEffect.isValid)
                {
                    particle = impactEffect.resourcePath;
                }
                Effect.client.Run(particle, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                if (info.DoDecals)
                {
                    Effect.client.Run(decal, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                }
            }
            if (info.WeaponPrefab)
            {
                BaseMelee weaponPrefab = info.WeaponPrefab as BaseMelee;
                if (weaponPrefab != null)
                {
                    string strikeEffectPath = weaponPrefab.GetStrikeEffectPath(str);
                    if (!info.HitEntity.IsValid())
                    {
                        Vector3 vector31        = info.HitPositionWorld;
                        Vector3 hitNormalWorld2 = info.HitNormalWorld;
                        vector3 = new Vector3();
                        Effect.client.Run(strikeEffectPath, vector31, hitNormalWorld2, vector3);
                    }
                    else
                    {
                        Effect.client.Run(strikeEffectPath, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                    }
                }
            }
            if (info.damageTypes.Has(DamageType.Explosion))
            {
                Effect.client.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/explosion.prefab");
            }
            if (info.damageTypes.Has(DamageType.Heat))
            {
                Effect.client.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/fire.prefab");
            }
        }
 public static bool Compare(HitInfo lhs, HitInfo rhs)
 {
     return(lhs.target == rhs.target && lhs.camera == rhs.camera);
 }
Beispiel #54
0
 public void PlayerDamage(HitInfo info)
 {
     //playerDamage[playerid].SetTrigger("Do It");
 }
Beispiel #55
0
 private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
 {
     HookCalled("OnEntityTakeDamage");
 }
Beispiel #56
0
 void CancelDamage(HitInfo hitinfo)
 {
     hitinfo.damageTypes  = emptyDamageType;
     hitinfo.DoHitEffects = false;
     hitinfo.HitMaterial  = 0;
 }
Beispiel #57
0
 private void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo)
 {
     HookCalled("OnEntityDeath");
     // TODO: Print player died
     // TODO: Automatically respawn admin after X time
 }
Beispiel #58
0
 private void OnHammerHit(BasePlayer player, HitInfo info)
 {
     HookCalled("OnHammerHit");
 }
Beispiel #59
0
 /// <summary>
 /// OnHammerHit for this player
 /// </summary>
 public static void OnHammerHit(BasePlayer basePlayer, HitInfo hit) => Get(basePlayer).OnHammerHit(hit);
Beispiel #60
0
 public override void OnAttacked(HitInfo info)
 {
     base.OnAttacked(info);
     this.Alert();
 }