Skip to content

Commit

Permalink
feat(leftCorridor): add zones to trigger the goblin suicide
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 7, 2023
1 parent c5a0f60 commit c91d45d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
41 changes: 40 additions & 1 deletion src/gameStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export const createGameStateManager = (settings: Settings) => {

const numberOfCollectedGames = new Variable('int', 'number_of_collected_games', 0)
const playerFoundAnyGames = new Variable('bool', 'player_found_any_games', false)
const isGoblinReadyForSuicide = new Variable('bool', 'is_goblin_ready_for_suicide', false)
const isGoblinDead = new Variable('bool', 'is_goblin_dead', false)
const haveLittered = new Variable('bool', 'have_littered', false)

manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinDead)
manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinReadyForSuicide, isGoblinDead)

manager.script?.subroutines.push(
tutorialWelcome,
Expand Down Expand Up @@ -123,5 +124,43 @@ export const createGameStateManager = (settings: Settings) => {
`
})

manager.script?.on('entered_at_the_game_displays_zone', () => {
return `
if (${numberOfCollectedGames.name} < 7) {
accept
}
if (${isGoblinDead.name} == 1) {
accept
}
if (${isGoblinReadyForSuicide.name} == 1) {
accept
}
set ${isGoblinReadyForSuicide.name} 1
sendevent goblin_vanishes self nop
`
})

manager.script?.on('entered_at_the_main_hall_zone', () => {
return `
if (${numberOfCollectedGames.name} < 7) {
accept
}
if (${isGoblinReadyForSuicide.name} == 0) {
accept
}
if (${isGoblinDead.name} == 1) {
accept
}
set ${isGoblinDead.name} 1
sendevent goblin_suicide self nop
`
})

return manager
}
38 changes: 35 additions & 3 deletions src/rooms/leftCorridor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Entity, Material, Rotation, Settings, Texture, Vector3 } from 'arx-level-generator'
import { createBox } from 'arx-level-generator/prefabs/mesh'
import { Scale, Shadow } from 'arx-level-generator/scripting/properties'
import { ControlZone, Scale, Shadow } from 'arx-level-generator/scripting/properties'
import { createZone } from 'arx-level-generator/tools'
import { circleOfVectors } from 'arx-level-generator/utils'
import { MathUtils } from 'three'
import { GameDisplay } from '@/entities/GameDisplay.js'
Expand Down Expand Up @@ -122,11 +123,42 @@ export const createLeftCorridor = async (
return `sendevent player_found_a_game ${gameStateManager.ref} ${game.variant}`
})

const atTheGameDisplaysZone = createZone({
name: 'at_the_game_displays',
size: new Vector3(200, Infinity, 200),
position: new Vector3(-1900, 0, 0),
})

const atTheGameDisplaysZoneController = Entity.marker.at({ position: new Vector3(-1900, 0, 0) }).withScript()
atTheGameDisplaysZoneController.script?.properties.push(new ControlZone(atTheGameDisplaysZone))
atTheGameDisplaysZoneController.script?.on('controlledzone_enter', () => {
return `sendevent entered_at_the_game_displays_zone ${gameStateManager.ref} nop`
})

const atTheMainHallZone = createZone({
name: 'at_the_main_hall',
size: new Vector3(200, Infinity, 200),
position: new Vector3(-400, 0, 0),
})

const atTheMainHallZoneController = Entity.marker.at({ position: new Vector3(-1900, 0, 0) }).withScript()
atTheMainHallZoneController.script?.properties.push(new ControlZone(atTheMainHallZone))
atTheMainHallZoneController.script?.on('controlledzone_enter', () => {
return `sendevent entered_at_the_main_hall_zone ${gameStateManager.ref} nop`
})

return {
meshes: [...bases],
entities: [rootMirror, mirror, ...Object.values(gameDisplays), game],
entities: [
rootMirror,
mirror,
...Object.values(gameDisplays),
game,
atTheGameDisplaysZoneController,
atTheMainHallZoneController,
],
lights: [],
zones: [],
zones: [atTheGameDisplaysZone, atTheMainHallZone],
_: {},
}
}
2 changes: 1 addition & 1 deletion src/rooms/mainHall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const createMainHall = async (
})
}

gameStateManager.script?.on('goblin_suicide', () => {
gameStateManager.script?.on('goblin_vanishes', () => {
return `destroy ${goblin.ref}`
})

Expand Down
2 changes: 2 additions & 0 deletions src/rooms/pcRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const createPCRoom = async (settings: Settings, gameStateManager: Entity)
sendevent change_to_big_rigs ${computer._.screen.ref} nop
sendevent emit_dying_sound ${hangedGoblin.ref} nop
// TODO: close the door
`
})

Expand Down

0 comments on commit c91d45d

Please sign in to comment.