Beispiel #1
0
            public void ScorePlayerHit(BaseCombatEntity entity, HitInfo hitinfo)
            {
                try
                {
                    if (entity is ReactiveTarget && hitinfo.Initiator is BasePlayer)
                    {
                        var target = (ReactiveTarget)entity;

                        if (!targets.Contains(target))
                        {
                            me.Puts("is not game target");
                            return;
                        }

                        var attacker = (BasePlayer)hitinfo.Initiator;
                        if (attacker.UserIDString != iemPlayer.AsBasePlayer().UserIDString)
                        {
                            me.Puts("is not game player");
                            return;
                        }

                        if (entity == null || attacker == null)
                        {
                            return;
                        }

                        // TODO resolve problem that the ReactiveTarget is squashing the HitInfo
                        //me.Puts("hitinfo.HitBone " + hitinfo.HitBone);
                        //me.Puts("target_collider_bullseye " + StringPool.Get("target_collider_bullseye"));
                        if (hitinfo.HitBone == StringPool.Get("target_collider_bullseye"))
                        {
                            IemUtils.DrawChatMessage(attacker, target, "Bullseye!!!!");
                        }

                        // hits on reactive targets tigger OnEntityTakeDamage twice
                        // this selects for the one created by on shared hit in ReactiveTarget
                        if (hitinfo.damageTypes.Total() != 1f)
                        {
                            return;
                        }

                        //this is the amount of damage done to the target by the hit
                        var health = knockdownHealth.GetValue(target);

                        TPGameLevel gamelevel = gamelevels[level];

                        if (!gamelevel.Started)
                        {
                            me.Puts("starting gamelevel " + (level));
                            gamelevel.Start();
                            IemUtils.GameTimer.Start(player);
                        }
                        else
                        {
                            me.Puts("gamelevel " + (level) + " is already started at " + gamelevel.StartTime);
                        }

                        gamelevel.accuracy.ShotsHit += 1;

                        if (target.IsKnockedDown())
                        {
                            iemPlayer.Score += 1;
                            IemUI.CreateGameBanner(attacker, "Level " + (level + 1) +
                                                   " - targets remaining " + (gamelevel.Targets - iemPlayer.Score));

                            if (CheckLevelComplete())
                            {
                                GoNextLevel();
                            }
                            else
                            {
                                target.CancelInvoke("ResetTarget");
                                target.health = target.MaxHealth();
                                target.SendNetworkUpdate();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    me.Puts("exception " + ex);
                }
            }