public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { // EffectsBag.AddItem(Bag bag, ItemStack stack, bool merge=true); // TODO randomize bool EffectsInventory.AddToBag(player, opt.OptionItem.item, false); ParticleGhosts.ManageParticle(player, biome.particleStorm); }
protected override void Randomize(OptionEffect opt) { opt.OptionShape.shape.x = Math.Max(1, opt.OptionShape.shape.x + this.rand.RandomRange(-1, 3)); opt.OptionShape.shape.y = Math.Max(1, opt.OptionShape.shape.y + this.rand.RandomRange(-1, 3)); opt.OptionShape.shape.z = Math.Max(1, opt.OptionShape.shape.z + this.rand.RandomRange(-1, 3)); opt.OptionShape.pace = opt.OptionShape.pace + this.rand.RandomRange(0f, 1f); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Vector3 color = Vectors.Float.RandomIn(colors.min, colors.max); Printer.Log(31, "ZBParticles", particle, color); SdtdUtils.EffectsItem.SpawnParticle(place.position, particle, new Color(color.x, color.y, color.z, 0.2f)); }
public IEnumerator _Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { // Careful, place.direction is the "to" (or I need a range option somewhere, or natural fadeaway) float y = 1.1f; // air above surface (+1) + offset // foreach (Emplacement place in Iter.On(Placer.Get(player.GetPosition()))) { Printer.Log(40, "FireStorm _Effect1:", place, opt.OptionItem.item); // line manage +5; if (place.valid) { // Vector3i at = Geo3D.Surface(Vectors.ToInt(place.position)); Vector3i at = Geo3D.Surface(Vectors.ToInt(place.position), -1, Geo3D.IsGroundOrBuilding); for (int x = 0; x < opt.OptionShape.shape.x; x++) { for (int z = 0; z < opt.OptionShape.shape.z; z++) { Vector3 shift = new Vector3(3 * x, y, 3 * z); // TODO randomize int echos = 1; if (ItemClass.GetItem(opt.OptionItem.item, false).ItemClass.Properties.Contains("Replicates")) { echos = 3; } yield return(Zombiome.Routines.Start( Fire.ThrowItem(Vectors.ToFloat(at) + shift, opt.OptionItem.item, echos), "FireStorm-spawnItemGhost" )); } } } else { Printer.Log(41, "Invalid place:", place, place.valid_msg); } }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Zombiome.Routines.Start( Routines.IfNotRunning(LockRegen, Regen(player)), "MovingDeco.Regen" ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { DecoSearch.Search(player, 20, 3); int nsteps = Math.Min(3, DecoSearch.Count); for (int k = 0; k < nsteps; k++) { BlockPos deco = DecoSearch.Dequeue(); if (deco == null) { continue; } Vector3i ppos = Vectors.ToInt(player.GetPosition()); if (Math.Abs(ppos.x - deco.Pos.x) + Math.Abs(ppos.z - deco.Pos.z) > DecoSearch.radius) { Printer.Log(85, "MovingDeco: too far !", deco, ppos); continue; } string item = Deco2Proj(deco.Value.Block); if (item == "") { continue; } Zombiome.Routines.Start(Fly(deco, item), "FlyDeco"); } }
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 OptionEffect Randomize() { OptionEffect opt = this.opt.Copy(); Randomize(opt); return(opt); }
protected override void Randomize(OptionEffect opt) { opt.OptionShape.shape.x = Math.Max(1, opt.OptionShape.shape.x + this.rand.RandomRange(-1, 2)); opt.OptionShape.shape.y = Math.Max(1, opt.OptionShape.shape.y + this.rand.RandomRange(-1, 2)); opt.OptionShape.shape.z = Math.Max(1, opt.OptionShape.shape.z + this.rand.RandomRange(-1, 2)); // opt.OptionShape.shape = new Vector3i(1,1,1); // debug opt.OptionShape.pace = opt.OptionShape.pace + this.rand.RandomRange(0f, 1f); }
public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt) { Zombiome.Routines.Start(Particles._Next(player), "Gravity-Particle"); Printer.Log(40, "Gravity() AddBuff", target); target.Buffs.AddBuff(this.opt.OptionEntity.buff); // avant c'était juste player player.Buffs.AddBuff(this.opt.OptionEntity.buff); // easier debug yield break; }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(40, "Puit Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); Zombiome.Routines.Named("Puit").Start( Routines.Call(biome.groundParticleEffect, place.ipos), new WaitForSeconds(1f), EffectsCollapse.Puit(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Vector3i where = place.ipos; where = where + rand.RandomRange(30, 50) * Vectors.Up; BlockSetter setter = new BlockSetter(opt.OptionBlock); Block previous = setter.options.block; setter.Apply(where); setter.Push(); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(40, "TrapLine Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); Zombiome.Routines.Named("TrapLine").Start( Routines.Call(biome.groundParticleEffect, place.ipos), ZBActivity.Environment.ZBSounds.Play(this.biome.groundNoise, place.position, player, World, 2, 0, 0.2f), new WaitForSeconds(1f), EffectsGround.TrapLine(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(60, "Geyser Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); Zombiome.Routines.Named("Geyser").Start( // treeGib_birch_15m creates falling leaves above smoke :( Routines.Call(EffectsItem.SpawnParticle, place.position, "treeGib_burnt_small"), new WaitForSeconds(1f), EffectsGround.Peak(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(40, "Wave Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); Zombiome.Routines.Named("Wave").Start( Routines.Call(biome.groundParticleEffect, place.ipos), // Routines.Call(__BUG), // TEST new WaitForSeconds(1f), EffectsGround.Wave(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(40, "Cave Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); Zombiome.Routines.Named("Cave").Start( Routines.Call(biome.groundParticleEffect, place.ipos), ZBActivity.Environment.ZBSounds.Play("light_pipebomb", place.position, player, World, 1, 0, 0.2f), new WaitForSeconds(1f), EffectsCollapse.Cave(player, place, opt) ); }
/** * Setting block at position is easy, but then you need to manage manually: * * Entity collision * Avoid stuck player and 'falling off the world' Zombies, especially when setting multiple blocks at once. * We push colliding entities up (after unicizing their set), (class EntityMover) * * Multiblock * Nothing done yet. Upper part of previous mblock may subsist when moving elastic down * * Previous block support * Not 100% sure here, but I have seen trees floating on water. Inserting air seems to be ok * * Elasticity * If you want to insert block (not replace), you need push up all blocks above * * TileEntities * They are destroyed and re-created on elastic motion * This is why container lose content. I could at least drop it on ground, * or store it an re-assign (tedious and bad performance, unless I can assign the list pointer ?) * * * * FIXME: * - multiblock, block a travers arbre (push multiblock ne suffit pas ? est ce qu'on pousse le parent ? ...) * - multipush : use moveto condition (y>target) * * - Manage entity collision: Avoid or Push * Must be managed, otherwise "zombie felt out of the world", or player stuck (even after "trying to unstick them") * * - Manage blocks! * - Elastic : Push or attract, elasticursively * For y axis only (other axis possible, but less guaranteed vertical support for moved blocks) * - Avoid * - TODO: small decoration only, terrain only ... * - TODO: water * - TODO: elastic down * **/ /* FIXME: I need unicize the above blocks and entities when applying push up, just before any yield * * Block.HasTileEntity, OnBlockRemoved(), PlaceBlock() * * chunkSync3.StopStabilityCalculation = false; * * TileEntity.public static TileEntity Instantiate(TileEntityType type, Chunk _chunk) * * * if (this.isMultiBlock && _blockValue.ischild) * { * Vector3i parentPos = this.multiBlockPos.GetParentPos(_blockPos, _blockValue); * BlockValue block = _world.GetBlock(parentPos); * */ // static bool ProtectLCB = true; // public static BlockValue GenBlockValue(Block block) { // /// Return a new BlockValue, or the "singleton" Air instance. // if (block == null) return BlockValue.Air; // return new BlockValue((uint) block.blockID); // } /* * * terrSnow * terrBrownGrassDiagnoal (decoration !) * terrBurntForestGround * terrGravel (sentier) * terrForestGround * terrTallGrassDiagonal (c'estt un bloc - empeche de plaser - mais non collidant) * terrrAsphalt (Diresville), cconcretePlate, concretePillar100 * cntBirdNest * terrDestroyedStone (wasteland * treeBurntMaple02 * cinderBlock02 * terrDesertGround * terrStone (dans le desert, un peu partout...) * terrDesertShrub (decoration vegatale) * rockResource * mushroom01 (grosses pierres, à spawn pour rouler depuis falaise) * flagstoneBlock * treeDeadPineLeaf * driftWood (bois desert) * orePotassiumNitrateBoulder * plantedAloe3Harvest * plantedYucca3Harvest * treeCactus04 : un petit */ // GameManager.ShowTooltipWithAlert(_data.holdingEntity as EntityPlayerLocal, "You cannot use that at this time.", "ui_denied"); public static void SetBlockAt(Vector3i where, Block block, OptionEffect options) { BlockSetter setter = new BlockSetter(options.OptionBlock); Block[] previous = setter.options.blocks; setter.options.block = block; setter.Apply(where); setter.Push(); setter.options.blocks = previous; }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Print("SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item); Vector3i where = Vectors.ToInt(player.GetPosition()); int y0 = Geo3D.Surface(where).y; Vector3i nw4 = ZChunk.TL4(place.ipos); Bounds b4 = ZChunk.Bounds4(nw4, y0); Zombiome.Routines.Start(Regen(player, b4, y0), name + "-SingleChunked"); }
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 override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(40, "RiftCollapse Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); // Zombiome.Routines.Start(EffectsCollapse.Rift(player, place, opt), "RiftCollapse"); Zombiome.Routines.Named("RiftCollapse").Start( Routines.Call(biome.groundParticleEffect, place.ipos), ZBActivity.Environment.ZBSounds.Play(ZBiomeInfo.NoiseCollapse, place.position, player, World, 1, 20, 0.2f), new WaitForSeconds(1f), EffectsCollapse.Rift(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(60, "Peak Effect1", place.position, place.ipos, opt.OptionBlock.blocks, opt.OptionShape.shape); // FIXME: this syntax cannot be merged ! Zombiome.Routines.Named("Peak").Start( // treeGib_birch_15m creates falling leaves above smoke :( Routines.Call(biome.groundParticleEffect, place.ipos), // "treeGib_burnt_small" new WaitForSeconds(1f), EffectsGround.Peak(player, place, opt) ); }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(46, "SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item); Vector3i where = Vectors.ToInt(player.GetPosition()); int y0 = Geo3D.Surface(where).y; Vector3i nw4 = ZChunk.TL4(place.ipos); Zombiome.Routines.Start(Regen(player, nw4, y0), name + "-SingleChunked0"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 0), y0), name + "-SingleChunked1"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(0, 0, 1), y0), name + "-SingleChunked2"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 1), y0), name + "-SingleChunked3"); }
public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt) { if (target.Buffs.HasBuff(buff)) { yield break; } Vector3 dir = -0.5f * Vectors.Float.UnitY; EntityMover mover = new EntityMover(1); // .Config(1); yield return(mover.Move(target, dir)); target.Buffs.AddBuff(buff); }
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; }
private IEnumerator PeakProj(EntityPlayer player, Emplacement place, OptionEffect opt) { yield return(EffectsGround.Peak(player, place, opt)); for (int k = 0; k < 10; k++) { Vector3 pos = place.position + (opt.OptionShape.shape.y + 2) * Vectors.Float.UnitY; yield return(EffectsItem.spawnItemGhost(opt.OptionItem.item, pos, 3 * (Vectors.Float.UnitY + Placer.directions.Generate(pos).normalized) )); yield return(new WaitForSeconds(0.5f)); } }
public override IEnumerator _Next(EntityPlayer player) { /* Over should keep some memory (position), and regenerate toward player */ long start_time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); Emplacement placeBase = new Emplacement(player, opt); placeBase.direction = Vectors.Float.Randomize(this.rand, 1f); // useless for peak Printer.Log(46, "MultiEffect._Next() placeBase", player, placeBase.position, placeBase.direction); foreach (int p in Cycler.Over()) { if (Cycler.dt >= 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start_time > (long)(Cycler.dt * 1000)) { yield break; } Printer.Log(41, "_Next iterating Over"); Vector3 maybeFollowing = (this.isFollowing) ? player.GetPosition() : placeBase.position; int q = -1; foreach (Emplacement place in Iter.On(Placer.Get(maybeFollowing))) { q = q + 1; if (q >= Repeater.n) { break; } if (place.valid) { Printer.Log(40, "MultiEffect._Next iterating Clones", place); // last before null (firestorm) // float state = ((float) q) / Repeater.copies; OptionEffect rdm = Randomize(); Printer.Log(40, "_Next Randomized", p, q, opt); Printer.Log(40, "_Next Place", p, q, place); this.Effect1(player, place, rdm); } else { Printer.Log(40, "Invalid place:", q, place, place.valid_msg); } yield return(Repeater.Yield); } yield return(Cycler.Yield); } }
public static void MaybeFloatingObject(string seed, OptionEffect Options, float rate = 1f) { /* Ground effect use airFull below surface to make ground/decoration float * * FIXME: ground becomes the inserted air, so this ends up digging via offset ! * I could also have a special effect that spawns the decoration and make it float * */ if (true) { return; // DISACTIVATED } if (Hashes.Rand(seed, "FloatingObject") > rate) { return; } Options.OptionBlock.SetBlocks("airFull"); Options.OptionBlock.avoidBlock = false; Options.OptionBlock.elastic = 10; Options.OptionShape.offsetSurface = 0; // -2 is too deep. 0 with elastic is enough to have 1 block ! }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { World World = GameManager.Instance.World; Vector3i ipos = place.ipos; Vector3i surf = Geo3D.Surface(ipos, (int)player.GetPosition().y); BlockValue existingB = World.GetBlock(surf + Vectors.Up); string existing = existingB.Block.ToString(); if (existingB.type == 0) // air { BlockValue insert = GenBV(); World.SetBlockRPC(0, surf + Vectors.Up, insert); } else { if (!decorationsSet.Contains(existing)) { return; } } Zombiome.Routines.Start(EffectsGround.Peak(player, place, opt), "FloatingDeco-Peak"); }
public override IEnumerator _Next(EntityPlayer player) { Vector3 ppos = player.GetPosition(); // if (entities.Count == 0) { // Printer.Print("AtEntities empty at ", bounds, player); // yield break; // } foreach (int p in Repeater.Over()) { Bounds bounds = BoundToPosition(ppos, Placer.Bounds(ppos)); Iter.EverySeconds(ref last_entities_update, updateEvery, this.UpdateEntities, bounds); // Printer.Print("AtEntities_Next Over"); // for (int draw=0; draw< Repeater.n; draw++) { // Downscale only if all entities can't be treated at once. Don't upscale above. int nUpdates = Math.Min(entities.Count, (int)Math.Ceiling(rate * entities.Count)); for (int draw = 0; draw < nUpdates; draw++) { // EntityAlive target = entities[this.NextIndex()] as EntityAlive; // Printer.Print("AtEntities_Next Clones", draw, target); // last before null (firestorm) EntityAlive target = SdtdUtils.Cycling.Next(entities, ref _indexEnt) as EntityAlive; if (target != null) { OptionEffect rdm = Randomize(); Printer.Log(40, "AtEntities_Next Randomized", draw, target, opt); yield return(this.Apply(player, target, rdm)); } else { Printer.Log(40, "AtEntities_Next null Entity", draw); } yield return(Repeater.Yield); } yield return(Cycler.Yield); // a single cycle } }
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)); }