Exemple #1
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            // TODO: randomize chance, and only on ice or snow ?
            // check is block below is snow
            Vector3 dir = Vectors.Float.Randomize(Zombiome.rand, 1f);

            dir   = dir.normalized;
            dir.y = 0.1f;
            Vector3i at = Vectors.ToInt(target.GetPosition());

            if (World.GetBlock(at).type == BlockValue.Air.type && World.GetBlock(at - Vectors.Up).type == BlockValue.Air.type)
            {
                yield break; // target is not on ground  // todo: snow only
            }
            Vector3 motion = EffectsEntity.MoveDir(target);

            if (motion.magnitude <= 0.3f)
            {
                yield break;
            }
            Vector3 slideDir = Vectors.Float.Randomize(rand, 1f, motion.normalized).normalized;

            slideDir.y = 0.05f;
            EntityMover mover = new EntityMover(2, 0.2f, 1); // .Config(1);

            yield return(mover.Move(target, slideDir));

            target.Buffs.AddBuff("buffRagdoll");
            if (target is EntityPlayerLocal)
            {
                GameManager.ShowTooltip((EntityPlayerLocal)target, "You slipped !");
            }
        }
Exemple #2
0
    private static IEnumerator _GoShowSpeed(List <string> _params)
    {
        // fails for player, but what about Z ??

        /*
         * Z: always has motion.y = -0.1 (gravity), except when falling, its <<
         * P: motion always = 0
         */

        EntityAlive target = GameManager.Instance.World.GetLocalPlayers()[0];

        if (_params.Count > 0)
        {
            int eid = int.Parse(_params[0]);
            target = GameManager.Instance.World.GetEntity(eid) as EntityAlive;
        }

        // EntityPlayerLocal player = GameManager.Instance.World.GetLocalPlayers()[0];
        for (int k = 0; k < 20; k++)
        {
            // Vector3 dir = player.moveDirection; // relative to o rientation
            // Vector3 rhs = EffectsEntity.MoveDir(player);
            // Printer.Print("ShowSpeed", player, "=> ", dir, " rot=", player.rotation, "=>", rhs);
            Vector3 speed = EffectsEntity.MoveDir(target);
            Printer.Print("ShowSpeed", target, "=> ", speed.magnitude, speed, target.motion, target.motion.magnitude);
            yield return(new WaitForSeconds(1f));
        }

        /*
         * moveDirection is relative to orientation
         * (0,0,1) is forward
         *
         * rotation : (x,y,0). 0 maybe not when eg ragdoll, but remain 0 at looking up/down
         *
         *
         * groud: water, terrDirt, terrForestGround...
         */
    }