-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dummy move through walls during respawn
- Loading branch information
Showing
9 changed files
with
119 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { world, system, Vector3 } from "@minecraft/server"; | ||
import { MinecraftDimensionTypes } from "@minecraft/vanilla-data"; | ||
|
||
export enum TaskType { | ||
SpawnSteve = 1, | ||
PathFind, | ||
SpawnAlex, | ||
SpawnCustom, | ||
} | ||
|
||
const overworld = world.getDimension("overworld"); | ||
|
||
system.runInterval(() => { | ||
for (const dummyEntity of overworld.getEntities({ type: "entity:dummy" })) { | ||
const spawnLocation = dummyEntity.getDynamicProperty( | ||
"dummy:spawn_location" | ||
) as Vector3 | undefined; | ||
const spawnDimension = dummyEntity.getDynamicProperty( | ||
"dummy:spawn_dimension" | ||
) as MinecraftDimensionTypes | undefined; | ||
if (!spawnLocation || !spawnDimension) continue; | ||
dummyEntity.teleport(spawnLocation, { | ||
dimension: world.getDimension(spawnDimension), | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
EntityHealthComponent, | ||
TicksPerSecond, | ||
system, | ||
world, | ||
} from "@minecraft/server"; | ||
import { MinecraftEffectTypes } from "@minecraft/vanilla-data"; | ||
import { debugEnabled } from "../config"; | ||
import { getSpreadLocation } from "../dummyEntity/spreadDummies"; | ||
import { TerminatorEntity } from "./terminator"; | ||
|
||
const overworld = world.getDimension("overworld"); | ||
|
||
// detect when terminator's health is below 20hp (max 60hp) | ||
system.runInterval(() => { | ||
for (const entity of overworld.getEntities({ type: "entity:terminator" })) { | ||
const health = entity.getComponent("health") as EntityHealthComponent; | ||
const dangerEscapeTriggered = | ||
(entity.getDynamicProperty("terminator:escape_triggered") as | ||
| boolean | ||
| undefined) ?? false; | ||
|
||
if (!health.isValid() || dangerEscapeTriggered) continue; | ||
if ( | ||
health.currentValue < 20 && | ||
!entity.hasTag("terminatorNoRegeneration") | ||
) { | ||
entity.addEffect(MinecraftEffectTypes.Regeneration, 6 * TicksPerSecond, { | ||
amplifier: 4, | ||
showParticles: false, | ||
}); | ||
entity.addEffect(MinecraftEffectTypes.Absorption, 24 * TicksPerSecond, { | ||
amplifier: 3, | ||
showParticles: false, | ||
}); | ||
entity.addEffect(MinecraftEffectTypes.Resistance, 60 * TicksPerSecond, { | ||
amplifier: 0, | ||
showParticles: false, | ||
}); | ||
entity.addEffect( | ||
MinecraftEffectTypes.FireResistance, | ||
60 * TicksPerSecond, | ||
{ | ||
amplifier: 0, | ||
showParticles: false, | ||
} | ||
); | ||
|
||
// Trigger terminator to pathfind to a random location within 32-48 block radius | ||
const terminator = new TerminatorEntity(entity); | ||
const locationOffsetXZ = { | ||
x: Math.floor(Math.random() * 32 - 17 + terminator.location.x), | ||
z: Math.floor(Math.random() * 32 - 17 + terminator.location.z), | ||
}; | ||
const locationOffset = getSpreadLocation( | ||
locationOffsetXZ, | ||
entity.dimension | ||
); | ||
if (debugEnabled) | ||
terminator.chat( | ||
`I'm going to ${locationOffset.x}, ${locationOffset.y}, ${locationOffset.z}!` | ||
); | ||
terminator.navigateToLocation(locationOffset); | ||
terminator.setDynamicProperty("terminator:escape_triggered", true); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters