Esempio n. 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 !");
            }
        }
    public IEnumerator Fragments(EntityAlive ctrl, Vector3 pos)
    {
        Printer.Log(81, "MinEventActionImpactFragment", ctrl, pos, this.item);
        string item = this.item;

        if (item.StartsWith("$"))
        {
            item = StringMap.Get(ctrl, item);
        }
        if (item == "")
        {
            yield break;
        }
        Printer.Log(30, "MinEventActionImpactFragment", ctrl, pos, ctrl.GetPosition());
        YieldInstruction dt = new WaitForSeconds((float)this.dt / 1000f);

        for (int replicate = 0; replicate < rep; replicate++)
        {
            yield return(dt);

            Vector3 offset = Vectors.Float.Randomize(random, 0.5f, Vectors.Float.UnitY);
            // Vector3 motion = Vectors.Float.Randomize(random, 1f, Vectors.Float.UnitY);
            Vector3 motion = offset.normalized * (1f + 5 * random.RandomFloat);
            motion = motion.normalized * 3;
            yield return(SdtdUtils.EffectsItem.spawnItemGhost(ctrl, item, pos + offset + Vectors.Float.UnitY, motion));
        }
    }
    private static IEnumerator _Trigger(EntityAlive entity)
    {
        if (entity == null)
        {
            yield break;
        }
        Vector3 pos  = entity.GetPosition();
        string  item = StringMap.Get(entity, cvarKey);

        // Printer.Print("MinEventActionExplodeEntity", entity, pos, item);
        if (item == "")
        {
            Printer.Print("StringMap no cvar");
        }
        else
        {
            Vector3 offset = 0.3f * Vectors.Float.UnitY;
            Vector3 motion = -Vectors.Float.UnitY;
            motion = motion.normalized * 3;
            yield return(SdtdUtils.EffectsItem.spawnItemGhost(item, pos + offset + Vectors.Float.UnitY, motion));

            yield return(dt);
        }
        if (entity == null)
        {
            yield break;
        }
        entity.SetDead();
    }
    public IEnumerator DestroyAround(EntityAlive ctrl)
    {
        running = true; // Actions are static, is this fine ? FIXME: There should be one per giant !
        Printer.Log(35, "MinEventActionGiantDestroy", ctrl, ctrl.GetPosition());

        Bounds  Bounds = ctrl.boundingBox; // check: not affected by rescale !
        Vector3 dir    = SdtdUtils.EffectsEntity.MoveDir(ctrl);
        Vector3 pos    = ctrl.GetPosition();

        int ymax = (int)Math.Floor(ctrl.boundingBox.size.y * ctrl.gameObject.transform.localScale.y);

        // how to enumerate x,z  wrt direction ?? h is ok
        foreach (int p in SdtdUtils.EffectsGround.LR(4))
        {
            foreach (int q in SdtdUtils.EffectsGround.LR(4))
            {
                Vector3 where = new Vector3(pos.x + p, pos.y, pos.z + q);
                if (!aigu(dir.x, dir.z, where.x - pos.x, where.z - pos.z))
                {
                    continue;                  // test not depending on y
                }
                for (int y = 0; y < ymax; y++) // TODO adjust by current giant ratio
                {
                    Printer.Log(30, "MinEventActionGiantDestroy at", p, q, y);
                    where.y = pos.y + y;
                    Vector3i   iwhere = Vectors.ToInt(where);
                    BlockValue block  = World.GetBlock(iwhere);
                    if (block.type != 0)
                    {
                        DamageBlock(ctrl, iwhere);
                    }
                    // todo: passer block et bv a DamageBlock
                }
                DamageEnts(ctrl);
                yield return(new WaitForSeconds(0.2f));

                if (ctrl == null || ctrl.IsDead())
                {
                    yield break;
                }
            }
        }
        running = false;
    }
Esempio n. 5
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            Zombiome.Routines.Start(Particles._Next(player), "Jumping-Particles");
            // EntityMover mover = new EntityMover(2, 0.2f, 1); // randomize
            SdtdUtils.EffectsItem.SpawnParticle(target.GetPosition(), "treeGib_birch_small", biome.groundColor);
            int         len   = 5 + (int)(this.rand.RandomFloat * 5);
            EntityMover mover = new EntityMover(len, 0.5f, 1); // tres bien : petit saut

            mover.Apply(target, Vectors.Float.UnitY);
            yield break;
        }
    public void SetCloseSpawnPoint()
    {
        Vector3 newPos = entityTarget.GetPosition();

        newPos.x += 2f;
        newPos.z += 2f;
        int x, y, z;

        this.theEntity.world.FindRandomSpawnPointNearPositionUnderground(entityTarget.position, 15, out x, out y, out z, new Vector3(2, 2, 2));
        //  this.theEntity.SetPosition( newPos, true);
        this.theEntity.SetPosition(new Vector3(x, y, z), true);
    }
Esempio n. 7
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            Vector3     pos   = target.GetPosition();
            Emplacement place = Emplacement.At(pos, Placer.directions.Generate(pos));

            Printer.Log(40, "Peak Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape);
            Zombiome.Routines.Named("PeakAt").Start(
                Routines.Call(biome.groundParticleEffect, place.ipos),
                new WaitForSeconds(1f),
                EffectsGround.Peak(player, place, opt)
                );
            yield break;
        }
Esempio n. 8
0
    public IEnumerator Particles(EntityAlive ctrl, Vector3 pos)
    {
        pos = pos + this.offset;
        Printer.Log(30, "MinEventActionParticleAtPos", ctrl, pos, ctrl.GetPosition());
        YieldInstruction dt = new WaitForSeconds((float)this.dt / 1000f);

        for (int replicate = 0; replicate < rep; replicate++)
        {
            yield return(dt);

            Vector3 rdmized = Vectors.Float.Randomize(random, pos, this.rpos);
            SdtdUtils.EffectsItem.SpawnParticle(rdmized, this.particle, RCol(), this.sound);
            // Vector3 motion = Vectors.Float.Randomize(random, 1f, Vectors.Float.UnitY);
            // SdtdUtils.EffectsItem.SpawnParticle(pos+offset, this.particle, this.color, this.sound);
        }
    }
Esempio n. 9
0
    public void SetCloseSpawnPoint()
    {
        if (entityTarget == null)
        {
            return;
        }

        Vector3 newPos = entityTarget.GetPosition();

        newPos.x += 2f;
        newPos.z += 2f;
        int x, y, z;

        this.theEntity.world.FindRandomSpawnPointNearPositionUnderground(entityTarget.position, 15, out x, out y, out z, new Vector3(2, 2, 2));
        //  this.theEntity.SetPosition( newPos, true);
        this.theEntity.SetPosition(new Vector3(x, y, z), true);
        this.theEntity.SetAttackTarget(null, 10);
        this.theEntity.SetRevengeTarget(null);
    }
Esempio n. 10
0
    public IEnumerator SpawnBlock(EntityAlive ctrl, Vector3 pos)
    {
        Printer.Log(30, "MinEventActionImpactSpawn", ctrl, pos, ctrl.GetPosition());
        yield return(new WaitForSeconds((float)this.dt / 1000f));

        BlockSetter.Options opt = new BlockSetter.Options();
        opt.avoidBlock  = false;
        opt.avoidEntity = false;
        opt.elastic     = 0;
        opt.SetBlocks(this.block);

        BlockSetter setter = new BlockSetter(opt);

        setter.OnCreation = BlockSetter.Rotate;
        Vector3i ipos = Vectors.ToInt(pos);
        Vector3i surf = Geo3D.Surface(ipos, ipos.y) + Vectors.Up;

        // setter.Apply(ipos); // is it pos +1 ? do we need surface ?
        setter.Apply(surf);
        setter.Push();
    }
Esempio n. 11
0
    private void DamageEnts(EntityAlive ctrl)
    {
        // TODO: command test
        Vector3       pos              = ctrl.GetPosition();
        Bounds        Bounds           = new Bounds(pos, new Vector3(4, 4, 4));
        List <Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(Entity),
                                                                                        Bounds,
                                                                                        new List <Entity>());
        //DamageSource DamageSource= new DamageSource(EnumDamageSource.External, EnumDamageTypes.Crushing);// TODO: DamageSourceEntity ?
        DamageSource DamageSource = new DamageSourceEntity(EnumDamageSource.External, EnumDamageTypes.Crushing,
                                                           ctrl.entityId); // direction ? can it be used to push back ?

        foreach (Entity ent in entitiesInBounds)
        {
            if (ent.entityId == ctrl.entityId)
            {
                continue;
            }
            ent.DamageEntity(DamageSource, 3, false);
        }
    }
Esempio n. 12
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            Vector3 tpos = target.GetPosition();
            Vector3 s    = Geo3D.Surface(tpos);

            if (s.y <= 1)
            {
                yield break;
            }
            float dy = tpos.y - s.y;

            if (dy >= 0.5f)
            {
                yield break;
            }
            if (dy <= -0.5f)
            {
                yield break;
            }
            Vector3     dir   = -0.3f * Vectors.Float.UnitY;
            EntityMover mover = new EntityMover(1); // .Config(1);

            yield return(mover.Move(target, dir));
        }
Esempio n. 13
0
 public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
 {
     Zombiome.Routines.Start(Particles._Next(player), "RandomSize-Particles");
     if (target is EntityZombie || target is EntityAnimal)
     {
         if (!target.IsDead())
         {
             SdtdUtils.EffectsItem.SpawnParticle(target.GetPosition(), "wire_tool_sparks",
                                                 biome.groundColor, "electric_fence_impact");
             int index = rand.RandomRange(buffs.Length);
             // target.Buffs.AddBuff(buffs[index]);
             // rm others, otherwise they would set back scaling=1 when gone but the neew buff still runs
             for (int k = 0; k < buffs.Length; k++)
             {
                 if (k != index && target.Buffs.HasBuff(buffs[k]))
                 {
                     target.Buffs.RemoveBuff(buffs[k]);
                 }
             }
             target.Buffs.AddBuff(buffs[index]);
         }
     }
     yield break;
 }
Esempio n. 14
0
    /**
     * Quick method for entity players to drop an item on the ground at a certain position.
     */

    public static void DropItemOnGround(EntityAlive entity, ItemValue _itemValue, int count = 1)
    {
        entity.world.GetGameManager().ItemDropServer(new ItemStack(_itemValue, count), entity.GetPosition(), new Vector3(0.5f, 0f, 0.5f), entity.belongsPlayerId, 60f, false);
    }
Esempio n. 15
0
    private void Execute(EntityAlive ctrl)
    {
        Vector3 pos = ctrl.GetPosition();

        SdtdUtils.EffectsItem.SpawnParticle(pos, this.particle, this.color, this.sound);
    }
Esempio n. 16
0
        // private int cursor = -1;
        public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt)
        {
            Vector3 ppos = player.GetPosition();

            Vector3 where = place.position;
            Bounds area = new Bounds(ppos, new Vector3(40, 40, 40));

            EntityPool.Update(area);

            Vector3 sharedDir = place.direction;

            sharedDir.y = 0.2f;                           // Math.Abs(sharedDir.y); // TODO: constraint in Directions
            EntityMover mover = new EntityMover(3, 0.3f); // .Config(1);
            int         mode  = 0;                        // 0nothing, 1random, 2parralel, 3 player
            float       u     = rand.RandomFloat;

            if (u < 0.4f)
            {
                mode = 3;
            }
            else if (u < 0.6f)
            {
                mode = 2;
            }
            else if (u < 0.8f)
            {
                mode = 1;
            }

            foreach (Entity entity in EntityPool.Entities)
            {
                if (entity == null)
                {
                    continue;
                }
                // if (entity.IsDead()) continue;
                EntityAlive alive = (EntityAlive)entity;
                if (!alive.Buffs.HasBuff(opt.OptionEntity.buff))
                {
                    Printer.Log(40, "MovingGhost buffing", opt.OptionEntity.buff, alive);
                    alive.Buffs.AddBuff(opt.OptionEntity.buff);
                }
                Vector3 toward = Vectors.Float.Zero;
                if (false)
                {
                    if (mode == 3)
                    {
                        toward = (ppos - alive.GetPosition()).normalized;
                        // toward.y = rand.RandomRange(0.05f, 0.2f);
                        toward.y = 0.2f;
                    }
                    else if (u < 0.6)
                    {
                        toward = sharedDir;
                    }
                    else if (u < 0.8)
                    {
                        toward.x = rand.RandomRange(-1f, 1f);
                        toward.z = rand.RandomRange(-1f, 1f);
                        // toward.y = rand.RandomRange(0.05f, 0.2f);
                        toward   = toward.normalized;
                        toward.y = 0.2f;
                    }
                }
                toward = (ppos - alive.GetPosition()).normalized;
                // toward.y = rand.RandomRange(0.05f, 0.2f);
                toward.y = 0.2f;
                if (toward.magnitude > 0)
                {
                    // Can we have a single routine that manages all motions ?
                    Printer.Log(40, "MovingGhost motion", entity, toward);
                    Zombiome.Routines.Start(mover.Move(alive, toward), "MovingGhost");
                }
            }
        }