id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
listlengths
1
47
2,774
seed.ui-spec.form.mode-document.asd
phantomics_seed/seed.ui-spec.form.mode-document/seed.ui-spec.form.mode-document.asd
;;;; seed.ui-spec.form.mode-document.asd (asdf:defsystem #:seed.ui-spec.form.mode-document :description "Component for display and interaction with rich text documents." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "form.mode-document")))
314
Common Lisp
.asd
8
34.875
80
0.700658
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e53525aaba681f3ba3d0f5228d90a556fc02b3169356df54ec1737262720c171
2,774
[ -1 ]
2,775
demo-sheet.asd
phantomics_seed/demo-sheet/demo-sheet.asd
;;;; demo-sheet.asd (asdf:defsystem #:demo-sheet :description "This is demoSheet, a package created to demonstrate Seed's spreadsheet module." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:april #:seed.app-model.sheet.base #:seed.app-model.graph.garden-path #:seed.app-model.document-slate.base) :components ((:file "package") (:file "main") (:file "graph")))
412
Common Lisp
.asd
12
30.833333
95
0.691729
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
c51898ef82a190938e2c9835b9f7383d9716b7f19eafdc2262b83549d4c17ab4
2,775
[ -1 ]
2,776
seed.ui-model.css.asd
phantomics_seed/seed.ui-model.css/seed.ui-model.css.asd
;;;; seed.ui-model.css.asd (asdf:defsystem #:seed.ui-model.css :description "Models by which the CSS for Seed's Web interface are generated." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "package") (:file "ui-model.css")))
278
Common Lisp
.asd
8
30.375
80
0.664179
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
68055246dfd9cbcfd1f47ede8295c77a2b45e449fc324424a8c4731ff5c48838
2,776
[ -1 ]
2,777
seed.ui-spec.css.base.asd
phantomics_seed/seed.ui-spec.css.base/seed.ui-spec.css.base.asd
;;;; seed.ui-spec.css.base.asd (asdf:defsystem #:seed.ui-spec.css.base :description "Standard CSS rules for Seed UI." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "css.base")))
244
Common Lisp
.asd
8
27.125
48
0.668085
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
b949823650120fa5f43a6b4fec4718c9175979b7c6b322a31cfb8d49812d27a3
2,777
[ -1 ]
2,778
demo-drawing.asd
phantomics_seed/demo-drawing/demo-drawing.asd
;;;; demo-drawing.asd (asdf:defsystem #:demo-drawing :description "Describe test-drawing here" :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:cl-who #:seed.sublimate) :components ((:file "package") (:file "format") (:file "main")))
276
Common Lisp
.asd
11
22
43
0.665399
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
998d8e0564010b77aba686f0ed398ed318dbb5772239411570520198f4cbeffa
2,778
[ -1 ]
2,779
seed.ui-effects.vector.base.asd
phantomics_seed/seed.ui-effects.vector.base/seed.ui-effects.vector.base.asd
;;;; seed.ui-effects.vector.base.asd (asdf:defsystem #:seed.ui-effects.vector.base :description "A set of common effects for items in vector-based displays within the Seed user interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "vector.base")))
326
Common Lisp
.asd
8
36.375
107
0.699367
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ee9a2b60774756e96fcd036259168124259210bf58039488e3a52b6ab9209398
2,779
[ -1 ]
2,780
demo-market.asd
phantomics_seed/demo-market/demo-market.asd
;;;; demo-market.asd (asdf:defsystem #:demo-market :description "Sample Seed system implementing a market data visualizer." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (:local-time :cl-date-time-parser) :components ((:file "package") (:file "main") (:file "utils")))
325
Common Lisp
.asd
10
27.8
74
0.654952
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ac204613cdbeb22ea35bbf5fc0ea93462fd027984ec221ebc46319eb81e7b225
2,780
[ -1 ]
2,781
seed.ui-spec.color.base.asd
phantomics_seed/seed.ui-spec.color.base/seed.ui-spec.color.base.asd
;;;; seed.ui-spec.color.base.asd (asdf:defsystem #:seed.ui-spec.color.base :description "Common color palettes and specifications for Seed user interfaces." :author "Andrew Sengul" :license "GPL-3.0" :version "0.0.1" :serial t :components ((:file "package") (:file "color.base")))
310
Common Lisp
.asd
9
30.333333
83
0.676667
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
33a2de4a90ed4948f7e599377f94d7f16979048370c44b672989e70e86ff2c87
2,781
[ -1 ]
2,782
seed.ui-model.html.asd
phantomics_seed/seed.ui-model.html/seed.ui-model.html.asd
;;;; seed.ui-model.html.asd (asdf:defsystem #:seed.ui-model.html :description "The model used to construct the foundation of Seed's HTML-based interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:cl-who #:cl-ppcre #:parenscript #:lass #:symbol-munger #:seed.modulate) :components ((:file "package") (:file "qualify-build") (:file "ui-model.html")))
399
Common Lisp
.asd
11
33.181818
91
0.69171
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
b572f865d6be1741bfb87d6b5382dcfde3968209fa42f91c7cab4c06a1ee7725
2,782
[ -1 ]
2,783
seed.modes.meta.common.asd
phantomics_seed/seed.modes.meta.common/seed.modes.meta.common.asd
;;;; seed.modes.meta.common.asd (asdf:defsystem #:seed.modes.meta.common :description "A set of common meta-formats, used to transform code when it is written according to meta-properties." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "meta.common")))
327
Common Lisp
.asd
8
36.5
118
0.697161
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
92db3053c7e5a35ed71a6521ef036fc5b05e677c6652fe66b3abc662cae6016a
2,783
[ -1 ]
2,784
seed.ui-spec.stage-controls.chart.base.asd
phantomics_seed/seed.ui-spec.stage-controls.chart.base/seed.ui-spec.stage-controls.chart.base.asd
;;;; seed.ui-spec.stage-controls.chart.base.asd (asdf:defsystem #:seed.ui-spec.stage-controls.chart.base :description "Common control interface specs for charts, currently with a focus on financial charting." :author "Andrew Sengul" :license "GPL-3.0" :version "0.0.1" :serial t :components ((:file "extension") (:file "chart.base")))
364
Common Lisp
.asd
9
36.333333
105
0.700565
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
03557445724942e1614738e9b09cf1f5b0fa3b2f7b188861bba8ce9688651623
2,784
[ -1 ]
2,785
seed.generate.asd
phantomics_seed/seed.generate/seed.generate.asd
;;;; seed.generate.asd (asdf:defsystem #:seed.generate :description "The heart of Seed, seed.generate encompasses the means by which Seed systems grow and change." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:asdf #:jonathan #:fare-quasiquote #:quickproject #:symbol-munger #:seed.sublimate) :components ((:file "package") (:file "generate")))
393
Common Lisp
.asd
11
32.363636
110
0.706037
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
f4cafa8f9537003d878c4ad7887896babd85c224eca01f8bba10eaf741d647af
2,785
[ -1 ]
2,786
demo-blog.asd
phantomics_seed/demo-blog/demo-blog.asd
;;;; demo-blog.asd (asdf:defsystem #:demo-blog :description "Sample Seed system implementing a web publishing environemnt." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "package") (:file "main")))
252
Common Lisp
.asd
8
27.125
78
0.669421
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
962310a591bcb5005a1b35c10828dd94c2fd519ab1eed51792917dc63c59e71d
2,786
[ -1 ]
2,787
seed.app-model.document-slate.base.asd
phantomics_seed/seed.app-model.document-slate.base/seed.app-model.document-slate.base.asd
;;;; seed.app-model.document-slate.base.asd (asdf:defsystem #:seed.app-model.document-slate.base :description "Seed application model for documents, reflecting the common data structures of the Slate document editing interface built with React.js." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (:cl-who) :components ((:file "package") (:file "document-slate.base")))
416
Common Lisp
.asd
9
42
153
0.723457
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
9636332b845daf9e6a1be7b121e1ce9eac537de25c2bcc26c55d1259ac7aa9c9
2,787
[ -1 ]
2,788
seed.ui-spec.keys.map-apl.asd
phantomics_seed/seed.ui-spec.keys.map-apl/seed.ui-spec.keys.map-apl.asd
;;;; seed.ui-spec.keys.map-apl.asd (asdf:defsystem #:seed.ui-spec.keys.map-apl :description "Keybindings for Seed's APL input mode." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "package") (:file "keys.map-apl")))
269
Common Lisp
.asd
8
29.25
55
0.656371
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
1bb3a27b7756d38f5625aa6ea75c7bdbeaf94b8e9ff9fd0df4139384d027d9f2
2,788
[ -1 ]
2,789
seed.ui-spec.html-css.glyph-set-mdi.asd
phantomics_seed/seed.ui-spec.html-css.glyph-set-mdi/seed.ui-spec.html-css.glyph-set-mdi.asd
;;;; seed.ui-spec.html-css.glyph-set-mdi.asd (asdf:defsystem #:seed.ui-spec.html-css.glyph-set-mdi :description "HTML glyph elements incorporating material design icons." :author "Andrew Sengul" :license "GPL-3.0" :version "0.0.1" :serial t :components ((:file "package") (:file "html-css.glyph-set-mdi")))
336
Common Lisp
.asd
9
33.222222
73
0.680982
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
9e03eac6ceeae98d9844388b9330d7d5756659531057d9982c64694397c1e9c0
2,789
[ -1 ]
2,790
seed.app-model.sheet.base.asd
phantomics_seed/seed.app-model.sheet.base/seed.app-model.sheet.base.asd
;;;; seed.app-model.sheet.base.asd (asdf:defsystem #:seed.app-model.sheet.base :description "Seed data model for spreadsheet applications." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:jonathan #:parse-number #:swank) :components ((:file "package") (:file "sheet.base")))
315
Common Lisp
.asd
10
28.5
62
0.69967
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e7eeac9b689f8b1992518273459be9749a62542beb5403bb26eaf6630d9c0e1d
2,790
[ -1 ]
2,791
seed.ui-model.react.asd
phantomics_seed/seed.ui-model.react/seed.ui-model.react.asd
;;;; seed.ui-model.react.asd (asdf:defsystem #:seed.ui-model.react :description "The model for React component templats used in the Seed interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:parenscript #:panic) :components ((:file "package") (:file "ui-model.react")))
316
Common Lisp
.asd
10
28.6
83
0.700658
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
7571dbf9b0f9ce80ffb9e94362e78790c3fcc10ea316c2122b8c33c8021facc0
2,791
[ -1 ]
2,792
seed.ui-spec.form.mode-text.asd
phantomics_seed/seed.ui-spec.form.mode-text/seed.ui-spec.form.mode-text.asd
;;;; seed.ui-spec.form.mode-text.asd (asdf:defsystem #:seed.ui-spec.form.mode-text :description "Mode for text editor" :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "form.mode-text")))
259
Common Lisp
.asd
8
28
45
0.658635
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
986326b14b321f6eb6ba75849444403c60ed09d92054979ce78babfda9038e37
2,792
[ -1 ]
2,793
seed.ui-spec.form.base.asd
phantomics_seed/seed.ui-spec.form.base/seed.ui-spec.form.base.asd
;;;; seed.ui-spec.form.base.asd (asdf:defsystem #:seed.ui-spec.form.base :description "Standard templates for the display of interactive data forms (i.e. Lisp programs) in the Seed interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "form.base")))
328
Common Lisp
.asd
8
36.625
121
0.688679
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
53931ee49571db8a3b1c5e5b90b8dcec477ae96f960fe28603f62f5381c1c30d
2,793
[ -1 ]
2,794
panic.asd
phantomics_seed/panic/panic.asd
;;;; panic.asd ;;; The MIT License (MIT) ;;; ;;; Copyright (c) 2015 Michael J. Forster ;;; ;;; Permission is hereby granted, free of charge, to any person obtaining a copy ;;; of this software and associated documentation files (the "Software"), to deal ;;; in the Software without restriction, including without limitation the rights ;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;;; copies of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be included in all ;;; copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;; SOFTWARE. (asdf:defsystem #:panic :description "Common Lisp (Parenscript) library for React" :version "0.1.0" :author "Michael J. Forster <mike@forsterfamily.ca>" :license "MIT" :depends-on (#:alexandria #:parenscript) :serial t :components ((:file "package") (:file "panic")))
1,512
Common Lisp
.asd
32
44.25
82
0.724628
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
593c9237ae47abbbdf7a086038c3fa8f6c93c0d71e7e6f0ca0947a3427ef7fc4
2,794
[ 91475 ]
2,795
seed.ui-spec.form.mode-block-space.asd
phantomics_seed/seed.ui-spec.form.mode-block-space/seed.ui-spec.form.mode-block-space.asd
;;;; seed.ui-spec.form.mode-block-space.asd (asdf:defsystem #:seed.ui-spec.form.mode-block-space :description "Voxel space" :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "extension") (:file "form.mode-block-space")))
271
Common Lisp
.asd
8
29.5
52
0.670498
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
dfaa719a9d640907b6f555f2f2482611015956b8117701f4c4150fc909495b7f
2,795
[ -1 ]
2,796
seed.foreign.browser-spec.ss.form-dygraphs.asd
phantomics_seed/seed.foreign.browser-spec.ss.form-dygraphs/seed.foreign.browser-spec.ss.form-dygraphs.asd
;;;; seed.foreign.browser-spec.ss.form-dygraphs.asd (asdf:defsystem #:seed.foreign.browser-spec.ss.form-dygraphs :description "Specifies the Javascript packages to include to build the dygraphs display modules." :author "Andrew Sengul" :license "GPL-3.0" :version "0.0.1" :serial t :components ((:file "package") (:file "ss.form-dygraphs")))
371
Common Lisp
.asd
9
37.111111
100
0.709141
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5ae138cfd90bdd9666f705b3dac598143ac135d8f5f7ef64f97464ca6ab515e5
2,796
[ -1 ]
2,797
seed.ui-spec.form.mode-chart-dygraph.asd
phantomics_seed/seed.ui-spec.form.mode-chart-dygraph/seed.ui-spec.form.mode-chart-dygraph.asd
;;;; seed.ui-spec.form.mode-chart-dygraph.asd (asdf:defsystem #:seed.ui-spec.form.mode-chart-dygraph :description "A template for the display of interactive charts using the dygraphs library." :author "Andrew Sengul" :license "GPL-3.0" :version "0.0.1" :serial t :components ((:file "extension") (:file "form.mode-chart-dygraph")))
360
Common Lisp
.asd
9
35.888889
93
0.7
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ad97cfa87cca24a821234496172812eeaa2faa109a4090b520b5216869a43b79
2,797
[ -1 ]
2,798
seed.ui-model.stage.asd
phantomics_seed/seed.ui-model.stage/seed.ui-model.stage.asd
;;;; seed.ui-model.stage.asd (asdf:defsystem #:seed.ui-model.stage :description "The model of Seed's interface layout." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "package") (:file "ui-model.stage")))
248
Common Lisp
.asd
9
24.666667
54
0.687764
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
4f21b418659b2c35ea30d82b42ed00b2d5ca488c13c15f6d7b1978c1d3ea47b2
2,798
[ -1 ]
2,799
seed.app-model.raster-layers.base.asd
phantomics_seed/seed.app-model.raster-layers.base/seed.app-model.raster-layers.base.asd
;;;; seed.app-model.raster-layers.base.asd (asdf:defsystem #:seed.app-model.raster-layers.base :description "Seed application model for a layer-based raster image editor, using the opticl library for image processing." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (:opticl :april) :components ((:file "package") (:file "raster-layers.base")))
392
Common Lisp
.asd
9
39.333333
125
0.711286
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
458e5d4889d67ca69fde9f297e2006123f521bb3f7f3deb4fdc0eb8ae13265b0
2,799
[ -1 ]
2,800
seed.modes.form.base.asd
phantomics_seed/seed.modes.form.base/seed.modes.form.base.asd
;;;; seed.modes.form.base.asd (asdf:defsystem #:seed.modes.form.base :description "Baseline specifications for modulating forms in Seed." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "form.base") (:file "extension")))
258
Common Lisp
.asd
7
34.142857
70
0.718876
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
a53ef8660a81adb62aee61a7c2bda8ac303e6bfdcfc1c2a4c0abe3122933e194
2,800
[ -1 ]
2,801
seed.foreign.browser-spec.script.base.asd
phantomics_seed/seed.foreign.browser-spec.script.base/seed.foreign.browser-spec.script.base.asd
;;;; seed.foreign.browser-spec.script.base.asd (asdf:defsystem #:seed.foreign.browser-spec.script.base :description "Defines the system through which Javascript modules are compiled and built to create the base library supporting Seed interface functions in the browser." :author "Andrew Sengul" :license "GPL" :serial t :depends-on (#:parenscript) :components ((:file "package") (:file "script.base")))
433
Common Lisp
.asd
9
43.888889
170
0.736967
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
9bd85473650dcd7304862df58b8c80a143a8f34ec39f342a22a6c15a65a817a0
2,801
[ -1 ]
2,802
seed.ui-spec.keys.base.asd
phantomics_seed/seed.ui-spec.keys.base/seed.ui-spec.keys.base.asd
;;;; seed.ui-spec.keys.base.asd (asdf:defsystem #:seed.ui-spec.keys.base :description "The standard Seed interface keybindings." :author "Andrew Sengul" :license "GPL-3.0" :serial t :components ((:file "package") (:file "keys.base")))
251
Common Lisp
.asd
9
25.111111
57
0.697095
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
d4d618c8bb33a7cb5d741160db08eb5f3d25a8757df67ec54b8a2ce51412e562
2,802
[ -1 ]
2,803
seed.ui-spec.html.base.asd
phantomics_seed/seed.ui-spec.html.base/seed.ui-spec.html.base.asd
;;;; seed-ui-spec.html.base.asd (asdf:defsystem #:seed.ui-spec.html.base :description "The standard HTML container elements used to display the Seed interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:symbol-munger) :components ((:file "package") (:file "html.base")))
317
Common Lisp
.asd
10
28.7
89
0.704918
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
41cabb1ed7c2980f1708dcc946a2303c6f2424547439999747b2d16bbab0f6ad
2,803
[ -1 ]
2,804
seed.sublimate.asd
phantomics_seed/seed.sublimate/seed.sublimate.asd
;;;; seed.sublimate.asd (asdf:defsystem #:seed.sublimate :description "By catalyzing the formation of meta-structures beyond standard Common Lisp data structures, seed.sublimate informs and empowers programmers of Seed systems." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:prove) :components ((:file "package") (:file "sublimate") (:file "test")))
395
Common Lisp
.asd
11
32.818182
173
0.730366
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5f1942aa63367af600d835d709f5611fe2a81d8b124ec66ea1d16330b32258d8
2,804
[ -1 ]
2,805
seed.app-model.graph.garden-path.asd
phantomics_seed/seed.app-model.graph.garden-path/seed.app-model.graph.garden-path.asd
;;;; seed.model.graph.garden-path.asd (asdf:defsystem #:seed.app-model.graph.garden-path :description "Seed application model for 'garden path' graphs modeling environments traversed by user interaction." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (:uuid) :components ((:file "package") (:file "graph.garden-path")))
368
Common Lisp
.asd
9
36.666667
117
0.708683
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
210174ef8eef6eb50f463a0ec4922e3e393dd5adb45829d339b421bcb75cc261
2,805
[ -1 ]
2,806
seed.ui-spec.react.base.asd
phantomics_seed/seed.ui-spec.react.base/seed.ui-spec.react.base.asd
;;;; seed.ui-spec.react.base.asd (asdf:defsystem #:seed.ui-spec.react.base :description "The standard React components for the Seed interface." :author "Andrew Sengul" :license "GPL-3.0" :serial t :depends-on (#:parenscript #:panic) :components ((:file "extension") (:file "react.base")))
318
Common Lisp
.asd
9
31.111111
70
0.677524
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
a765f8c418ae385f8a31217ccd5842677bb0fe079aab2c893063f3516c470563
2,806
[ -1 ]
2,839
material-icons.css
phantomics_seed/seed.foreign.browser-spec.style.icons-m-design/material-icons.css
@font-face { font-family: 'Material Icons'; font-style: normal; font-weight: 400; src: url('./style-assets/material-design-iconfont/MaterialIcons-Regular.eot'); /* For IE6-8 */ src: local('Material Icons'), local('MaterialIcons-Regular'), url('./style-assets/material-design-iconfont/MaterialIcons-Regular.woff2') format('woff2'), url('./style-assets/material-design-iconfont/MaterialIcons-Regular.woff') format('woff'), url('./style-assets/material-design-iconfont/MaterialIcons-Regular.ttf') format('truetype'); } .material-icons { font-family: 'Material Icons'; font-weight: normal; font-style: normal; font-size: 24px; /* Preferred icon size */ display: inline-block; line-height: 1; text-transform: none; letter-spacing: normal; word-wrap: normal; white-space: nowrap; direction: ltr; /* Support for all WebKit browsers. */ -webkit-font-smoothing: antialiased; /* Support for Safari and Chrome. */ text-rendering: optimizeLegibility; /* Support for Firefox. */ -moz-osx-font-smoothing: grayscale; /* Support for IE. */ font-feature-settings: 'liga'; }
1,138
Common Lisp
.l
32
32.0625
99
0.712341
phantomics/seed
77
4
3
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5bff8733e36e070c850bcacf20c68df1fcae3101ff300e2613f9075c729db231
2,839
[ -1 ]
2,840
effects.lisp
gwathlobal_CotD/src/effects.lisp
(in-package :cotd) (defclass effect-type () ((id :initarg :id :accessor id) (name-func :initarg :name-func :accessor name-func) (color-func :initform #'(lambda (effect actor) (declare (ignore effect actor)) nil) :initarg :color-func :accessor color-func) (on-add :initform #'(lambda (effect actor) (declare (ignore effect actor)) nil) :initarg :on-add :accessor on-add) (on-remove :initform #'(lambda (effect actor) (declare (ignore effect actor)) nil) :initarg :on-remove :accessor on-remove) (on-tick :initform #'(lambda (effect actor) (declare (ignore effect actor)) nil) :initarg :on-tick :accessor on-tick) )) (defun set-effect-type (effect-type) (when (>= (id effect-type) (length *effect-types*)) (adjust-array *effect-types* (list (1+ (id effect-type))))) (setf (aref *effect-types* (id effect-type)) effect-type)) (defun get-effect-type-by-id (effect-type-id) (aref *effect-types* effect-type-id)) (defclass effect () ((id :initform 0 :accessor id :type fixnum) (effect-type :initarg :effect-type :accessor effect-type :type fixnum) (actor-id :initform nil :initarg :actor-id :accessor actor-id) (target-id :initform nil :initarg :target-id :accessor target-id) (cd :initform 0 :initarg :cd :accessor cd) (param1 :initform nil :initarg :param1 :accessor param1) )) (defmethod initialize-instance :after ((effect effect) &key) (setf (id effect) (find-free-id *effects*)) (setf (aref *effects* (id effect)) effect) ) (defmethod name ((effect effect)) (if (actor-id effect) (let ((actor (get-mob-by-id (actor-id effect)))) (funcall (name-func (get-effect-type-by-id (effect-type effect))) effect actor)) (funcall (name-func (get-effect-type-by-id (effect-type effect))) effect nil))) (defun get-effect-by-id (effect-id) (aref *effects* effect-id)) (defun remove-effect-from-world (effect) (setf (aref *effects* (id effect)) nil))
2,190
Common Lisp
.lisp
48
37.25
86
0.614627
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
7a533754c2ec8098a982e5a53ea235fa6316963a2b4d9b2f327eb394683b6f77
2,840
[ -1 ]
2,841
init-campaign-commands.lisp
gwathlobal_CotD/src/init-campaign-commands.lisp
(in-package :cotd) (set-campaign-command :id :campaign-command-angel-wait :name-func #'(lambda (world) (declare (ignore world)) "Wait & see") :descr-func #'(lambda (world) (declare (ignore world)) "Do nothing and wait.") :faction-type +faction-type-angels+ :disabled nil :cd 5 :on-check-func #'(lambda (world campaign-command) (declare (ignore world campaign-command)) t ) ) (set-campaign-command :id :campaign-command-demon-wait :name-func #'(lambda (world) (declare (ignore world)) "Wait & see") :descr-func #'(lambda (world) (declare (ignore world)) "Do nothing and wait.") :faction-type +faction-type-demons+ :disabled nil :cd 4 :on-check-func #'(lambda (world campaign-command) (declare (ignore world campaign-command)) t ) ) (set-campaign-command :id :campaign-command-military-wait :name-func #'(lambda (world) (declare (ignore world)) "Wait & see") :descr-func #'(lambda (world) (declare (ignore world)) "Do nothing and wait.") :faction-type +faction-type-military+ :disabled nil :cd 5 :on-check-func #'(lambda (world campaign-command) (declare (ignore world campaign-command)) t ) ) (set-campaign-command :id :campaign-command-church-wait :name-func #'(lambda (world) (declare (ignore world)) "Wait & see") :descr-func #'(lambda (world) (declare (ignore world)) "Do nothing and wait.") :faction-type +faction-type-church+ :disabled nil :cd 5 :on-check-func #'(lambda (world campaign-command) (declare (ignore world campaign-command)) t ) ) (set-campaign-command :id :campaign-command-eater-wait :name-func #'(lambda (world) (declare (ignore world)) "Wait & see") :descr-func #'(lambda (world) (declare (ignore world)) "Do nothing and wait.") :faction-type +faction-type-eater+ :disabled nil :cd 7 :on-check-func #'(lambda (world campaign-command) (declare (ignore world campaign-command)) t ) ) (set-campaign-command :id :campaign-command-satanist-sacrifice :name-func #'(lambda (world) (declare (ignore world)) "Sacrifice a citizen") :descr-func #'(lambda (world) (declare (ignore world)) "Find a new citizen and sacrifice them to give demons more opportunities to invade.") :faction-type +faction-type-satanists+ :disabled nil :cd 10 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((military-win-cond (get-win-condition-by-id :win-cond-military-campaign))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) world military-win-cond) (declare (ignore corrupted-sectors-left)) (if (not (zerop satanist-lairs-left)) t nil))) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-satanist-sacrifice :cd 5) )) (set-campaign-command :id :campaign-command-satanist-hide-lair :name-func #'(lambda (world) (declare (ignore world)) "Hide a lair") :descr-func #'(lambda (world) (declare (ignore world)) "Increase the paranoia level of your fellow cultists to protect the lair from infiltration.") :faction-type +faction-type-satanists+ :disabled nil :cd 7 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((military-win-cond (get-win-condition-by-id :win-cond-military-campaign))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) world military-win-cond) (declare (ignore corrupted-sectors-left)) (if (and (not (zerop satanist-lairs-left)) (not (find-campaign-effects-by-id world :campaign-effect-satanist-lair-visible))) t nil))) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-satanist-lair-hidden :cd 5) )) (set-campaign-command :id :campaign-command-satanist-reform-lair :name-func #'(lambda (world) (declare (ignore world)) "Reform a satanist' lair") :descr-func #'(lambda (world) (declare (ignore world)) "Seduce willing undividuals to recreate the once destroyed satanist' lair.") :faction-type +faction-type-satanists+ :disabled nil :cd 6 :priority 10 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((military-win-cond (get-win-condition-by-id :win-cond-military-campaign))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) world military-win-cond) (declare (ignore corrupted-sectors-left)) (if (zerop satanist-lairs-left) t nil)))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world)))) (add-message (format nil "There are whispers about ") sdl:*white* message-box-list) (add-message (format nil "satanists reforming their hideout") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) :on-trigger-end-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (place-satanist-lair-on-map (world-map world) 1) (let ((message-box-list `(,(world/event-message-box world)))) (add-message (format nil "The ") sdl:*white* message-box-list) (add-message (format nil "satanists' lair") sdl:*yellow* message-box-list) (add-message (format nil " has been ") sdl:*white* message-box-list) (add-message (format nil "reformed") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)) )) (set-campaign-command :id :campaign-command-demon-rebuild-engine :name-func #'(lambda (world) (declare (ignore world)) "Rebuild a dimensional engine") :descr-func #'(lambda (world) (declare (ignore world)) "Rebuild a destroyed dimensional engine.") :faction-type +faction-type-demons+ :disabled nil :cd 12 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (if (not (zerop (world/machine-destroyed world))) t nil)) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world)))) (add-message (format nil "There are whispers about ") sdl:*white* message-box-list) (add-message (format nil "demons rebuilding") sdl:*yellow* message-box-list) (add-message (format nil " one of their ") sdl:*white* message-box-list) (add-message (format nil "dimensional engines") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) :on-trigger-end-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (decf (world/machine-destroyed world)) (let ((message-box-list `(,(world/event-message-box world)))) (add-message (format nil "Demons have ") sdl:*white* message-box-list) (add-message (format nil "rebuilt") sdl:*yellow* message-box-list) (add-message (format nil " their ") sdl:*white* message-box-list) (add-message (format nil "dimensional engine") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)) )) (set-campaign-command :id :campaign-command-demon-add-army :name-func #'(lambda (world) (declare (ignore world)) "Raise a demonic army") :descr-func #'(lambda (world) (declare (ignore world)) "March a demonic army onto Earth to control one of the corrupted districts.") :faction-type +faction-type-demons+ :disabled nil :cd 5 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((corrupted-sectors 0)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-corrupted-p world-sector)) (incf corrupted-sectors))))) (if (and (> corrupted-sectors 0) (null (find-campaign-effects-by-id world :campaign-effect-demon-turmoil))) t nil)) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world))) (corrupted-sector-list ()) (selected-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-corrupted-p world-sector)) (push (list x y) corrupted-sector-list))))) (setf selected-sector (nth (random (length corrupted-sector-list)) corrupted-sector-list)) (setf (controlled-by (aref (cells (world-map world)) (first selected-sector) (second selected-sector))) +lm-controlled-by-demons+) (add-message (format nil "A ") sdl:*white* message-box-list) (add-message (format nil "demon army") sdl:*yellow* message-box-list) (add-message (format nil " has entered ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name (aref (cells (world-map world)) (first selected-sector) (second selected-sector)))) sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) ) (set-campaign-command :id :campaign-command-demon-protect-dimension :name-func #'(lambda (world) (declare (ignore world)) "Protect the Hell Dimension") :descr-func #'(lambda (world) (declare (ignore world)) "Invoke the rites from the Book of Rituals to prevent anybody from entering the Hell Dimension. The enchantment lasts as long as the demons control the Book of Rituals.") :faction-type +faction-type-demons+ :disabled nil :cd 5 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((book-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-item-book-of-rituals+ (items world-sector)) (world-sector-corrupted-p world-sector)) (setf book-sector t))))) (if (and book-sector (null (find-campaign-effects-by-id world :campaign-effect-demon-protect-dimension))) t nil)) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-demon-protect-dimension :cd nil) )) (set-campaign-command :id :campaign-command-demon-corrupt-portals :name-func #'(lambda (world) (declare (ignore world)) "Corrupt divine portals") :descr-func #'(lambda (world) (declare (ignore world)) "Invoke the rites from the Book of Rituals to make angels arrive delayed whenever they are present. The enchantment lasts as long as the demons control the Holy Relic.") :faction-type +faction-type-demons+ :disabled nil :cd 5 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((relic-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-item-holy-relic+ (items world-sector)) (world-sector-corrupted-p world-sector)) (setf relic-sector t))))) (if (and relic-sector (null (find-campaign-effects-by-id world :campaign-effect-demon-corrupt-portals))) t nil)) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-demon-corrupt-portals :cd nil) )) (set-campaign-command :id :campaign-command-military-reveal-lair :name-func #'(lambda (world) (declare (ignore world)) "Reveal a satanists' lair") :descr-func #'(lambda (world) (declare (ignore world)) "Infiltrate the satanists' lair and make it vulnerable for attack.") :faction-type +faction-type-military+ :disabled nil :cd 6 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((military-win-cond (get-win-condition-by-id :win-cond-military-campaign))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) world military-win-cond) (declare (ignore corrupted-sectors-left)) (if (and (not (zerop satanist-lairs-left)) (not (find-campaign-effects-by-id world :campaign-effect-satanist-lair-visible)) (not (find-campaign-effects-by-id world :campaign-effect-satanist-lair-hidden))) t nil)))) :on-trigger-end-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-satanist-lair-visible :cd 5) )) (set-campaign-command :id :campaign-command-military-reform-army :name-func #'(lambda (world) (declare (ignore world)) "Reform an army") :descr-func #'(lambda (world) (declare (ignore world)) "Recruit new soldiers to recreate a previously destroyed army.") :faction-type +faction-type-military+ :disabled nil :cd 6 :priority 10 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((residential-sectors 0)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-normal-p world-sector)) (incf residential-sectors))))) (if (and (> residential-sectors 0) (zerop (world/cur-military-num world))) t nil)) ) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world))) (residential-sector-list ()) (selected-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-normal-p world-sector)) (push (list x y) residential-sector-list))))) (setf selected-sector (nth (random (length residential-sector-list)) residential-sector-list)) (setf (controlled-by (aref (cells (world-map world)) (first selected-sector) (second selected-sector))) +lm-controlled-by-military+) (add-message (format nil "The military have drafted ") sdl:*white* message-box-list) (add-message (format nil "a new army") sdl:*yellow* message-box-list) (add-message (format nil " in ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name (aref (cells (world-map world)) (first selected-sector) (second selected-sector)))) sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) ) (set-campaign-command :id :campaign-command-military-add-army :name-func #'(lambda (world) (declare (ignore world)) "Call for a new army") :descr-func #'(lambda (world) (declare (ignore world)) "Reinforce the military with an additional army deployed in one of the inhabited districts.") :faction-type +faction-type-military+ :disabled nil :cd 7 :priority 2 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((residential-sectors 0) (demon-win-cond (get-win-condition-by-id :win-cond-demon-campaign)) (military-win-cond (get-win-condition-by-id :win-cond-military-campaign)) (normal-sectors-left (funcall (win-condition/win-func demon-win-cond) *world* demon-win-cond))) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-normal-p world-sector)) (incf residential-sectors))))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) *world* military-win-cond) (declare (ignore satanist-lairs-left)) (if (and (> residential-sectors 0) (not (zerop (world/cur-military-num world))) (> corrupted-sectors-left normal-sectors-left)) t nil)))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world))) (residential-sector-list ()) (selected-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-normal-p world-sector)) (push (list x y) residential-sector-list))))) (setf selected-sector (nth (random (length residential-sector-list)) residential-sector-list)) (setf (controlled-by (aref (cells (world-map world)) (first selected-sector) (second selected-sector))) +lm-controlled-by-military+) (add-message (format nil "The military have deployed ") sdl:*white* message-box-list) (add-message (format nil "a new army") sdl:*yellow* message-box-list) (add-message (format nil " in ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name (aref (cells (world-map world)) (first selected-sector) (second selected-sector)))) sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)))) (set-campaign-command :id :campaign-command-priest-delay-demons :name-func #'(lambda (world) (declare (ignore world)) "Pray to thicken the Barrier") :descr-func #'(lambda (world) (declare (ignore world)) "Pray to make the Barrier between the Hell and human world thicker for 5 turns. This shall make demons arrive 30 turns later when they arrive delayed.") :faction-type +faction-type-church+ :disabled nil :cd 6 :priority 0 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((church-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (world-sector-normal-p world-sector)) (setf church-sector t))))) (if (and church-sector (null (find-campaign-effects-by-id world :campaign-effect-demon-delayed))) t nil))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-demon-delayed :cd 5))) (set-campaign-command :id :campaign-command-priest-hasten-angels :name-func #'(lambda (world) (declare (ignore world)) "Pray for divine intervention") :descr-func #'(lambda (world) (declare (ignore world)) "Pray to make angels arrive 30 turns earlier when the they arrive delayed. This effect lasts for 5 turns.") :faction-type +faction-type-church+ :disabled nil :cd 6 :priority 0 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((church-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (world-sector-normal-p world-sector)) (setf church-sector t))))) (if (and church-sector (null (find-campaign-effects-by-id world :campaign-effect-angel-hastened))) t nil))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-angel-hastened :cd 5))) (set-campaign-command :id :campaign-command-eater-agitated :name-func #'(lambda (world) (declare (ignore world)) "Awaken Primordials") :descr-func #'(lambda (world) (declare (ignore world)) "Awaken Primordials to make the more present during missions.") :faction-type +faction-type-military+ :disabled nil :cd 9 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let* ((normal-sectors 0) (corrupted-sectors 0) (abandoned-sectors 0)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (world-sector-normal-p world-sector) (incf normal-sectors)) (when (world-sector-abandoned-p world-sector) (incf abandoned-sectors)) (when (world-sector-corrupted-p world-sector) (incf corrupted-sectors))))) (if (and (>= abandoned-sectors (+ corrupted-sectors normal-sectors)) (not (find-campaign-effects-by-id world :campaign-effect-eater-agitated))) t nil))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-eater-agitated :cd 5))) (set-campaign-command :id :campaign-command-angel-reveal-lair :name-func #'(lambda (world) (declare (ignore world)) "Reveal a satanists' lair") :descr-func #'(lambda (world) (declare (ignore world)) "Shed divine light to allow humans instantly reveal the satanists' lair and make it vulnerable for attack.") :faction-type +faction-type-angels+ :disabled nil :cd 7 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((military-win-cond (get-win-condition-by-id :win-cond-military-campaign)) (relic-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-item-holy-relic+ (items world-sector)) (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (world-sector-normal-p world-sector)) (setf relic-sector t))))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func military-win-cond) world military-win-cond) (declare (ignore corrupted-sectors-left)) (if (and relic-sector (not (zerop satanist-lairs-left)) (not (find-campaign-effects-by-id world :campaign-effect-satanist-lair-visible)) (< (world/random-number world) 15)) t nil)))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((message-box-list `(,(world/event-message-box world)))) (add-message (format nil "Angels have ") sdl:*white* message-box-list) (add-message (format nil "revealed") sdl:*yellow* message-box-list) (add-message (format nil " the place where the ") sdl:*white* message-box-list) (add-message (format nil "satanists") sdl:*yellow* message-box-list) (add-message (format nil "hide.~%") sdl:*white* message-box-list)) (add-campaign-effect world :id :campaign-effect-satanist-lair-visible :cd 5) (loop for campaign-effect in (find-campaign-effects-by-id world :campaign-effect-satanist-lair-hidden) do (remove-campaign-effect world campaign-effect)) )) (set-campaign-command :id :campaign-command-angel-divine-crusade :name-func #'(lambda (world) (declare (ignore world)) "Declare divine crusade") :descr-func #'(lambda (world) (declare (ignore world)) "Declare divine crusade to be able to initiate 1 more mission for 5 turns.") :faction-type +faction-type-angels+ :disabled nil :cd 9 :priority 1 :on-check-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (let ((relic-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-item-holy-relic+ (items world-sector)) (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (world-sector-normal-p world-sector)) (setf relic-sector t))))) (if (and relic-sector (not (find-campaign-effects-by-id world :campaign-effect-angel-crusade)) (> (world/random-number world) 85)) t nil))) :on-trigger-start-func #'(lambda (world campaign-command) (declare (ignore campaign-command)) (add-campaign-effect world :id :campaign-effect-angel-crusade :cd 5) ))
46,727
Common Lisp
.lisp
571
41.082312
208
0.392376
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ff9fa1f452b788285570b8c9b3e66eaeb54efa313e299028fa9f274b6734b3a2
2,841
[ -1 ]
2,842
globals.lisp
gwathlobal_CotD/src/globals.lisp
(in-package :cotd) (declaim (type fixnum *max-x-level* *max-y-level*)) (declaim (ftype (function (fixnum fixnum fixnum fixnum) single-float) get-distance)) (defvar *time-at-end-of-player-turn* 0) (defparameter *max-x-level* 100) (defparameter *max-y-level* 100) (defparameter *max-z-level* 9) (defparameter *max-x-view* 25) (defparameter *max-y-view* 25) (defvar *options*) (defvar *highscores*) ;; most likely I am doing it wrong but I need a sequence of letters in alphabetical order (defvar *char-list* (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z")) (defparameter *init-angel-names* (list "Barachiel" "Jegudiel" "Muriel" "Pahaliah" "Selaphiel" "Zachariel" "Adriel" "Ambriel" "Camael" "Cassiel" "Daniel" "Eremiel" "Hadraniel" "Haniel" "Hesediel" "Jehoel" "Jerahmeel" "Jophiel" "Kushiel" "Leliel" "Metatron" "Nanael" "Nithael" "Netzach" "Ophaniel" "Puriel" "Qaphsiel" "Raziel" "Remiel" "Rikbiel" "Sachiel" "Samael" "Sandalphon" "Seraphiel" "Shamsiel" "Tzaphqiel" "Uriel" "Uzziel" "Vehuel" "Zophiel" "Azazel" "Azrael" "Sariel" "Gabriel" "Raphael" "Michael")) (defparameter *init-demon-names* (list "Amon" "Abaddon" "Agares" "Haborym" "Alastor" "Allocer" "Amaymon" "Amdusias" "Andras" "Amdusias" "Andromalius" "Anzu" "Asmodeus" "Astaroth" "Bael" "Balam" "Barbatos" "Bathin" "Beelzebub" "Behemoth" "Beleth" "Belial" "Belthegor" "Berith" "Bifrons" "Botis" "Buer" "Cacus" "Cerberus" "Mastema" "Melchiresus" "Moloch" "Onoskelis" "Shedim" "Xaphan" "Ornias" "Mammon" "Lix Tetrax" "Nybbas" "Focalor" "Furfur" "Gaap" "Geryon" "Haures" "Ipos" "Jezebeth" "Kasdeya" "Kobal" "Malphas" "Melchom" "Mullin" "Naberius" "Nergal" "Nicor" "Nysrogh" "Oriax" "Paymon" "Philatnus" "Pruflas" "Raum" "Rimmon" "Ronove" "Ronwe" "Shax" "Shalbriri" "Sonellion" "Stolas" "Succorbenoth" "Thamuz" "Ukobach" "Uphir" "Uvall" "Valafar" "Vepar" "Verdelet" "Verin" "Xaphan" "Zagan" "Zepar" "Ioz" "Zohadam" "Hardaz")) (defparameter *init-human-names* (list "Afanasiy" "Andrey" "Boris" "Ivan" "Dmitry" "Alexey" "Nicolay" "Alexander" "Pyotr" "Pavel" "Vladimir" "Mikhail" "Fyodor" "Gavriil" "Vasiliy" "Denis" "Konstantin" "Sergey" "Vladislav" "Victor" "Vsevolod" "Grigoriy" "Daniil")) (defparameter *init-human-surnames* (list "Grekov" "Plotnikov" "Strakhov" "Verkhovenskiy" "Shatov" "Stavrogin" "Kirillov" "Tushin" "Lebyadkin" "Liputin" "Virginskiy" "Lyamshin" "Tolkachenko" "Shigalev" "Karmazinov" "Nechayev" "Lebedev" "Rogozhin" "Ivolgin" "Epanchin" "Ferdishchenko" "Totskiy" "Myshkin" "Pavlishchev" "Burdovskiy" "Radomskiy" "Molovtsov" "Terentyev" "Ptitsin" "Zhadov" "Zhuravishkin")) (defparameter *cur-demon-names* nil) (defparameter *cur-angel-names* nil) (defparameter *cur-human-names* nil) (defparameter *cur-human-surnames* nil) (defparameter *max-player-name-length* 20) (defconstant +noun-proper+ 0) (defconstant +noun-common+ 1) (defconstant +noun-plural+ 2) (defconstant +noun-singular+ 3) (defconstant +article-none+ 0) (defconstant +article-a+ 1) (defconstant +article-the+ 2) (defparameter *scenario-hints* (list (format nil "In the beginning, there was Nothing. Then from Nothing came Something and it was the One, the Unborn, the Creator.") (format nil "Those whom we call demons were the first to be created. They call themselves the Firstborn and take great pride in their primacy.") (format nil "The Creator was not satisfied with Its first creation for the Firstborn were a mass of multiplying mingling flesh lacking any divine spark. So, the Creator confined them into a Prison Dimension as they were a disgrace to Its will.") (format nil "The humankind was created the second. They were given flesh as their shell and a soul as their core. But the flesh corrupted the Secondborn nonetheless and they forgot their origin.") (format nil "The Creator gave the Secondborn a world of their own and let them be. From time to time, it sent spoke to some of the humankind so that they did not go astray. Those humans were declared Prophets by their brethren.") (format nil "The Creator installed the Font from where a human soul comes when a human is born and where it returns to when a human dies. The number of souls is finite but they are infinitely divisible. Yet as humans multiplied, their divine spark wore thinner and thinner in them.") (format nil "Those Secondborn souls that were not blemished by sinful flesh during their mortal life remain in the Font free from any corrupting action. The souls stained by sin are torn and reforged to feed the demand of the ever-spawning humanity in new souls.") (format nil "The One takes great pity in humans for they are the Secondborn and possess the divine spark. Yet their fleshly shells make them akin to demons who were imprisoned in Hell for their misguided ways.") (format nil "We are the Thirdborn, the pinnacle of creation, the ultimate design of the One. We reject the malign flesh and exist as pure spirits. Our numbers are constant and our self can never be reduced.") (format nil "We, the Thirdborn, are the host of the Creator and allowed into Its inner circle. We serve as guards of the Prison Dimension and Its personal messengers. The One confides Its secrets in us and we are granted the privilege to speak to It orderly."))) ;;-------------------- ;; MOB-TEMPLATE Constants ;;-------------------- (defconstant +base-accuracy+ 100) (defconstant +mob-type-player+ 0) (defconstant +mob-type-human+ 1) (defconstant +mob-type-angel+ 2) (defconstant +mob-type-demon+ 3) (defconstant +mob-type-archangel+ 4) (defconstant +mob-type-imp+ 5) (defconstant +mob-type-archdemon+ 6) (defconstant +mob-type-man+ 7) (defconstant +mob-type-woman+ 8) (defconstant +mob-type-child+ 9) (defconstant +mob-type-clerk+ 10) (defconstant +mob-type-criminal+ 11) (defconstant +mob-type-policeman+ 12) (defconstant +mob-type-priest+ 13) (defconstant +mob-type-satanist+ 14) (defconstant +mob-type-soldier+ 15) (defconstant +mob-type-sergeant+ 16) (defconstant +mob-type-chaplain+ 17) (defconstant +mob-type-gunner+ 18) (defconstant +mob-type-horse+ 19) (defconstant +mob-type-fiend+ 20) (defconstant +mob-type-scout+ 21) (defconstant +mob-type-gargantaur+ 22) (defconstant +mob-type-thief+ 23) (defconstant +mob-type-reanimated-pwr-1+ 24) (defconstant +mob-type-reanimated-pwr-2+ 25) (defconstant +mob-type-reanimated-pwr-3+ 26) (defconstant +mob-type-reanimated-pwr-4+ 27) (defconstant +mob-type-reanimated-empowered+ 28) (defconstant +mob-type-wisp+ 29) (defconstant +mob-type-shadow-imp+ 30) (defconstant +mob-type-shadow-demon+ 31) (defconstant +mob-type-shadow-devil+ 32) (defconstant +mob-type-star-singer+ 33) (defconstant +mob-type-star-gazer+ 34) (defconstant +mob-type-star-mender+ 35) (defconstant +mob-type-star-singer-mender+ 36) (defconstant +mob-type-star-singer-gazer+ 37) (defconstant +mob-type-star-gazer-mender+ 38) (defconstant +mob-type-star-singer-gazer-mender+ 39) (defconstant +mob-type-angel-image+ 40) (defconstant +mob-type-eater-of-the-dead+ 41) (defconstant +mob-type-malseraph-puppet+ 42) (defconstant +mob-type-sheep+ 43) (defconstant +mob-type-locust+ 44) (defconstant +mob-type-scarab+ 45) (defconstant +mob-type-acid-locust+ 46) (defconstant +mob-type-fast-scarab+ 47) (defconstant +mob-type-seeker-larva+ 48) (defconstant +mob-type-spore-colony+ 49) (defconstant +mob-type-ghost+ 50) (defconstant +mob-type-tree+ 51) (defconstant +mob-type-satanist-empowered+ 52) (defconstant +mob-type-demon-sigil+ 53) (defconstant +mob-type-skinchanger-melee+ 54) (defconstant +mob-type-skinchanger-ranged+ 55) (defconstant +mob-type-skinchanger-flyer+ 56) (defconstant +mob-type-skinchanger-turret+ 57) (defconstant +mob-type-demon-machine+ 58) (defconstant +mob-type-military-bomb-1+ 59) (defconstant +mob-type-military-bomb-2+ 60) (defconstant +mob-type-military-bomb-3+ 61) (defconstant +faction-type-none+ 0) (defconstant +faction-type-civilians+ 1) (defconstant +faction-type-angels+ 2) (defconstant +faction-type-demons+ 3) (defconstant +faction-type-military+ 4) (defconstant +faction-type-animals+ 5) (defconstant +faction-type-outsider-beasts+ 6) (defconstant +faction-type-criminals+ 7) (defconstant +faction-type-outsider-wisps+ 8) (defconstant +faction-type-eater+ 9) (defconstant +faction-type-ghost+ 10) (defconstant +faction-type-satanists+ 11) (defconstant +faction-type-church+ 12) (defconstant +specific-faction-type-dead-player+ -3) (defconstant +specific-faction-type-test+ -2) (defconstant +specific-faction-type-player+ -1) (defconstant +specific-faction-type-angel-chrome+ 0) (defconstant +specific-faction-type-angel-trinity+ 1) (defconstant +specific-faction-type-demon-crimson+ 2) (defconstant +specific-faction-type-demon-shadow+ 3) (defconstant +specific-faction-type-demon-malseraph+ 4) (defconstant +specific-faction-type-military-chaplain+ 5) (defconstant +specific-faction-type-military-scout+ 6) (defconstant +specific-faction-type-thief+ 7) (defconstant +specific-faction-type-satanist+ 8) (defconstant +specific-faction-type-priest+ 9) (defconstant +specific-faction-type-eater+ 10) (defconstant +specific-faction-type-ghost+ 11) (defconstant +specific-faction-type-skinchanger+ 12) (defconstant +ai-package-coward+ 0) (defconstant +ai-package-horde+ 1) (defconstant +ai-package-wants-bless+ 2) (defconstant +ai-package-takes-valuable-items+ 3) (defconstant +ai-package-curious+ 4) (defconstant +ai-package-kleptomaniac+ 5) (defconstant +ai-package-cautious+ 6) (defconstant +ai-package-trinity-mimic+ 7) (defconstant +ai-package-split-soul+ 8) (defconstant +ai-package-search-corpses+ 9) (defconstant +ai-package-use-ability+ 10) (defconstant +ai-package-use-item+ 11) (defconstant +ai-package-reload-ranged-weapon+ 12) (defconstant +ai-package-shoot-enemy+ 13) (defconstant +ai-package-follow-leader+ 14) (defconstant +ai-package-approach-target+ 15) (defconstant +ai-package-attack-nearest-enemy+ 16) (defconstant +ai-package-find-random-location+ 17) (defconstant +ai-package-patrol-district+ 18) (defconstant +ai-package-avoid-possession+ 19) (defconstant +ai-package-avoid-melee+ 20) (defconstant +ai-package-pick-corpses+ 21) (defconstant +ai-package-return-corpses-to-portal+ 22) (defconstant +ai-package-search-relic+ 23) (defconstant +ai-package-pick-relic+ 24) (defconstant +ai-package-return-relic-to-portal+ 25) (defconstant +ai-package-find-sigil+ 26) (defconstant +ai-package-escape-with-relic+ 27) (defconstant +ai-package-swim-up+ 28) (defconstant +ai-package-find-machine+ 29) (defconstant +ai-package-find-bomb-plant-location+ 30) (defconstant +ai-priority-never+ 0) (defconstant +ai-priority-always+ 10) (defconstant +mob-abil-heal-self+ 0) (defconstant +mob-abil-conceal-divine+ 1) (defconstant +mob-abil-reveal-divine+ 2) (defconstant +mob-abil-detect-good+ 3) (defconstant +mob-abil-detect-evil+ 4) (defconstant +mob-abil-possessable+ 5) (defconstant +mob-abil-can-possess+ 6) (defconstant +mob-abil-purging-touch+ 7) (defconstant +mob-abil-blessing-touch+ 8) (defconstant +mob-abil-can-be-blessed+ 9) (defconstant +mob-abil-unholy+ 10) (defconstant +mob-abil-angel+ 11) (defconstant +mob-abil-demon+ 12) (defconstant +mob-abil-human+ 13) (defconstant +mob-abil-see-all+ 14) (defconstant +mob-abil-lifesteal+ 15) (defconstant +mob-abil-call-for-help+ 16) (defconstant +mob-abil-answer-the-call+ 17) (defconstant +mob-abil-loves-infighting+ 18) (defconstant +mob-abil-prayer-bless+ 19) (defconstant +mob-abil-free-call+ 20) (defconstant +mob-abil-prayer-shield+ 21) (defconstant +mob-abil-curse+ 22) (defconstant +mob-abil-keen-senses+ 23) (defconstant +mob-abil-prayer-reveal+ 24) (defconstant +mob-abil-military-follow-me+ 25) (defconstant +mob-abil-blindness+ 26) (defconstant +mob-abil-instill-fear+ 27) (defconstant +mob-abil-charge+ 28) (defconstant +mob-abil-momentum+ 29) (defconstant +mob-abil-animal+ 30) (defconstant +mob-abil-horseback-riding+ 31) (defconstant +mob-abil-horse-can-be-ridden+ 32) (defconstant +mob-abil-dismount+ 33) (defconstant +mob-abil-dominate-fiend+ 34) (defconstant +mob-abil-fiend-can-be-ridden+ 35) (defconstant +mob-abil-starts-with-horse+ 36) (defconstant +mob-abil-independent+ 37) (defconstant +mob-abil-eagle-eye+ 38) (defconstant +mob-abil-facing+ 39) (defconstant +mob-abil-immovable+ 40) (defconstant +mob-abil-mind-burn+ 41) (defconstant +mob-abil-gargantaur-teleport+ 42) (defconstant +mob-abil-dominate-gargantaur+ 43) (defconstant +mob-abil-gargantaurs-mind-burn+ 44) (defconstant +mob-abil-death-from-above+ 45) (defconstant +mob-abil-climbing+ 46) (defconstant +mob-abil-no-breathe+ 47) (defconstant +mob-abil-open-close-door+ 48) (defconstant +mob-abil-toggle-light+ 49) (defconstant +mob-abil-open-close-window+ 50) (defconstant +mob-abil-can-possess-toggle+ 51) (defconstant +mob-abil-sacrifice-host+ 52) (defconstant +mob-abil-reanimate-corpse+ 53) (defconstant +mob-abil-undead+ 54) (defconstant +mob-abil-shared-minds+ 55) (defconstant +mob-abil-empower-undead+ 56) (defconstant +mob-abil-ignite-the-fire+ 57) (defconstant +mob-abil-avatar-of-brilliance+ 58) (defconstant +mob-abil-gravity-chains+ 59) (defconstant +mob-abil-flying+ 60) (defconstant +mob-abil-no-corpse+ 61) (defconstant +mob-abil-smite+ 62) (defconstant +mob-abil-slow+ 63) (defconstant +mob-abil-prayer-wrath+ 64) (defconstant +mob-abil-shadow-step+ 65) (defconstant +mob-abil-extinguish-light+ 66) (defconstant +mob-abil-umbral-aura+ 67) (defconstant +mob-abil-trinity-mimic+ 68) (defconstant +mob-abil-merge+ 69) (defconstant +mob-abil-unmerge+ 70) (defconstant +mob-abil-heal-other+ 71) (defconstant +mob-abil-righteous-fury+ 72) (defconstant +mob-abil-pain-link+ 73) (defconstant +mob-abil-soul-reinforcement+ 74) (defconstant +mob-abil-silence+ 75) (defconstant +mob-abil-confuse+ 76) (defconstant +mob-abil-split-soul+ 77) (defconstant +mob-abil-restore-soul+ 78) (defconstant +mob-abil-resurrection+ 79) (defconstant +mob-abil-sprint+ 80) (defconstant +mob-abil-jump+ 81) (defconstant +mob-abil-bend-space+ 82) (defconstant +mob-abil-cast-shadow+ 83) (defconstant +mob-abil-cannibalize+ 84) (defconstant +mob-abil-primordial+ 85) (defconstant +mob-abil-make-disguise+ 86) (defconstant +mob-abil-remove-disguise+ 87) (defconstant +mob-abil-constriction+ 88) (defconstant +mob-abil-irradiate+ 89) (defconstant +mob-abil-fission+ 90) (defconstant +mob-abil-adrenal-gland+ 91) (defconstant +mob-abil-mutate-acid-spit+ 92) (defconstant +mob-abil-mutate-corroding-secretion+ 93) (defconstant +mob-abil-acid-spit+ 94) (defconstant +mob-abil-corroding-secretion+ 95) (defconstant +mob-abil-mutate-corrosive-bile+ 96) (defconstant +mob-abil-mutate-accurate-bile+ 97) (defconstant +mob-abil-corrosive-bile+ 98) (defconstant +mob-abil-accurate-bile+ 99) (defconstant +mob-abil-mutate-clawed-tentacle+ 100) (defconstant +mob-abil-mutate-piercing-needles+ 101) (defconstant +mob-abil-clawed-tentacle+ 102) (defconstant +mob-abil-piercing-needles+ 103) (defconstant +mob-abil-mutate-chitinous-plating+ 104) (defconstant +mob-abil-mutate-thick-carapace+ 105) (defconstant +mob-abil-chitinous-plating+ 106) (defconstant +mob-abil-thick-carapace+ 107) (defconstant +mob-abil-mutate-metabolic-boost+ 108) (defconstant +mob-abil-mutate-jump+ 109) (defconstant +mob-abil-metabolic-boost+ 110) (defconstant +mob-abil-mutate-retracting-spines+ 111) (defconstant +mob-abil-mutate-acidic-tips+ 112) (defconstant +mob-abil-retracting-spines+ 113) (defconstant +mob-abil-acidic-tips+ 114) (defconstant +mob-abil-mutate-ovipositor+ 115) (defconstant +mob-abil-oviposit+ 116) (defconstant +mob-abil-create-parasites+ 117) (defconstant +mob-abil-mutate-spawn-locusts+ 118) (defconstant +mob-abil-spawn-locusts+ 119) (defconstant +mob-abil-mutate-spawn-scarabs+ 120) (defconstant +mob-abil-spawn-scarabs+ 121) (defconstant +mob-abil-acid-explosion+ 122) (defconstant +mob-abil-mutate-acid-locusts+ 123) (defconstant +mob-abil-mutate-fast-scarabs+ 124) (defconstant +mob-abil-mutate-oviposit-more-eggs+ 125) (defconstant +mob-abil-mutate-tougher-locusts+ 126) (defconstant +mob-abil-oviposit-more-eggs+ 127) (defconstant +mob-abil-tougher-locusts+ 128) (defconstant +mob-abil-acid-locusts+ 129) (defconstant +mob-abil-fast-scarabs+ 130) (defconstant +mob-abil-regenerate+ 131) (defconstant +mob-abil-casts-light+ 132) (defconstant +mob-abil-vulnerable-to-vorpal+ 133) (defconstant +mob-abil-vulnerable-to-fire+ 134) (defconstant +mob-abil-cure-mutation+ 135) (defconstant +mob-abil-mutate-hooks-and-suckers+ 136) (defconstant +mob-abil-mutate-disguise-as-human+ 137) (defconstant +mob-abil-disguise-as-human+ 138) (defconstant +mob-abil-mutate-spawn-larva+ 139) (defconstant +mob-abil-spawn-larva+ 140) (defconstant +mob-abil-mutate-spore-colony+ 141) (defconstant +mob-abil-spore-colony+ 142) (defconstant +mob-abil-immobile+ 143) (defconstant +mob-abil-float+ 144) (defconstant +mob-abil-ghost-possess+ 145) (defconstant +mob-abil-invisibility+ 146) (defconstant +mob-abil-passwall+ 147) (defconstant +mob-abil-ghost-release+ 148) (defconstant +mob-abil-decipher-rune+ 149) (defconstant +mob-abil-demon-word-flesh+ 150) (defconstant +mob-abil-demon-word-knockback+ 151) (defconstant +mob-abil-demon-word-invasion+ 152) (defconstant +mob-abil-demon-word-darkness+ 153) (defconstant +mob-abil-demon-word-plague+ 154) (defconstant +mob-abil-demon-word-power+ 155) (defconstant +mob-abil-soul+ 156) (defconstant +mob-abil-detect-unnatural+ 157) (defconstant +mob-abil-throw-corpse-into-portal+ 158) (defconstant +mob-abil-throw-relic-into-portal+ 159) (defconstant +mob-abil-create-demon-sigil+ 160) (defconstant +mob-abil-skinchange-to-melee+ 161) (defconstant +mob-abil-skinchange-to-ranged+ 162) (defconstant +mob-abil-skinchange-to-flyer+ 163) (defconstant +mob-abil-mutate-skin-ranged-to-turret+ 164) (defconstant +mob-abil-skinchange-to-turret+ 165) (defconstant +mob-abil-mutate-charge+ 166) (defconstant +mob-abil-mutate-explosive-glands+ 167) (defconstant +mob-abil-explosive-glands+ 168) (defconstant +mob-abil-mutate-poisoning-glands+ 169) (defconstant +mob-abil-poisoning-glands+ 170) (defconstant +mob-abil-purge-rune+ 171) (defconstant +mob-abil-civilian+ 172) (defconstant +mob-abil-deep-breath+ 173) (defconstant +mob-abil-nameless+ 174) (defconstant +mob-abil-strength-in-numbers+ 175) (defconstant +mob-abil-coward+ 176) (defconstant +mob-effect-possessed+ 0) (defconstant +mob-effect-blessed+ 1) (defconstant +mob-effect-reveal-true-form+ 2) (defconstant +mob-effect-divine-concealed+ 3) (defconstant +mob-effect-calling-for-help+ 4) (defconstant +mob-effect-called-for-help+ 5) (defconstant +mob-effect-divine-shield+ 6) (defconstant +mob-effect-cursed+ 7) (defconstant +mob-effect-blind+ 8) (defconstant +mob-effect-fear+ 9) (defconstant +mob-effect-climbing-mode+ 10) (defconstant +mob-effect-alertness+ 11) (defconstant +mob-effect-ready-to-possess+ 12) (defconstant +mob-effect-avatar-of-brilliance+ 13) (defconstant +mob-effect-empowered-undead+ 14) (defconstant +mob-effect-necrolink+ 15) (defconstant +mob-effect-gravity-pull+ 16) (defconstant +mob-effect-flying+ 17) (defconstant +mob-effect-slow+ 18) (defconstant +mob-effect-holy-touch+ 19) (defconstant +mob-effect-extinguished-light+ 20) (defconstant +mob-effect-merged+ 21) (defconstant +mob-effect-righteous-fury+ 22) (defconstant +mob-effect-wet+ 23) (defconstant +mob-effect-pain-link-source+ 24) (defconstant +mob-effect-pain-link-target+ 25) (defconstant +mob-effect-soul-reinforcement+ 26) (defconstant +mob-effect-silence+ 27) (defconstant +mob-effect-confuse+ 28) (defconstant +mob-effect-split-soul-source+ 29) (defconstant +mob-effect-split-soul-target+ 30) (defconstant +mob-effect-sprint+ 31) (defconstant +mob-effect-exerted+ 32) (defconstant +mob-effect-casting-shadow+ 33) (defconstant +mob-effect-disguised+ 34) (defconstant +mob-effect-constriction-source+ 35) (defconstant +mob-effect-constriction-target+ 36) (defconstant +mob-effect-irradiated+ 37) (defconstant +mob-effect-polymorph-sheep+ 38) (defconstant +mob-effect-glowing+ 39) (defconstant +mob-effect-parasite+ 40) (defconstant +mob-effect-evolving+ 41) (defconstant +mob-effect-adrenaline+ 42) (defconstant +mob-effect-metabolic-boost+ 43) (defconstant +mob-effect-spines+ 44) (defconstant +mob-effect-mortality+ 45) (defconstant +mob-effect-laying-eggs+ 46) (defconstant +mob-effect-regenerate+ 47) (defconstant +mob-effect-corroded+ 48) (defconstant +mob-effect-primordial-transfer+ 49) (defconstant +mob-effect-rest-in-peace+ 50) (defconstant +mob-effect-polymorph-tree+ 51) (defconstant +mob-effect-life-guard+ 52) (defconstant +mob-effect-invisibility+ 53) (defconstant +mob-effect-soul-sickness+ 54) (defconstant +mob-effect-demonic-power+ 55) (defconstant +mob-effect-demonic-sigil+ 56) (defconstant +mob-effect-deep-breath+ 57) (defconstant +mob-effect-demonic-machine+ 58) (defconstant +mob-effect-bomb-ticking+ 59) (defconstant +mob-effect-reduce-resitances+ 60) (defconstant +mob-effect-strength-in-numbers+ 61) (defconstant +mob-order-follow+ 0) (defconstant +mob-order-target+ 1) (defconstant +weapon-dmg-flesh+ 0) (defconstant +weapon-dmg-iron+ 1) (defconstant +weapon-dmg-fire+ 2) (defconstant +weapon-dmg-vorpal+ 3) (defconstant +weapon-dmg-mind+ 4) (defconstant +weapon-dmg-radiation+ 5) (defconstant +weapon-dmg-acid+ 6) ;;-------------------- ;; ITEM-TYPE Constants ;;-------------------- (defconstant +item-abil-corpse+ 0) (defconstant +item-abil-card+ 1) (defconstant +item-type-body-part-limb+ 0) (defconstant +item-type-body-part-half+ 1) (defconstant +item-type-body-part-body+ 2) (defconstant +item-type-body-part-full+ 3) (defconstant +item-type-coin+ 4) (defconstant +item-type-medkit+ 5) (defconstant +item-type-smoke-bomb+ 6) (defconstant +item-type-clothing+ 7) (defconstant +item-type-disguise+ 8) (defconstant +item-type-deck-of-war+ 9) (defconstant +item-type-deck-of-escape+ 10) (defconstant +item-type-eater-parasite+ 11) (defconstant +item-type-signal-flare+ 12) (defconstant +item-type-eater-scarab-egg+ 13) (defconstant +item-type-eater-locust-egg+ 14) (defconstant +item-type-eater-larva-egg+ 15) (defconstant +item-type-eater-colony-egg+ 16) (defconstant +item-type-book-of-rituals+ 17) (defconstant +item-type-scroll-demonic-rune-flesh+ 18) (defconstant +item-type-scroll-demonic-rune-invite+ 19) (defconstant +item-type-scroll-demonic-rune-away+ 20) (defconstant +item-type-scroll-demonic-rune-transform+ 21) (defconstant +item-type-scroll-demonic-rune-barrier+ 22) (defconstant +item-type-scroll-demonic-rune-all+ 23) (defconstant +item-type-scroll-demonic-rune-decay+ 24) (defconstant +item-type-church-reli—Å+ 25) (defconstant +item-type-bomb+ 26) ;;-------------------- ;; FEATURE-TYPE Constants ;;-------------------- (defconstant +feature-trait-blocks-vision+ 0) (defconstant +feature-trait-smoke+ 1) (defconstant +feature-trait-no-gravity+ 2) (defconstant +feature-trait-fire+ 3) (defconstant +feature-trait-remove-on-dungeon-generation+ 4) (defconstant +feature-trait-demonic-rune+ 5) (defconstant +feature-blood-fresh+ 0) (defconstant +feature-blood-old+ 1) (defconstant +feature-blood-stain+ 2) (defconstant +feature-start-satanist-player+ 3) (defconstant +feature-smoke-thin+ 4) (defconstant +feature-smoke-thick+ 5) (defconstant +feature-fire+ 6) (defconstant +feature-start-gold-small+ 7) (defconstant +feature-start-gold-big+ 8) (defconstant +feature-start-church-player+ 9) (defconstant +feature-start-repel-demons+ 10) (defconstant +feature-smoke-flare+ 11) (defconstant +feature-smoke-flare-final+ 12) (defconstant +feature-corrosive-bile-target+ 13) (defconstant +feature-sacrificial-circle+ 14) (defconstant +feature-demonic-rune-flesh+ 15) (defconstant +feature-demonic-rune-invite+ 16) (defconstant +feature-demonic-rune-away+ 17) (defconstant +feature-demonic-rune-transform+ 18) (defconstant +feature-demonic-rune-barrier+ 19) (defconstant +feature-demonic-rune-all+ 20) (defconstant +feature-demonic-rune-decay+ 21) (defconstant +feature-demonic-portal+ 22) (defconstant +feature-start-place-relic+ 23) (defconstant +feature-start-strong-repel-demons+ 24) (defconstant +feature-start-sigil-point+ 25) (defconstant +feature-corrupted-spores+ 26) (defconstant +feature-smoke-acid-gas+ 27) (defconstant +feature-start-place-church-priest+ 28) (defconstant +feature-start-place-civilian-man+ 29) (defconstant +feature-start-place-civilian-woman+ 30) (defconstant +feature-start-place-civilian-child+ 31) (defconstant +feature-start-place-book-of-rituals+ 32) (defconstant +feature-arrival-point-north+ 33) (defconstant +feature-arrival-point-south+ 34) (defconstant +feature-arrival-point-west+ 35) (defconstant +feature-arrival-point-east+ 36) (defconstant +feature-start-place-demons+ 37) (defconstant +feature-start-place-angels+ 38) (defconstant +feature-start-place-military+ 39) (defconstant +feature-delayed-demons-arrival-point+ 40) (defconstant +feature-delayed-angels-arrival-point+ 41) (defconstant +feature-delayed-military-arrival-point+ 42) (defconstant +feature-start-machine-point+ 43) (defconstant +feature-bomb-plant-target+ 44) (defconstant +feature-smoke-weak-acid-gas+ 45) (defconstant +feature-divine-portal+ 46) ;;-------------------- ;; TERRAIN-TEMPLATE Constants ;;-------------------- (defconstant +level-city-park+ 0) (defconstant +level-city-terrain-border+ 1) (defconstant +level-city-terrain-dirt+ 2) (defconstant +level-city-terrain-grass+ 3) (defconstant +level-city-terrain-tree+ 4) (defconstant +level-city-terrain-bush+ 5) (defconstant +level-city-terrain-earth+ 6) (defconstant +terrain-trait-blocks-move+ 0) (defconstant +terrain-trait-blocks-vision+ 1) (defconstant +terrain-trait-blocks-projectiles+ 2) (defconstant +terrain-trait-blocks-move-floor+ 3) (defconstant +terrain-trait-slope-up+ 4) (defconstant +terrain-trait-slope-down+ 5) (defconstant +terrain-trait-not-climable+ 6) (defconstant +terrain-trait-light-source+ 7) (defconstant +terrain-trait-blocks-sound+ 8) (defconstant +terrain-trait-blocks-sound-floor+ 9) (defconstant +terrain-trait-water+ 10) (defconstant +terrain-trait-move-cost-factor+ 11) (defconstant +terrain-trait-openable-door+ 12) (defconstant +terrain-trait-openable-window+ 13) (defconstant +terrain-trait-flammable+ 14) (defconstant +terrain-trait-can-jump-over+ 15) (defconstant +terrain-trait-can-have-rune+ 16) (defconstant +terrain-trait-can-switch-light+ 17) (defconstant +terrain-trait-blocks-projectiles-floor+ 18) (defconstant +terrain-trait-blocks-vision-floor+ 19) (defconstant +terrain-border-floor+ 0) (defconstant +terrain-floor-stone+ 1) (defconstant +terrain-wall-stone+ 2) (defconstant +terrain-tree-birch+ 3) (defconstant +terrain-floor-grass+ 4) (defconstant +terrain-water-liquid+ 5) (defconstant +terrain-floor-dirt+ 6) (defconstant +terrain-wall-window+ 7) (defconstant +terrain-floor-dirt-bright+ 8) (defconstant +terrain-floor-chair+ 9) (defconstant +terrain-floor-table+ 10) (defconstant +terrain-floor-bed+ 11) (defconstant +terrain-floor-cabinet+ 12) (defconstant +terrain-floor-crate+ 13) (defconstant +terrain-floor-bookshelf+ 14) (defconstant +terrain-border-floor-snow+ 15) (defconstant +terrain-floor-snow+ 16) (defconstant +terrain-floor-snow-prints+ 17) (defconstant +terrain-tree-birch-snow+ 18) (defconstant +terrain-water-ice+ 19) (defconstant +terrain-border-water+ 20) (defconstant +terrain-floor-bridge+ 21) (defconstant +terrain-floor-pier+ 22) (defconstant +terrain-water-liquid-nofreeze+ 23) (defconstant +terrain-border-grass+ 24) (defconstant +terrain-wall-barricade+ 25) (defconstant +terrain-door-closed+ 26) (defconstant +terrain-door-open+ 27) (defconstant +terrain-border-air+ 28) (defconstant +terrain-floor-air+ 29) (defconstant +terrain-slope-stone-up+ 30) (defconstant +terrain-slope-stone-down+ 31) (defconstant +terrain-wall-earth+ 32) (defconstant +terrain-wall-bush+ 33) (defconstant +terrain-floor-branches+ 34) (defconstant +terrain-floor-leaves+ 35) (defconstant +terrain-tree-birch-trunk+ 36) (defconstant +terrain-floor-leaves-snow+ 37) (defconstant +terrain-tree-oak-trunk-nw+ 38) (defconstant +terrain-tree-oak-trunk-sw+ 39) (defconstant +terrain-tree-oak-trunk-ne+ 40) (defconstant +terrain-tree-oak-trunk-se+ 41) (defconstant +terrain-wall-lantern+ 42) (defconstant +terrain-wall-lantern-off+ 43) (defconstant +terrain-wall-window-opened+ 44) (defconstant +terrain-floor-ash+ 45) (defconstant +terrain-wall-grave+ 46) (defconstant +terrain-floor-sign-church-catholic+ 47) (defconstant +terrain-floor-sign-library+ 48) (defconstant +terrain-floor-sign-prison+ 49) (defconstant +terrain-floor-sign-bank+ 50) (defconstant +terrain-floor-sign-church-orthodox+ 51) (defconstant +terrain-border-creep+ 52) (defconstant +terrain-floor-creep+ 53) (defconstant +terrain-floor-creep-bright+ 54) (defconstant +terrain-tree-twintube+ 55) (defconstant +terrain-tree-twintube-trunk+ 56) (defconstant +terrain-floor-twintube-branches+ 57) (defconstant +terrain-wall-gloomtwigs+ 58) (defconstant +terrain-wall-corrupted+ 59) (defconstant +terrain-floor-creep-dreadtubes+ 60) (defconstant +terrain-floor-creep-spores+ 61) (defconstant +terrain-wall-razorthorns+ 62) (defconstant +terrain-floor-creep-glowshroom+ 63) (defconstant +terrain-floor-creep-irradiated+ 64) (defconstant +terrain-wall-compressed-bones+ 65) (defconstant +terrain-floor-glass+ 66) (defconstant +terrain-wall-raw-flesh+ 67) (defconstant +terrain-floor-slime+ 68) (defconstant +terrain-wall-ice+ 69) ;;-------------------- ;; GOD Constants ;;-------------------- (defconstant +god-entity-malseraph+ 0) ;;-------------------- ;; OBJECTIVE-TYPE Constants ;;-------------------- (defconstant +objective-demon-attack-attacker+ 0) (defconstant +objective-demon-attack-defender+ 1) (defconstant +objective-demon-attack-eater+ 2) (defconstant +objective-demon-attack-thief+ 3) (defconstant +objective-demon-attack-ghost+ 4) (defconstant +objective-demon-attack-scout+ 5) ;;-------------------- ;; Template Globals ;;-------------------- (defparameter *faction-table* (make-hash-table)) (defparameter *specific-faction-names* (make-hash-table)) (defparameter *ability-types* (make-array (list 0) :adjustable t)) (defparameter *feature-types* (make-array (list 0) :adjustable t)) (defparameter *terrain-types* (make-array (list 0) :adjustable t)) (defparameter *mob-types* (make-array (list 0) :adjustable t)) (defparameter *item-types* (make-array (list 0) :adjustable t)) (defparameter *effect-types* (make-array (list 0) :adjustable t)) (defparameter *card-types* (make-array (list 0) :adjustable t)) (defparameter *gods* (make-array (list 0) :adjustable t)) (defparameter *ai-packages* (make-array (list 0) :adjustable t)) (defparameter *faction-types* (make-array (list 0) :initial-element nil :adjustable t)) (defparameter *objective-types* (make-array (list 0) :adjustable t)) ;;-------------------- ;; Actual Game Globals ;;-------------------- (defparameter *lvl-features* (make-array (list 0) :adjustable t)) (defparameter *mobs* (make-array (list 0) :adjustable t)) (defparameter *items* (make-array (list 0) :adjustable t)) (defparameter *effects* (make-array (list 0) :adjustable t)) (defparameter *world* nil) (defparameter *player* nil) (defparameter *game-manager* nil) (defparameter *player-name* nil) (defparameter *player-title* nil) (defvar *update-screen-closure*) (defvar *cur-progress-bar*) (defvar *max-progress-bar*) (defparameter *current-dir* (asdf:system-source-directory :cotd)) (defparameter *campaign-saves-pathlist* (list "saves" "campaign")) (defparameter *scenario-saves-pathlist* (list "saves" "scenario")) (defparameter *save-final-base-dirname* "save") (defparameter *save-descr-filename* "descr") (defparameter *save-game-filename* "game") (defparameter *highscores-filename* "scenario-highscores") (defconstant +normal-ap+ 10) (defparameter *possessed-revolt-chance* 12) (defparameter *acc-loss-per-tile* 5) (defparameter *max-mob-sight* 10) (defparameter *base-mob-sight* 8) (defparameter *base-light-radius* 6) (defparameter *light-power-faloff* 17) (defparameter *dark-power-faloff* 12) (defparameter *mob-visibility-threshold* 50) (defparameter *mob-motion-order* 20) (defparameter *mob-motion-move* 40) (defparameter *mob-motion-stand* 0) (defparameter *mob-motion-melee* 60) (defparameter *mob-motion-shoot* 30) (defparameter *mob-motion-reload* 40) (defparameter *mob-motion-ascend* 100) (defparameter *mob-motion-pick-drop* 30) (defparameter *mob-motion-use-item* 30) (defparameter *mob-exposure-alertness* 30) (defparameter *max-hearing-range* 12) (defparameter *sound-power-falloff* 10) (defparameter *vision-power-falloff* 1) (defparameter *mob-sound-move* 50) (defparameter *mob-sound-stand* 0) (defparameter *mob-sound-melee* 80) (defparameter *mob-sound-reload* 50) (defparameter *mob-sound-shoot* 200) (defparameter *mob-sound-ascend* 60) (defparameter *mob-sound-pick-drop* 40) (defparameter *thief-win-value* 1500) (defparameter *demonic-conquest-win-sigils-dist* 35) (defparameter *max-oxygen-level* 5) (defparameter *lack-oxygen-dmg* 5) (defparameter *repel-demons-dist* 5) (defparameter *repel-demons-dist-strong* 15) (defparameter *min-angels-number* 10) (defparameter *min-imps-number* 10) (defparameter *max-imps-number* 26) (defparameter *shared-mind-msg-color* (sdl:color :r 0 :g 128 :b 128)) (defparameter *water-move-factor* 1.5) (defconstant +connect-room-none+ -1) (defparameter *previous-scenario* nil) ;; Connect map indices for various movement types (defconstant +connect-map-move-walk+ 0) (defconstant +connect-map-move-climb+ 1) (defconstant +connect-map-move-fly+ 2) (defenum:defenum log-options-enum (:log-option-all :log-option-file :log-option-none)) (defvar *cotd-release* nil) (defparameter *cotd-logging* :log-option-all) (defparameter *cotd-log-level* :info) ;;--------------------------- ;; Multithreading parameters ;;--------------------------- (defparameter *path-thread* nil) (defparameter *fov-thread* nil) #+windows (defun new-line (&optional (on-screen nil)) (if on-screen "" #\return)) #+unix (defun new-line (&optional (on-screen nil)) (if on-screen "" #\return)) (defparameter *start-map-x* 190)
35,565
Common Lisp
.lisp
730
45.513699
321
0.735274
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ac8ad656c19142843d23ec7929643d7c1fc3c926e80d2fb22612a8c7cdadfe76
2,842
[ -1 ]
2,843
init-faction-types.lisp
gwathlobal_CotD/src/init-faction-types.lisp
(in-package :cotd) ;;-------------------- ;; Faction Types ;;-------------------- (set-faction-type (make-instance 'faction-type :id +faction-type-civilians+ :name "Civilians" :faction-relations (list (cons +faction-type-civilians+ t) (cons +faction-type-angels+ t) (cons +faction-type-animals+ t) (cons +faction-type-military+ t) (cons +faction-type-church+ t) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-satanists+ nil)))) (set-faction-type (make-instance 'faction-type :id +faction-type-angels+ :name "Angels" :faction-relations (list (cons +faction-type-angels+ t) (cons +faction-type-civilians+ t) (cons +faction-type-animals+ t) (cons +faction-type-criminals+ t) (cons +faction-type-church+ t) (cons +faction-type-demons+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-military+ nil) (cons +faction-type-outsider-wisps+ t) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-angel-chrome+ +specific-faction-type-angel-trinity+))) (set-faction-type (make-instance 'faction-type :id +faction-type-demons+ :name "Demons" :faction-relations (list (cons +faction-type-demons+ t) (cons +faction-type-satanists+ t) (cons +faction-type-angels+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-animals+ nil) (cons +faction-type-military+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil)) :specific-faction-list (list +specific-faction-type-demon-crimson+ +specific-faction-type-demon-shadow+ +specific-faction-type-demon-malseraph+))) (set-faction-type (make-instance 'faction-type :id +faction-type-military+ :name "Military" :faction-relations (list (cons +faction-type-military+ t) (cons +faction-type-civilians+ t) (cons +faction-type-animals+ t) (cons +faction-type-church+ t) (cons +faction-type-demons+ nil) (cons +faction-type-angels+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-military-chaplain+ +specific-faction-type-military-scout+))) (set-faction-type (make-instance 'faction-type :id +faction-type-animals+ :name "Animals" :faction-relations (list (cons +faction-type-animals+ t) (cons +faction-type-civilians+ t) (cons +faction-type-angels+ t) (cons +faction-type-military+ t) (cons +faction-type-criminals+ t) (cons +faction-type-church+ t) (cons +faction-type-demons+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-satanists+ nil)))) (set-faction-type (make-instance 'faction-type :id +faction-type-outsider-beasts+ :name "Outsider beasts" :faction-relations (list (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-animals+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-angels+ nil) (cons +faction-type-military+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil) (cons +faction-type-satanists+ nil)))) (set-faction-type (make-instance 'faction-type :id +faction-type-criminals+ :name "Criminals" :faction-relations (list (cons +faction-type-criminals+ t) (cons +faction-type-angels+ t) (cons +faction-type-animals+ t) (cons +faction-type-civilians+ nil) (cons +faction-type-military+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-thief+))) (set-faction-type (make-instance 'faction-type :id +faction-type-outsider-wisps+ :name "Wisps" :faction-relations (list (cons +faction-type-angels+ t) (cons +faction-type-outsider-wisps+ t) (cons +faction-type-animals+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-military+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil) (cons +faction-type-satanists+ nil)))) (set-faction-type (make-instance 'faction-type :id +faction-type-eater+ :name "Eater of the dead" :faction-relations (list (cons +faction-type-eater+ t) (cons +faction-type-angels+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-animals+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-military+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-eater+ +specific-faction-type-skinchanger+))) (set-faction-type (make-instance 'faction-type :id +faction-type-ghost+ :name "Ghost" :faction-relations (list (cons +faction-type-ghost+ t) (cons +faction-type-angels+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-animals+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-military+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-church+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-ghost+))) (set-faction-type (make-instance 'faction-type :id +faction-type-church+ :name "Church" :faction-relations (list (cons +faction-type-church+ t) (cons +faction-type-civilians+ t) (cons +faction-type-angels+ t) (cons +faction-type-animals+ t) (cons +faction-type-military+ t) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-demons+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-satanists+ nil)) :specific-faction-list (list +specific-faction-type-priest+))) (set-faction-type (make-instance 'faction-type :id +faction-type-satanists+ :name "Satanists" :faction-relations (list (cons +faction-type-satanists+ t) (cons +faction-type-demons+ t) (cons +faction-type-angels+ nil) (cons +faction-type-civilians+ nil) (cons +faction-type-animals+ nil) (cons +faction-type-military+ nil) (cons +faction-type-outsider-beasts+ nil) (cons +faction-type-criminals+ nil) (cons +faction-type-outsider-wisps+ nil) (cons +faction-type-eater+ nil) (cons +faction-type-ghost+ nil) (cons +faction-type-church+ nil)) :specific-faction-list (list +specific-faction-type-satanist+))) ;;------------------------- ;; Specific Faction Names ;;------------------------- (set-specific-faction-name +specific-faction-type-dead-player+ "Dead Player") (set-specific-faction-name +specific-faction-type-test+ "Test Player") (set-specific-faction-name +specific-faction-type-player+ "Player") (set-specific-faction-name +specific-faction-type-angel-chrome+ "Chrome angel") (set-specific-faction-name +specific-faction-type-angel-trinity+ "Trinity mimic") (set-specific-faction-name +specific-faction-type-demon-crimson+ "Crimson demon") (set-specific-faction-name +specific-faction-type-demon-shadow+ "Shadow demon") (set-specific-faction-name +specific-faction-type-demon-malseraph+ "Malseraph's puppet") (set-specific-faction-name +specific-faction-type-military-chaplain+ "Military chaplain") (set-specific-faction-name +specific-faction-type-military-scout+ "Military scout") (set-specific-faction-name +specific-faction-type-thief+ "Thief") (set-specific-faction-name +specific-faction-type-satanist+ "Satanist") (set-specific-faction-name +specific-faction-type-priest+ "Priest") (set-specific-faction-name +specific-faction-type-eater+ "Eater of the dead") (set-specific-faction-name +specific-faction-type-ghost+ "Lost soul") (set-specific-faction-name +specific-faction-type-skinchanger+ "Skinchanger")
12,303
Common Lisp
.lisp
98
86.265306
233
0.520427
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
f980cae4b7532daf0c9cf7021006c9d229eb7b315b6876ed26dc53fa835675b5
2,843
[ -1 ]
2,844
world-sector.lisp
gwathlobal_CotD/src/world-sector.lisp
(in-package :cotd) (defclass world-sector-type () ((wtype :initform nil :initarg :wtype :accessor wtype) (glyph-idx :initform 0 :initarg :glyph-idx :accessor glyph-idx :type fixnum) (glyph-color :initform sdl:*white* :initarg :glyph-color :accessor glyph-color :type sdl:color) (name :initform "" :initarg :name :accessor name :type string) (general-type :initform :world-sector-normal :initarg :general-type :accessor general-type :type world-sector-general-type) (faction-list-func :initform nil :initarg :faction-list-func :accessor faction-list-func) ;; funcation that returns a list of (list <faction type id> <mission faction status id>) (sector-level-gen-func :initform nil :initarg :sector-level-gen-func :accessor sector-level-gen-func) (template-level-gen-func :initform nil :initarg :template-level-gen-func :accessor template-level-gen-func) (terrain-post-process-func-list :initform nil :initarg :terrain-post-process-func-list :accessor terrain-post-process-func-list) (overall-post-process-func-list :initform nil :initarg :overall-post-process-func-list :accessor overall-post-process-func-list) (angel-disguised-mob-type-id :initform +mob-type-man+ :initarg :angel-disguised-mob-type-id :accessor angel-disguised-mob-type-id) (scenario-enabled-func :initform nil :initarg :scenario-enabled-func :accessor scenario-enabled-func) (always-lvl-mods-func :initform nil :initarg :always-lvl-mods-func :accessor always-lvl-mods-func) )) (defparameter *world-sector-types* (make-hash-table)) (defmethod world-sector-normal-p ((world-sector-type world-sector-type)) (eql (general-type world-sector-type) :world-sector-normal)) (defmethod world-sector-abandoned-p ((world-sector-type world-sector-type)) (eql (general-type world-sector-type) :world-sector-abandoned)) (defmethod world-sector-corrupted-p ((world-sector-type world-sector-type)) (eql (general-type world-sector-type) :world-sector-corrupted)) (defmethod world-sector-hell-p ((world-sector-type world-sector-type)) (eql (general-type world-sector-type) :world-sector-hell)) (defun set-world-sector-type (&key wtype glyph-idx glyph-color name general-type faction-list-func sector-level-gen-func template-level-gen-func terrain-post-process-func-list overall-post-process-func-list angel-disguised-mob-type-id scenario-enabled-func (always-lvl-mods-func #'(lambda (world-sector mission-type-id world-time) (declare (ignore world-sector mission-type-id world-time)) nil))) (unless wtype (error ":WTYPE is an obligatory parameter!")) (unless name (error ":NAME is an obligatory parameter!")) (unless glyph-idx (error ":GLYPH-IDX is an obligatory parameter!")) (unless glyph-color (error ":GLYPH-COLOR is an obligatory parameter!")) (unless general-type (error ":GENERAL-TYPE is an obligatory parameter!")) (setf (gethash wtype *world-sector-types*) (make-instance 'world-sector-type :wtype wtype :glyph-idx glyph-idx :glyph-color glyph-color :name name :general-type general-type :faction-list-func faction-list-func :sector-level-gen-func sector-level-gen-func :template-level-gen-func template-level-gen-func :terrain-post-process-func-list terrain-post-process-func-list :overall-post-process-func-list overall-post-process-func-list :angel-disguised-mob-type-id angel-disguised-mob-type-id :scenario-enabled-func scenario-enabled-func :always-lvl-mods-func always-lvl-mods-func ))) (defun get-world-sector-type-by-id (world-sector-type-id) (gethash world-sector-type-id *world-sector-types*)) (defun get-all-world-sector-types-list () (loop for world-sector-type being the hash-values in *world-sector-types* collect world-sector-type)) (defclass world-sector () ((wtype :initform nil :initarg :wtype :accessor wtype) (x :initarg :x :accessor x) (y :initarg :y :accessor y) (feats :initform () :initarg :feats :accessor feats) ;; auxiliary features of the sector, like rivers present ;; ((+lm-feat-river+ (:n :s :w :e)) (+lm-feat-sea+ (:n :s :w :e)) (+lm-feat-barricade+ (:n :s :w :e)) (+lm-feat-church+) (+lm-feat-lair+) (+lm-feat-library+)) (items :initform () :initarg :items :accessor items) ;; global items in in this sector ;; (<level modifier id of type :level-mod-sector-item ...) (controlled-by :initform +lm-controlled-by-none+ :initarg :controlled-by :accessor controlled-by) ;; <level modifier id of type :level-mod-controlled-by (mission :initform nil :initarg :mission :accessor mission) )) (defun description (sector &key (reveal-lair nil)) (let ((feats-list (copy-list (feats sector))) (feats-str (create-string)) (feats-str-comma nil) (controlled-str (create-string)) (items-str (create-string)) (items-str-comma nil) (mission-str (create-string)) (faction-str (create-string)) (level-mod-str (create-string))) (setf feats-list (remove +lm-feat-sea+ feats-list :key #'(lambda (a) (first a)))) (setf feats-list (remove-if #'(lambda (a) (if (and (= (first a) +lm-feat-lair+) (null reveal-lair) (not (mission sector))) t nil)) feats-list)) (loop for l in feats-list for lm-modifier-id = (first l) for name = (name (get-level-modifier-by-id lm-modifier-id)) do (format feats-str "~A~A" (if feats-str-comma ", " (format nil "~%~%")) name) (setf feats-str-comma t) finally (when feats-str-comma (format feats-str "."))) (loop for lm-modifier-id in (items sector) for name = (name (get-level-modifier-by-id lm-modifier-id)) do (format items-str "~A~A" (if items-str-comma ", " (format nil "~%~%Available items:~% ")) (capitalize-name (prepend-article +article-a+ name))) (setf items-str-comma t) finally (when items-str-comma (format items-str "."))) (unless (= (controlled-by sector) +lm-controlled-by-none+) (format controlled-str "~%~%~A." (name (get-level-modifier-by-id (controlled-by sector))))) (when (mission sector) (format mission-str "~%~%Available mission:~% ~A.~%" (name (mission sector))) (loop with first-line = t with faction-comma = nil for (faction-type faction-presence) in (faction-list (mission sector)) for faction-name = (name (get-faction-type-by-id faction-type)) when (eq faction-presence :mission-faction-present) do (when first-line (format faction-str "~% Present factions:~% ") (setf first-line nil)) (format faction-str "~A~A" (if faction-comma ", " "") faction-name) (setf faction-comma t) finally (when faction-comma (format faction-str "~%"))) (loop with first-line = t with faction-comma = nil for (faction-type faction-presence) in (faction-list (mission sector)) for faction-name = (name (get-faction-type-by-id faction-type)) when (eq faction-presence :mission-faction-delayed) do (when first-line (format faction-str "~% Delayed arrival:~% ") (setf first-line nil)) (format faction-str "~A~A" (if faction-comma ", " "") faction-name) (setf faction-comma t) finally (when faction-comma (format faction-str "~%"))) (loop with first-line = t with comma = nil for lvl-mod-id in (level-modifier-list (mission sector)) for lvl-mod-name = (name (get-level-modifier-by-id lvl-mod-id)) do (when first-line (format level-mod-str "~% Features:~% ") (setf first-line nil)) (format level-mod-str "~A~A" (if comma ", " "") lvl-mod-name) (setf comma t) finally (when comma (format level-mod-str "~%")))) (format nil "~A.~A~A~A~A~A~A" (name (get-world-sector-type-by-id (wtype sector))) feats-str items-str controlled-str mission-str faction-str level-mod-str))) (defun add-item-to-sector (world-sector item-type-id) (push (items world-sector) item-type-id)) (defun remove-item-from-sector (world-sector item-type-id) (setf (items world-sector) (remove item-type-id (items world-sector)))) (defmethod angel-disguised-mob-type-id ((world-sector world-sector)) (angel-disguised-mob-type-id (get-world-sector-type-by-id (wtype world-sector)))) (defmethod name ((world-sector world-sector)) (name (get-world-sector-type-by-id (wtype world-sector)))) (defmethod world-sector-normal-p ((world-sector world-sector)) (eql (general-type (get-world-sector-type-by-id (wtype world-sector))) :world-sector-normal)) (defmethod world-sector-abandoned-p ((world-sector world-sector)) (eql (general-type (get-world-sector-type-by-id (wtype world-sector))) :world-sector-abandoned)) (defmethod world-sector-corrupted-p ((world-sector world-sector)) (eql (general-type (get-world-sector-type-by-id (wtype world-sector))) :world-sector-corrupted)) (defmethod world-sector-hell-p ((world-sector world-sector)) (eql (general-type (get-world-sector-type-by-id (wtype world-sector))) :world-sector-hell)) (defun world-find-sides-for-world-sector (world-sector world-map test-north-func test-south-func test-west-func test-east-func call-north-func call-south-func call-west-func call-east-func) ;; test-func takes (x y) ;; find sectors to the east, west, north, south that satisfy the test ;; if found place do something to that side of the level (let ((max-world-x (array-dimension (cells world-map) 0)) (max-world-y (array-dimension (cells world-map) 1))) ;; find west (loop named loop for x from 0 below (x world-sector) do (loop for y from 0 below max-world-y do (when (funcall test-west-func x y) (funcall call-west-func) (return-from loop nil) ))) ;; find east (loop named loop for x from (1+ (x world-sector)) below max-world-x do (loop for y from 0 below max-world-y do (when (funcall test-east-func x y) (funcall call-east-func) (return-from loop nil) ))) ;; find north (loop named loop for x from 0 below max-world-x do (loop for y from 0 below (y world-sector) do (when (funcall test-north-func x y) (funcall call-north-func) (return-from loop nil) ))) ;; find south (loop named loop for x from 0 below max-world-x do (loop for y from (1+ (y world-sector)) below max-world-y do (when (funcall test-south-func x y) (funcall call-south-func) (return-from loop nil) ))) ) ) (defun add-arrival-points-on-level (level world-sector mission world) (declare (ignore mission)) (log:info "Start") (let* ((sides-hash (make-hash-table)) (demon-test-func #'(lambda (x y) (if (and (<= (abs (- x (x world-sector))) 1) (<= (abs (- y (y world-sector))) 1) (or (= (controlled-by (aref (cells (world-map world)) x y)) +lm-controlled-by-demons+) (and (world-sector-corrupted-p (aref (cells (world-map world)) x y)) (not (eql (wtype (aref (cells (world-map world)) x y)) :world-sector-corrupted-island))))) t nil))) (military-test-func #'(lambda (x y) (if (and (<= (abs (- x (x world-sector))) 1) (<= (abs (- y (y world-sector))) 1) (or (= (controlled-by (aref (cells (world-map world)) x y)) +lm-controlled-by-military+) (world-sector-normal-p (aref (cells (world-map world)) x y)))) t nil))) (hash-print-func #'(lambda () (loop initially (log:debug "~%SIDES-HASH:") for side being the hash-keys in sides-hash do (log:debug " ~A : ~A" side (gethash side sides-hash)) finally (log:debug "")))) (side-party-list (list (list :demons +feature-delayed-demons-arrival-point+) (list :military +feature-delayed-military-arrival-point+) (list :angels +feature-delayed-angels-arrival-point+) ))) (when (or (not (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a)))) (and (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (or (world-sector-abandoned-p world-sector) (world-sector-corrupted-p world-sector)))) (push (list :angels +feature-start-place-angels+) side-party-list)) (unless (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list :military +feature-start-place-military+) side-party-list)) (unless (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list :demons +feature-start-place-demons+) side-party-list)) (setf (gethash :n sides-hash) ()) (setf (gethash :s sides-hash) ()) (setf (gethash :e sides-hash) ()) (setf (gethash :w sides-hash) ()) ;; find all sides from which demons can arrive (world-find-sides-for-world-sector world-sector (world-map world) demon-test-func demon-test-func demon-test-func demon-test-func #'(lambda () (if (gethash :n sides-hash) (push :demons (gethash :n sides-hash)) (setf (gethash :n sides-hash) (list :demons)))) #'(lambda () (if (gethash :s sides-hash) (push :demons (gethash :s sides-hash)) (setf (gethash :s sides-hash) (list :demons)))) #'(lambda () (if (gethash :w sides-hash) (push :demons (gethash :w sides-hash)) (setf (gethash :w sides-hash) (list :demons)))) #'(lambda () (if (gethash :e sides-hash) (push :demons (gethash :e sides-hash)) (setf (gethash :e sides-hash) (list :demons))))) ;; find all sides from which military can arrive (world-find-sides-for-world-sector world-sector (world-map world) military-test-func military-test-func military-test-func military-test-func #'(lambda () (if (gethash :n sides-hash) (push :military (gethash :n sides-hash)) (setf (gethash :n sides-hash) (list :military)))) #'(lambda () (if (gethash :s sides-hash) (push :military (gethash :s sides-hash)) (setf (gethash :s sides-hash) (list :military)))) #'(lambda () (if (gethash :w sides-hash) (push :military (gethash :w sides-hash)) (setf (gethash :w sides-hash) (list :military)))) #'(lambda () (if (gethash :e sides-hash) (push :military (gethash :e sides-hash)) (setf (gethash :e sides-hash) (list :military))))) ;; PRINT (funcall hash-print-func) ;; reduce all sides to only one party per side (loop with parties = (list :angels :military :demons) with nums = (list :angels 0 :military 0 :demons 0) with has-overlapped = nil with count-nums-func = #'(lambda () (loop initially (setf nums (list :angels 0 :military 0 :demons 0) has-overlapped nil) for side being the hash-keys in sides-hash do (loop for party in parties when (find party (gethash side sides-hash)) do (incf (getf nums party))) (when (> (length (gethash side sides-hash)) 1) (setf has-overlapped t)) finally (log:debug "Reduce counts:~% ~A~% Overlapped: ~A~%" nums has-overlapped))) initially (funcall count-nums-func) while has-overlapped do (loop for party in parties do (loop with prev-num = 0 with cur-num = (getf nums party) while (/= cur-num prev-num) do (setf prev-num cur-num) (loop for side being the hash-keys in sides-hash when (and (> (length (gethash side sides-hash)) 1) (> cur-num 1) (find party (gethash side sides-hash))) do (setf (gethash side sides-hash) (remove party (gethash side sides-hash))) (funcall count-nums-func) (funcall hash-print-func) (loop-finish)))) ) (log:debug "After reduce ") (funcall hash-print-func) ;; add parties that are absent at the moment (loop with absent-parties = (list :demons :angels :military) with free-sides = () with excess-parties = () with parties-hash = (make-hash-table) with count-nums-func = #'(lambda () (setf (gethash :demons parties-hash) ()) (setf (gethash :angels parties-hash) ()) (setf (gethash :military parties-hash) ()) (loop initially (setf absent-parties (list :demons :angels :military) free-sides () excess-parties ()) for side being the hash-keys in sides-hash when (find :demons (gethash side sides-hash)) do (setf absent-parties (remove :demons absent-parties)) (push side (gethash :demons parties-hash)) when (find :military (gethash side sides-hash)) do (setf absent-parties (remove :military absent-parties)) (push side (gethash :military parties-hash)) when (find :angels (gethash side sides-hash)) do (setf absent-parties (remove :angels absent-parties)) (push side (gethash :angels parties-hash)) when (null (gethash side sides-hash)) do (push side free-sides) finally (when (> (length (gethash :demons parties-hash)) 1) (push :demons excess-parties)) (when (> (length (gethash :military parties-hash)) 1) (push :military excess-parties)) (when (> (length (gethash :angels parties-hash)) 1) (push :angels excess-parties)) (log:debug "Counts:~% Absent parties: ~A, Free sides: ~A, Excess parties: ~A" absent-parties free-sides excess-parties))) initially (funcall count-nums-func) while absent-parties do (let ((random-party (nth (random (length absent-parties)) absent-parties)) (random-side nil) (random-excess-party nil)) ;; add an absent party to a free side (if free-sides (progn (setf random-side (nth (random (length free-sides)) free-sides)) (setf (gethash random-side sides-hash) (list random-party)) ) ;; if there are no free sides replace a side of the party that has more than one sides (progn (setf random-excess-party (nth (random (length excess-parties)) excess-parties)) (setf random-side (nth (random (length (gethash random-excess-party parties-hash))) (gethash random-excess-party parties-hash))) (setf (gethash random-side sides-hash) (remove random-excess-party (gethash random-side sides-hash))) (push random-party (gethash random-side sides-hash)) )) ) (log:debug "After ") (funcall count-nums-func) (funcall hash-print-func) ) ;; once we fixed everything - we can place arrival points (loop with party-list = side-party-list for (party arrival-point-feature-type-id) in party-list ;; north when (find party (gethash :n sides-hash)) do ;; replace feature arrival points (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-arrival-point-north+) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x (x feature) :y (y feature) :z (z feature)))) ;; place standard arrival points an the side (loop with y = 2 with z = 2 for x from 0 below (array-dimension (terrain level) 0) by (+ 5 (random 3)) when (and (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+)) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x x :y y :z z))) ;; south when (find party (gethash :s sides-hash)) do ;; replace feature arrival points (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-arrival-point-south+) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x (x feature) :y (y feature) :z (z feature)))) ;; place standard arrival points an the side (loop with y = (- (array-dimension (terrain level) 1) 3) with z = 2 for x from 0 below (array-dimension (terrain level) 0) by (+ 5 (random 3)) when (and (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+)) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x x :y y :z z))) ;; west when (find party (gethash :w sides-hash)) do ;; replace feature arrival points (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-arrival-point-west+) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x (x feature) :y (y feature) :z (z feature)))) ;; place standard arrival points an the side (loop with x = 2 with z = 2 for y from 0 below (array-dimension (terrain level) 1) by (+ 5 (random 3)) when (and (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+)) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x x :y y :z z))) ;; east when (find party (gethash :e sides-hash)) do ;; replace feature arrival points (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-arrival-point-east+) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x (x feature) :y (y feature) :z (z feature)))) ;; place standard arrival points an the side (loop with x = (- (array-dimension (terrain level) 1) 3) with z = 2 for y from 0 below (array-dimension (terrain level) 1) by (+ 5 (random 3)) when (and (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+)) do (add-feature-to-level-list level (make-instance 'feature :feature-type arrival-point-feature-type-id :x x :y y :z z))) ) ) ) (defun place-seaport-north (template-level warehouse-building-id-1 warehouse-building-id-2) (loop with max-x = (array-dimension template-level 0) for x from 0 below max-x for building-type-id = (if (and (zerop (mod x 5)) (/= x 0) (/= x 9) (/= x 10) (/= x 11) (/= x (1- max-x))) +building-city-pier-north+ +building-city-sea+) for random-warehouse-1 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) for random-warehouse-2 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) do (level-city-reserve-build-on-grid +building-city-sea+ x 0 2 template-level) (level-city-reserve-build-on-grid building-type-id x 1 2 template-level) (level-city-reserve-build-on-grid building-type-id x 2 2 template-level) (when (level-city-can-place-build-on-grid random-warehouse-1 x 3 2 template-level) (level-city-reserve-build-on-grid random-warehouse-1 x 3 2 template-level)) (when (level-city-can-place-build-on-grid random-warehouse-2 x 5 2 template-level) (level-city-reserve-build-on-grid random-warehouse-2 x 5 2 template-level)))) (defun place-seaport-south (template-level warehouse-building-id-1 warehouse-building-id-2) (loop with max-x = (array-dimension template-level 0) with max-y = (array-dimension template-level 1) for x from 0 below max-x for building-type-id = (if (and (zerop (mod x 5)) (/= x 0) (/= x 9) (/= x 10) (/= x 11) (/= x (1- max-x))) +building-city-pier-south+ +building-city-sea+) for random-warehouse-1 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) for random-warehouse-2 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) do (level-city-reserve-build-on-grid +building-city-sea+ x (- max-y 1) 2 template-level) (level-city-reserve-build-on-grid building-type-id x (- max-y 2) 2 template-level) (level-city-reserve-build-on-grid building-type-id x (- max-y 3) 2 template-level) (when (level-city-can-place-build-on-grid random-warehouse-1 x (- max-y 5) 2 template-level) (level-city-reserve-build-on-grid random-warehouse-1 x (- max-y 5) 2 template-level)) (when (level-city-can-place-build-on-grid random-warehouse-2 x (- max-y 7) 2 template-level) (level-city-reserve-build-on-grid random-warehouse-2 x (- max-y 7) 2 template-level)))) (defun place-seaport-east (template-level warehouse-building-id-1 warehouse-building-id-2) (loop with max-x = (array-dimension template-level 0) with max-y = (array-dimension template-level 1) for y from 0 below max-y for building-type-id = (if (and (zerop (mod y 5)) (/= y 0) (/= y 9) (/= y 10) (/= y 11) (/= y (1- max-y))) +building-city-pier-east+ +building-city-sea+) for random-warehouse-1 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) for random-warehouse-2 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) do (level-city-reserve-build-on-grid +building-city-sea+ (- max-x 1) y 2 template-level) (level-city-reserve-build-on-grid building-type-id (- max-y 2) y 2 template-level) (level-city-reserve-build-on-grid building-type-id (- max-y 3) y 2 template-level) (when (level-city-can-place-build-on-grid random-warehouse-1 (- max-x 5) y 2 template-level) (level-city-reserve-build-on-grid random-warehouse-1 (- max-x 5) y 2 template-level)) (when (level-city-can-place-build-on-grid random-warehouse-2 (- max-x 7) y 2 template-level) (level-city-reserve-build-on-grid random-warehouse-2 (- max-x 7) y 2 template-level)))) (defun place-seaport-west (template-level warehouse-building-id-1 warehouse-building-id-2) (loop with max-y = (array-dimension template-level 1) for y from 0 below max-y for building-type-id = (if (and (zerop (mod y 5)) (/= y 0) (/= y 9) (/= y 10) (/= y 11) (/= y (1- max-y))) +building-city-pier-west+ +building-city-sea+) for random-warehouse-1 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) for random-warehouse-2 = (if (zerop (random 2)) warehouse-building-id-1 warehouse-building-id-2) do (level-city-reserve-build-on-grid +building-city-sea+ 0 y 2 template-level) (level-city-reserve-build-on-grid building-type-id 1 y 2 template-level) (level-city-reserve-build-on-grid building-type-id 2 y 2 template-level) (when (level-city-can-place-build-on-grid random-warehouse-1 3 y 2 template-level) (level-city-reserve-build-on-grid random-warehouse-1 3 y 2 template-level)) (when (level-city-can-place-build-on-grid random-warehouse-2 5 y 2 template-level) (level-city-reserve-build-on-grid random-warehouse-2 5 y 2 template-level)))) (defun place-coins-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Place coins") (let ((total-gold-items (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-start-gold-small+) count lvl-feature))) (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-start-gold-small+) do (add-item-to-level-list level (make-instance 'item :item-type +item-type-coin+ :x (x lvl-feature) :y (y lvl-feature) :z (z lvl-feature) :qty (+ (round 1250 total-gold-items) (random 51)))) (remove-feature-from-level-list level lvl-feature) ) )) (defun place-civilians-on-level (level world-sector mission world) (declare (ignore world-sector world)) (log:info "Place civilians") (loop with civilians-present = nil for (faction-type faction-presence) in (faction-list mission) when (and (= faction-type +faction-type-civilians+) (eq faction-presence :mission-faction-present)) do (setf civilians-present t) finally (unless civilians-present (return)) ;; find all civilian start points and place civilians there (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) for x = (x lvl-feature) for y = (y lvl-feature) for z = (z lvl-feature) when (= (feature-type lvl-feature) +feature-start-place-civilian-man+) do (add-mob-to-level-list level (make-instance 'mob :mob-type +mob-type-man+ :x x :y y :z z)) when (= (feature-type lvl-feature) +feature-start-place-civilian-woman+) do (add-mob-to-level-list level (make-instance 'mob :mob-type +mob-type-woman+ :x x :y y :z z)) when (= (feature-type lvl-feature) +feature-start-place-civilian-child+) do (add-mob-to-level-list level (make-instance 'mob :mob-type +mob-type-child+ :x x :y y :z z))) )) (defun place-outsider-beasts-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Place outsider beasts") (populate-level-with-mobs level (list (list +mob-type-gargantaur+ 1 nil) (list +mob-type-wisp+ 9 nil)) #'find-unoccupied-place-inside) (populate-level-with-mobs level (list (list +mob-type-fiend+ 16 nil)) #'find-unoccupied-place-inside) ) (defun place-demonic-sigils-on-level (level world-sector mission world) (declare (ignore world-sector mission)) (log:info "Add demon sigils") (loop with sigil = nil for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-start-sigil-point+) do (setf sigil (make-instance 'mob :mob-type +mob-type-demon-sigil+)) (setf (x sigil) (x lvl-feature) (y sigil) (y lvl-feature) (z sigil) (z lvl-feature)) (add-mob-to-level-list level sigil) (set-mob-effect sigil :effect-type-id +mob-effect-demonic-sigil+ :actor-id (id sigil) :cd t) (multiple-value-bind (year month day hour min sec) (get-current-date-time (world-game-time world)) (declare (ignore year month day min sec)) (let ((demon-list (if (and (>= hour 7) (< hour 19)) (list (list +mob-type-demon+ 3 nil) (list +mob-type-imp+ 4 nil)) (list (list +mob-type-demon+ 2 nil) (list +mob-type-shadow-demon+ 1 nil) (list +mob-type-imp+ 1 nil) (list +mob-type-shadow-imp+ 3 nil))))) (place-mobs-on-level-immediate level :start-point-list (list (list (1+ (x sigil)) (1+ (y sigil)) (z sigil)) (list (1- (x sigil)) (1+ (y sigil)) (z sigil)) (list (1+ (x sigil)) (1- (y sigil)) (z sigil)) (list (1- (x sigil)) (1- (y sigil)) (z sigil))) :create-player nil :mob-list demon-list :no-center nil)))) ) (defun place-demonic-machines-on-level (level world-sector mission world) (declare (ignore world-sector world mission)) (log:info (format nil "OVERALL-POST-PROCESS-FUNC: Add demon machines~%")) (loop with machine = nil for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-start-machine-point+) do (setf machine (make-instance 'mob :mob-type +mob-type-demon-machine+)) (setf (x machine) (x lvl-feature) (y machine) (y lvl-feature) (z machine) (z lvl-feature)) (add-mob-to-level-list level machine) (set-mob-effect machine :effect-type-id +mob-effect-demonic-machine+ :actor-id (id machine) :cd t)) ) (defun place-flesh-storages-on-level (level world-sector mission world) (declare (ignore world-sector world mission)) (log:info (format nil "OVERALL-POST-PROCESS-FUNC: Add flesh storages~%")) (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-bomb-plant-target+) do (push feature-id (bomb-plant-locations level)) ;; accumulate raw flesh terrain inside the feature parameter (loop for x from (+ (x lvl-feature) -5) to (+ (x lvl-feature) 5) do (loop for y from (+ (y lvl-feature) -5) to (+ (y lvl-feature) 5) do (loop for z from (z lvl-feature) downto 0 do (when (and (> x 0) (> y 0) (< x (array-dimension (terrain level) 0)) (< y (array-dimension (terrain level) 1)) (eq (get-terrain-* level x y z) +terrain-wall-raw-flesh+)) (push (list x y z) (param1 lvl-feature))))))) ) (defun place-blood-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info (format nil "OVERALL-POST-PROCESS-FUNC: Place blood spatters~%")) (let ((blood ()) (max-blood (sqrt (* (array-dimension (terrain level) 0) (array-dimension (terrain level) 1))))) (loop with max-x = (- (array-dimension (terrain level) 0) 2) with max-y = (- (array-dimension (terrain level) 1) 2) with max-z = (- (array-dimension (terrain level) 2) 2) with cur-blood = 0 for x = (1+ (random max-x)) for y = (1+ (random max-y)) for z = (1+ (random max-z)) while (< cur-blood max-blood) do (when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-water+))) (if (zerop (random 2)) (push (list x y z +feature-blood-stain+) blood) (push (list x y z +feature-blood-old+) blood)) (incf cur-blood) (check-surroundings x y nil #'(lambda (dx dy) (when (and (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-water+))) (when (zerop (random 4)) (push (list dx dy z +feature-blood-old+) blood)))))) ) (loop for (x y z feature-type-id) in blood do ;;(format t "PLACE PORTAL ~A AT (~A ~A ~A)~%" (name (get-feature-type-by-id feature-type-id)) x y z) (add-feature-to-level-list level (make-instance 'feature :feature-type feature-type-id :x x :y y :z z))))) (defun place-irradation-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Place irradiated spots") (loop with max-x = (- (array-dimension (terrain level) 0) 2) with max-y = (- (array-dimension (terrain level) 1) 2) with max-z = (- (array-dimension (terrain level) 2) 2) with cur-spot = 0 with max-spots = (+ 3 (random 10)) with func = #'(lambda (tx ty tz) (labels ((recursive-func (tx ty tz) (set-terrain-* level tx ty tz +terrain-floor-creep-irradiated+) (check-surroundings tx ty nil #'(lambda (dx dy) (when (= (get-terrain-* level dx dy tz) +terrain-floor-creep+) (when (zerop (random 4)) (recursive-func dx dy tz))))))) (recursive-func tx ty tz))) for x = (1+ (random max-x)) for y = (1+ (random max-y)) for z = (1+ (random max-z)) while (< cur-spot max-spots) do (when (= (get-terrain-* level x y z) +terrain-floor-creep+) (funcall func x y z) (incf cur-spot))) ) (defun place-lake-on-template-level (template-level building-lake-id) (let ((x (- (truncate (array-dimension template-level 0) 2) 2)) (y (- (truncate (array-dimension template-level 1) 2) 2))) (level-city-reserve-build-on-grid building-lake-id x y 2 template-level) )) (defun place-island-on-template-level (template-level world-sector mission world) (declare (ignore mission world mission world-sector)) (log:info "Start") (let ((max-x (array-dimension template-level 0)) (max-y (array-dimension template-level 1))) ;; place water along the borders (loop for x from 0 below max-x do (level-city-reserve-build-on-grid +building-city-sea+ x 0 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ x 1 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ x 2 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ x (- max-y 1) 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ x (- max-y 2) 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ x (- max-y 3) 2 template-level)) (loop for y from 0 below max-y do (level-city-reserve-build-on-grid +building-city-sea+ 0 y 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ 1 y 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ 2 y 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ (- max-x 1) y 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ (- max-x 2) y 2 template-level) (level-city-reserve-build-on-grid +building-city-sea+ (- max-x 3) y 2 template-level)) ;; place four piers - north, south, east, west (let ((min) (max) (r)) ;; north (setf min 3 max (- (truncate max-x 2) 1)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-north+ r 1 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-north+ r 2 2 template-level) (setf min (+ (truncate max-x 2) 1) max (- max-x 3)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-north+ r 1 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-north+ r 2 2 template-level) ;; south (setf min 3 max (- (truncate max-x 2) 1)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-south+ r (- max-y 2) 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-south+ r (- max-y 3) 2 template-level) (setf min (+ (truncate max-x 2) 1) max (- max-x 3)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-south+ r (- max-y 2) 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-south+ r (- max-y 3) 2 template-level) ;; west (setf min 3 max (- (truncate max-y 2) 1)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-west+ 1 r 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-west+ 2 r 2 template-level) (setf min (+ (truncate max-y 2) 1) max (- max-y 3)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-west+ 1 r 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-west+ 2 r 2 template-level) ;; east (setf min 3 max (- (truncate max-y 2) 1)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-east+ (- max-x 2) r 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-east+ (- max-x 3) r 2 template-level) (setf min (+ (truncate max-y 2) 1) max (- max-y 3)) (setf r (+ (random (- max min)) min)) (level-city-reserve-build-on-grid +building-city-pier-east+ (- max-x 2) r 2 template-level) (level-city-reserve-build-on-grid +building-city-pier-east+ (- max-x 3) r 2 template-level)) ) ) (defun place-outskirts-on-template-level (template-level building-border-id building-park-id) ;; place building-park-id along the borders (loop with y1 = 0 with y2 = (array-dimension template-level 1) for x from 0 below (array-dimension template-level 0) do (level-city-reserve-build-on-grid building-border-id x y1 2 template-level) (level-city-reserve-build-on-grid building-border-id x (- y2 1) 2 template-level) (when (level-city-can-place-build-on-grid building-park-id x (+ y1 1) 2 template-level) (level-city-reserve-build-on-grid building-park-id x (+ y1 1) 2 template-level)) (when (level-city-can-place-build-on-grid building-park-id x (- y2 3) 2 template-level) (level-city-reserve-build-on-grid building-park-id x (- y2 3) 2 template-level))) (loop with x1 = 0 with x2 = (array-dimension template-level 0) for y from 0 below (array-dimension template-level 1) do (level-city-reserve-build-on-grid building-border-id x1 y 2 template-level) (level-city-reserve-build-on-grid building-border-id (- x2 1) y 2 template-level) (when (level-city-can-place-build-on-grid building-park-id (+ x1 1) y 2 template-level) (level-city-reserve-build-on-grid building-park-id (+ x1 1) y 2 template-level)) (when (level-city-can-place-build-on-grid building-park-id (- x2 3) y 2 template-level) (level-city-reserve-build-on-grid building-park-id (- x2 3) y 2 template-level))) ) (defun place-demonic-sigils-on-template-level (template-level) (let ((building-id +building-city-sigil-post+) (x-w 4) (y-n 4) (x-e (- (array-dimension template-level 0) 5)) (y-s (- (array-dimension template-level 1) 5))) ;; place nw post (when (level-city-can-place-build-on-grid building-id x-w y-n 2 template-level) (level-city-reserve-build-on-grid building-id x-w y-n 2 template-level)) ;; place ne post (when (level-city-can-place-build-on-grid building-id x-e y-n 2 template-level) (level-city-reserve-build-on-grid building-id x-e y-n 2 template-level)) ;; place sw post (when (level-city-can-place-build-on-grid building-id x-w y-s 2 template-level) (level-city-reserve-build-on-grid building-id x-w y-s 2 template-level)) ;; place se post (when (level-city-can-place-build-on-grid building-id x-e y-s 2 template-level) (level-city-reserve-build-on-grid building-id x-e y-s 2 template-level)) )) (defun place-demonic-machines-on-template-level (template-level) (let ((building-id-list (get-all-building-ids-by-type +building-type-hell-machine+)) (x-w 4) (y-n 4) (x-e (- (array-dimension template-level 0) 5)) (y-s (- (array-dimension template-level 1) 5)) (building-id)) ;; place nw post (setf building-id (nth (random (length building-id-list)) building-id-list)) (when (level-city-can-place-build-on-grid building-id x-w y-n 2 template-level) (level-city-reserve-build-on-grid building-id x-w y-n 2 template-level)) ;; place ne post (setf building-id (nth (random (length building-id-list)) building-id-list)) (when (level-city-can-place-build-on-grid building-id x-e y-n 2 template-level) (level-city-reserve-build-on-grid building-id x-e y-n 2 template-level)) ;; place sw post (setf building-id (nth (random (length building-id-list)) building-id-list)) (when (level-city-can-place-build-on-grid building-id x-w y-s 2 template-level) (level-city-reserve-build-on-grid building-id x-w y-s 2 template-level)) ;; place se post (setf building-id (nth (random (length building-id-list)) building-id-list)) (when (level-city-can-place-build-on-grid building-id x-e y-s 2 template-level) (level-city-reserve-build-on-grid building-id x-e y-s 2 template-level)) )) (defun place-flesh-storages-on-template-level (template-level) (let* ((building-id-list (get-all-building-ids-by-type +building-type-hell-storage+)) (x-step (truncate (array-dimension template-level 0) 4)) (y-step (truncate (array-dimension template-level 1) 4)) (x1 (1- (* x-step 1))) (x2 (1- (* x-step 2))) (x3 (1- (* x-step 3))) (y1 (1- (* y-step 1))) (y2 (1- (* y-step 2))) (y3 (1- (* y-step 3))) (variant1 `((,x1 ,y1) (,x1 ,y3) (,x3 ,y2))) (variant2 `((,x1 ,y2) (,x3 ,y1) (,x3 ,y3))) (variant3 `((,x2 ,y1) (,x1 ,y3) (,x3 ,y3))) (variant4 `((,x1 ,y1) (,x3 ,y1) (,x2 ,y3))) (variants (list variant1 variant2 variant3 variant4)) (building-id)) (loop for (x y) in (nth (random (length variants)) variants) do (setf building-id (nth (random (length building-id-list)) building-id-list)) (when (level-city-can-place-build-on-grid building-id x y 2 template-level) (level-city-reserve-build-on-grid building-id x y 2 template-level))) )) (defun get-max-buildings-normal () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-house+ max-building-types) t) (setf (gethash +building-type-townhall+ max-building-types) t) (setf (gethash +building-type-park+ max-building-types) t) (setf (gethash +building-type-mansion+ max-building-types) t) (setf (gethash +building-type-warehouse+ max-building-types) 1) (setf (gethash +building-type-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 1) (setf (gethash +building-type-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 4) (setf (gethash +building-type-graveyard+ max-building-types) 1) max-building-types)) (defun get-max-buildings-port () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-house+ max-building-types) t) (setf (gethash +building-type-townhall+ max-building-types) t) (setf (gethash +building-type-park+ max-building-types) t) (setf (gethash +building-type-mansion+ max-building-types) t) (setf (gethash +building-type-warehouse+ max-building-types) 0) (setf (gethash +building-type-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 1) (setf (gethash +building-type-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 0) max-building-types)) (defun get-reserved-buildings-normal () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-reserved-buildings-port () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-max-buildings-ruined-normal () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-ruined-house+ max-building-types) t) (setf (gethash +building-type-ruined-townhall+ max-building-types) t) (setf (gethash +building-type-ruined-park+ max-building-types) t) (setf (gethash +building-type-ruined-mansion+ max-building-types) t) (setf (gethash +building-type-ruined-warehouse+ max-building-types) 1) (setf (gethash +building-type-ruined-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 1) (setf (gethash +building-type-ruined-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 4) (setf (gethash +building-type-graveyard+ max-building-types) 1) (setf (gethash +building-type-crater+ max-building-types) 4) (setf (gethash +building-type-crater-large+ max-building-types) 1) max-building-types)) (defun get-max-buildings-ruined-port () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-ruined-house+ max-building-types) t) (setf (gethash +building-type-ruined-townhall+ max-building-types) t) (setf (gethash +building-type-ruined-park+ max-building-types) t) (setf (gethash +building-type-ruined-mansion+ max-building-types) t) (setf (gethash +building-type-ruined-warehouse+ max-building-types) 0) (setf (gethash +building-type-ruined-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 1) (setf (gethash +building-type-ruined-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 0) (setf (gethash +building-type-crater+ max-building-types) 4) (setf (gethash +building-type-crater-large+ max-building-types) 1) max-building-types)) (defun get-reserved-buildings-ruined-normal () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-reserved-buildings-ruined-port () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-max-buildings-corrupted-normal () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-corrupted-house+ max-building-types) t) (setf (gethash +building-type-corrupted-townhall+ max-building-types) t) (setf (gethash +building-type-corrupted-park+ max-building-types) t) (setf (gethash +building-type-corrupted-mansion+ max-building-types) t) (setf (gethash +building-type-corrupted-warehouse+ max-building-types) 1) (setf (gethash +building-type-corrupted-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 0) (setf (gethash +building-type-corrupted-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 4) (setf (gethash +building-type-corrupted-graveyard+ max-building-types) 1) (setf (gethash +building-type-crater+ max-building-types) 4) (setf (gethash +building-type-crater-large+ max-building-types) 1) max-building-types)) (defun get-max-buildings-corrupted-port () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-corrupted-house+ max-building-types) t) (setf (gethash +building-type-corrupted-townhall+ max-building-types) t) (setf (gethash +building-type-corrupted-park+ max-building-types) t) (setf (gethash +building-type-corrupted-mansion+ max-building-types) t) (setf (gethash +building-type-corrupted-warehouse+ max-building-types) 0) (setf (gethash +building-type-corrupted-prison+ max-building-types) 1) (setf (gethash +building-type-stables+ max-building-types) 0) (setf (gethash +building-type-corrupted-bank+ max-building-types) 1) (setf (gethash +building-type-lake+ max-building-types) 0) (setf (gethash +building-type-crater+ max-building-types) 4) (setf (gethash +building-type-crater-large+ max-building-types) 1) max-building-types)) (defun get-max-buildings-hell-normal () (let ((max-building-types (make-hash-table))) (setf (gethash +building-type-hell-structure+ max-building-types) t) (setf (gethash +building-type-hell-growth+ max-building-types) t) (setf (gethash +building-type-hell-struct-growth+ max-building-types) t) (setf (gethash +building-type-hell-slime-pool+ max-building-types) 4) (setf (gethash +building-type-crater+ max-building-types) 4) (setf (gethash +building-type-crater-large+ max-building-types) 1) max-building-types)) (defun get-reserved-buildings-corrupted-normal () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-reserved-buildings-corrupted-port () (let ((reserved-building-types (make-hash-table))) reserved-building-types)) (defun get-reserved-buildings-hell-normal () (let ((reserved-building-types (make-hash-table))) reserved-building-types))
62,341
Common Lisp
.lisp
976
46.947746
181
0.554665
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
0de26e66703aa80bd6b047f98079ca1c4192dd0707437907ecf576556dda4186
2,844
[ -1 ]
2,845
colored-text.lisp
gwathlobal_CotD/src/colored-text.lisp
(in-package :cotd) (defstruct colored-txt (list () :type list)) (defun add-colored-str (colored-txt str &optional (color sdl:*white*)) (setf (colored-txt-list colored-txt) (append (colored-txt-list colored-txt) (list (list str color)))))
291
Common Lisp
.lisp
6
38.666667
77
0.600707
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
297075e620f3914c48865c00285e476f4aa104ec09828f2be97cc9d3fe2592d0
2,845
[ -1 ]
2,846
abilities.lisp
gwathlobal_CotD/src/abilities.lisp
(in-package :cotd) ;;-------------------- ;; ABILITY-TYPE ;;-------------------- (defconstant +abil-select-start-with-hostile+ 0) (defconstant +abil-select-start-with-self+ 1) (defconstant +abil-select-start-with-ally+ 2) (defclass ability-type () ((id :initarg :id :accessor id) (name :initarg :name :accessor name) (descr :initform "" :initarg :descr :accessor descr) (cost :initform 0 :initarg :cost :accessor cost) (spd :initform +normal-ap+ :initarg :spd :accessor spd) (cd :initform 0 :initarg :cd :accessor cd) (motion :initform 0 :initarg :motion :accessor motion) (start-map-select-func :initform nil :initarg :start-map-select-func :accessor start-map-select-func) (passive :initform t :initarg :passive :accessor passive) ;; passive abilities should have their cost set to 0 (on-touch :initform nil :initarg :on-touch :accessor on-touch :type boolean) ;; if the abilities should be invoked, when actor bumps into target (final :initform t :initarg :final :accessor final :type boolean) ;; if the ability is invoked, no further abilities can be invoked (removes-disguise :initform nil :initarg :removes-disguise :accessor removes-disguise :type boolean) ;; if this ability is invoked, the disguise effect is removed (on-invoke :initform nil :initarg :on-invoke :accessor on-invoke) ;; a function that takes three parameters - ability-type, actor and target (on-check-applic :initform nil :initarg :on-check-applic :accessor on-check-applic) ;; a function that takes three parameters - ability type, actor and target (on-kill :initform nil :initarg :on-kill :accessor on-kill :type boolean) ;; if the ability should be invoked when actor kills target (on-check-ai :initform nil :initarg :on-check-ai :accessor on-check-ai) ;; a function that checks for the AI if it can and should invoke the ability now (on-invoke-ai :initform nil :initarg :on-invoke-ai :accessor on-invoke-ai) ;; a function that invokes the ability for the ai (map-select-func :initform nil :initarg :map-select-func :accessor map-select-func) ;; a function that is invoked when the player needs to select the target for the ability, also indicates that this is a targeted ability (obj-select-func :initform nil :initarg :obj-select-func :accessor obj-select-func) ;; a function that is invoked when the player needs to select some other object after choosing this ability (on-add-mutation :initform nil :initarg :on-add-mutation :accessor on-add-mutation) ;; a function that takes two parameters - ability-type, actor (on-remove-mutation :initform nil :initarg :on-remove-mutation :accessor on-remove-mutation) ;; a function that takes two parameters - ability-type, actor )) (defun set-ability-type (ability-type) (when (>= (id ability-type) (length *ability-types*)) (adjust-array *ability-types* (list (1+ (id ability-type))))) (setf (aref *ability-types* (id ability-type)) ability-type)) (defun get-ability-type-by-id (ability-type-id) (aref *ability-types* ability-type-id)) (defun can-invoke-ability (actor target ability-type-id) (if (and (abil-applic-cost-p ability-type-id actor) (abil-applicable-p (get-ability-type-by-id ability-type-id) actor target) (abil-applic-cd-p ability-type-id actor)) t nil)) (defun abil-applic-cost-p (ability-type-id mob) (if (>= (cur-fp mob) (cost (get-ability-type-by-id ability-type-id))) t nil)) (defun abil-applicable-p (ability-type actor target) (if (or (eq (on-check-applic ability-type) nil) (and (on-check-applic ability-type) (funcall (on-check-applic ability-type) ability-type actor target))) t nil)) (defun abil-passive-p (ability-type-id) (passive (get-ability-type-by-id ability-type-id))) (defun abil-on-touch-p (ability-type-id) (on-touch (get-ability-type-by-id ability-type-id))) (defun abil-on-kill-p (ability-type-id) (on-kill (get-ability-type-by-id ability-type-id))) (defun abil-final-p (ability-type-id) (final (get-ability-type-by-id ability-type-id))) (defun abil-spd-p (ability-type-id) (spd (get-ability-type-by-id ability-type-id))) (defun abil-max-cd-p (ability-type-id) (cd (get-ability-type-by-id ability-type-id))) (defun abil-start-map-select-func-p (ability-type-id) (start-map-select-func (get-ability-type-by-id ability-type-id))) (defun abil-cur-cd-p (mob ability-type-id) (if (gethash ability-type-id (abilities-cd mob)) (gethash ability-type-id (abilities-cd mob)) 0)) (defun set-abil-cur-cd (mob ability-type-id value) (setf (gethash ability-type-id (abilities-cd mob)) value)) (defun abil-applic-cd-p (ability-type-id mob) (if (zerop (abil-cur-cd-p mob ability-type-id)) t nil)) (defun abil-motion-p (ability-type-id) (motion (get-ability-type-by-id ability-type-id))) (defun get-mob-all-abilities (mob &key (include-mission-abilities t)) (let ((abilities nil)) (setf abilities (loop for ability-type-id being the hash-key in (abilities mob) when (gethash ability-type-id (abilities mob)) collect ability-type-id)) ;; add mission-type abilities (when (and include-mission-abilities *world* (level *world*) (mission (level *world*))) (setf abilities (append abilities (get-abilities-based-on-faction (faction mob) (mission-type-id (mission (level *world*))))))) abilities)) (defun get-mob-applic-abilities (actor target &key (include-mission-abilities t)) (let ((abilities (get-mob-all-abilities actor :include-mission-abilities include-mission-abilities))) (loop for ability-type-id in abilities when (abil-applicable-p (get-ability-type-by-id ability-type-id) actor target) collect ability-type-id))) (defun copy-hash-table (hash-table) (let ((new-table (make-hash-table))) (loop for key being the hash-key in hash-table using (hash-value value) do (setf (gethash key new-table) value)) new-table))
6,179
Common Lisp
.lisp
101
55.079208
224
0.69589
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
d4f87f9b5a714f27878d43a134d5cbc7c4ba82571cddca6adf516874e1cd5d01
2,846
[ -1 ]
2,847
mobs.lisp
gwathlobal_CotD/src/mobs.lisp
(in-package :cotd) ;;---------------------- ;; MOB-TYPE ;;---------------------- (defclass mob-type () ((glyph-idx :initform 0 :initarg :glyph-idx :accessor glyph-idx :type fixnum) (glyph-color :initform sdl:*white* :initarg :glyph-color :accessor glyph-color :type sdl:color) (back-color :initform sdl:*black* :initarg :back-color :accessor back-color :type sdl:color) (name :initform "No name mob" :initarg :name :accessor name) (faction :initform +faction-type-none+ :initarg :faction :accessor faction) (mob-type :initarg :mob-type :accessor mob-type) (evolve-mob-id :initform nil :initarg :evolve-mob-id :accessor evolve-mob-id) (map-size :initform 1 :initarg :map-size :accessor map-size) ;; can take odd mumbers only, because there should always be a center (max-hp :initform 1 :initarg :max-hp :accessor max-hp) (max-fp :initform 1 :initarg :max-fp :accessor max-fp) (max-ap :initform +normal-ap+ :initarg :max-ap :accessor max-ap) (strength :initform 0 :initarg :strength :accessor strength) ;; relative mob strength for AI to assess its chances (ai-packages :initform (make-hash-table) :accessor ai-packages) ;; The following keys may be used in make-instance ;; :ai-coward - mob will flee if there are enemies in sight ;; :ai-horde - mob will attack only if the relative strength of allies in sight is more than the relative strength of enemies, otherwise it will flee ;; :ai-wants-bless - mob will get to the nearest ally and bless it ;; :ai-stop - mob will stop all movement whenever it see an enemy ;; :ai-curious - mob will try to investigate sounds if it has nothing to do ;; :ai-kleptomaniac - mob will try to collect as much valuable items as possible ;; :ai-cautious - mob will not attack smb of higher strength ;; :ai-simple-pathfinding - mob will not use Astar pathfinding and will move in the general direction towards the target ;; :ai-search-corpses - mob will try to go to the nearest corpse ;; :ai-trinity-mimic ;; :ai-split-soul ;; :ai-swim-up (abilities :initform (make-hash-table) :accessor abilities) ;; The pattern of naming keys that may be used in make-instance is like <name of mob ability constant> minus the 'mob-' part ;; For example, ;; :abil-conceal-divine - +mob-abil-conceal-divine+ ;; Usually the key takes a boolean parameter with the exception of the following cases ;; :abil-heal-self - +mob-abil-heal-self+ (takes fixnum) ;; :abil-can-possess - +mob-abil-can-possess+ (takes fixnum) ;; :abil-momentum - +mob-abil-momentum+ (takes fixnum) ;; :abil-instill-fear - +mob-abil-instill-fear+ (takes fixnum) ;; :abil-heal-other - +mob-abil-heal-other+ (takes fixnum) (weapon :initform nil :initarg :weapon :accessor weapon) ;; of type (<weapon name> (<dmg-type> <dmg min> <dmg max> <attack speed> <accuracy> <list of aux params>) ;; (<dmg-type> <dmg min> <dmg max> <attack speed> <cur charges> <max charges> <rate of fire> <accuracy> <shoot str> <list of aux params>)) ;; <list of aux params> may contain ;; :chops-body-parts ;; :is-fire ;; :constricts ;; :no-charges ;; :corrodes (armor :initform nil :accessor armor) ;; for initarg - ((<dmg-type> <direct-reduct> <%-reduct>) ...), while inside it is an array of lists (base-sight :initform *base-mob-sight* :initarg :base-sight :accessor base-sight) (base-dodge :initform 5 :initarg :base-dodge :accessor base-dodge) (base-armor :initform 0 :initarg :base-armor :accessor base-armor) (move-spd :initform +normal-ap+ :initarg :move-spd :accessor move-spd) (base-light-radius :initform *base-light-radius* :initarg :base-light-radius :accessor base-light-radius) (base-stealth :initform 0 :initarg :base-stealth :accessor base-stealth) (init-items :initform nil :initarg :init-items :accessor init-items) ;; for initarg - ((<item-type-id> <item-qty>) ...) )) (defmethod initialize-instance :after ((mob-type mob-type) &key armor ai-coward ai-horde ai-wants-bless ai-curious ai-takes-valuable-items ai-kleptomaniac ai-cautious ai-trinity-mimic ai-split-soul ai-search-corpses ai-use-ability ai-use-item ai-reload-ranged-weapon ai-shoot-enemy ai-follow-leader ai-approach-target ai-attack-nearest-enemy ai-find-random-location ai-avoid-possession ai-avoid-melee ai-swim-up abil-can-possess abil-possessable abil-purging-touch abil-blessing-touch abil-can-be-blessed abil-unholy abil-heal-self abil-conceal-divine abil-reveal-divine abil-detect-good abil-detect-evil abil-human abil-demon abil-angel abil-see-all abil-lifesteal abil-call-for-help abil-answer-the-call abil-loves-infighting abil-prayer-bless abil-free-call abil-prayer-shield abil-curse abil-keen-senses abil-prayer-reveal abil-military-follow-me abil-blindness abil-instill-fear abil-charge abil-momentum abil-animal abil-horseback-riding abil-horse-can-be-ridden abil-dismount abil-dominate-fiend abil-fiend-can-be-ridden abil-starts-with-horse abil-independent abil-eagle-eye abil-facing abil-immovable abil-mind-burn abil-gargantaur-teleport abil-dominate-gargantaur abil-gargantaurs-mind-burn abil-death-from-above abil-climbing abil-no-breathe abil-open-close-door abil-toggle-light abil-open-close-window abil-can-possess-toggle abil-sacrifice-host abil-reanimate-corpse abil-undead abil-shared-minds abil-ignite-the-fire abil-avatar-of-brilliance abil-empower-undead abil-gravity-chains abil-flying abil-no-corpse abil-smite abil-slow abil-prayer-wrath abil-shadow-step abil-extinguish-light abil-umbral-aura abil-trinity-mimic abil-merge abil-unmerge abil-heal-other abil-righteous-fury abil-pain-link abil-soul-reinforcement abil-silence abil-confuse abil-split-soul abil-restore-soul abil-resurrection abil-sprint abil-jump abil-bend-space abil-cast-shadow abil-cannibalize abil-primordial abil-make-disguise abil-remove-disguise abil-constriction abil-irradiate abil-fission abil-create-parasites abil-mutate-acid-spit abil-acid-spit abil-adrenal-gland abil-mutate-corrosive-bile abil-corrosive-bile abil-mutate-clawed-tentacle abil-clawed-tentacle abil-mutate-chitinous-plating abil-chitinous-plating abil-mutate-metabolic-boost abil-metabolic-boost abil-mutate-retracting-spines abil-retracting-spines abil-spawn-locusts abil-mutate-spawn-locusts abil-mutate-ovipositor abil-oviposit abil-acid-explosion abil-mutate-acid-locusts abil-acid-locusts abil-mutate-fast-scarabs abil-fast-scarabs abil-mutate-oviposit-more-eggs abil-oviposit-more-eggs abil-mutate-tougher-locusts abil-tougher-locusts abil-cure-mutation abil-mutate-thick-carapace abil-thick-carapace abil-mutate-acidic-tips abil-acidic-tips abil-mutate-jump abil-mutate-piercing-needles abil-piercing-needles abil-mutate-corroding-secretion abil-corroding-secretion abil-mutate-accurate-bile abil-accurate-bile abil-mutate-hooks-and-suckers abil-mutate-disguise-as-human abil-disguise-as-human abil-spawn-scarabs abil-mutate-spawn-scarabs abil-mutate-spawn-larva abil-spawn-larva abil-mutate-spore-colony abil-spore-colony abil-immobile abil-float abil-ghost-possess abil-invisibility abil-passwall abil-ghost-release abil-decipher-rune abil-demon-word-flesh abil-demon-word-knockback abil-demon-word-invasion abil-demon-word-darkness abil-demon-word-plague abil-demon-word-power abil-soul abil-detect-unnatural abil-throw-corpse-into-portal abil-throw-relic-into-portal abil-create-demon-sigil abil-skinchange-to-melee abil-skinchange-to-ranged abil-skinchange-to-flyer abil-mutate-skin-ranged-to-turret abil-mutate-charge abil-mutate-explosive-glands abil-mutate-poisoning-glands abil-purge-rune abil-civilian abil-deep-breath abil-nameless abil-strength-in-numbers abil-coward) ;; set up armor (setf (armor mob-type) (make-array (list 7) :initial-element nil)) (loop for (dmg-type dir-resist %-resist) in armor do (setf (aref (armor mob-type) dmg-type) (list dir-resist %-resist))) ;; set up AI prefs (when ai-coward (setf (gethash +ai-package-coward+ (ai-packages mob-type)) t)) (when ai-horde (setf (gethash +ai-package-horde+ (ai-packages mob-type)) t)) (when ai-wants-bless (setf (gethash +ai-package-wants-bless+ (ai-packages mob-type)) t)) (when ai-curious (setf (gethash +ai-package-curious+ (ai-packages mob-type)) t)) (when ai-takes-valuable-items (setf (gethash +ai-package-takes-valuable-items+ (ai-packages mob-type)) t)) (when ai-kleptomaniac (setf (gethash +ai-package-kleptomaniac+ (ai-packages mob-type)) t)) (when ai-cautious (setf (gethash +ai-package-cautious+ (ai-packages mob-type)) t)) (when ai-trinity-mimic (setf (gethash +ai-package-trinity-mimic+ (ai-packages mob-type)) t)) (when ai-split-soul (setf (gethash +ai-package-split-soul+ (ai-packages mob-type)) t)) (when ai-search-corpses (setf (gethash +ai-package-search-corpses+ (ai-packages mob-type)) t)) (when ai-use-ability (setf (gethash +ai-package-use-ability+ (ai-packages mob-type)) t)) (when ai-use-item (setf (gethash +ai-package-use-item+ (ai-packages mob-type)) t)) (when ai-reload-ranged-weapon (setf (gethash +ai-package-reload-ranged-weapon+ (ai-packages mob-type)) t)) (when ai-shoot-enemy (setf (gethash +ai-package-shoot-enemy+ (ai-packages mob-type)) t)) (when ai-follow-leader (setf (gethash +ai-package-follow-leader+ (ai-packages mob-type)) t)) (when ai-approach-target (setf (gethash +ai-package-approach-target+ (ai-packages mob-type)) t)) (when ai-attack-nearest-enemy (setf (gethash +ai-package-attack-nearest-enemy+ (ai-packages mob-type)) t)) (when ai-find-random-location (setf (gethash +ai-package-find-random-location+ (ai-packages mob-type)) t)) (when ai-avoid-possession (setf (gethash +ai-package-avoid-possession+ (ai-packages mob-type)) t)) (when ai-avoid-melee (setf (gethash +ai-package-avoid-melee+ (ai-packages mob-type)) t)) (when ai-swim-up (setf (gethash +ai-package-swim-up+ (ai-packages mob-type)) t)) ;; set up abilities (when abil-can-possess (setf (gethash +mob-abil-can-possess+ (abilities mob-type)) abil-can-possess)) (when abil-possessable (setf (gethash +mob-abil-possessable+ (abilities mob-type)) t)) (when abil-purging-touch (setf (gethash +mob-abil-purging-touch+ (abilities mob-type)) t)) (when abil-blessing-touch (setf (gethash +mob-abil-blessing-touch+ (abilities mob-type)) t)) (when abil-can-be-blessed (setf (gethash +mob-abil-can-be-blessed+ (abilities mob-type)) t)) (when abil-unholy (setf (gethash +mob-abil-unholy+ (abilities mob-type)) t)) (when abil-heal-self (setf (gethash +mob-abil-heal-self+ (abilities mob-type)) abil-heal-self)) (when abil-conceal-divine (setf (gethash +mob-abil-conceal-divine+ (abilities mob-type)) t)) (when abil-reveal-divine (setf (gethash +mob-abil-reveal-divine+ (abilities mob-type)) t)) (when abil-detect-good (setf (gethash +mob-abil-detect-good+ (abilities mob-type)) t)) (when abil-detect-evil (setf (gethash +mob-abil-detect-evil+ (abilities mob-type)) t)) (when abil-human (setf (gethash +mob-abil-human+ (abilities mob-type)) t)) (when abil-angel (setf (gethash +mob-abil-angel+ (abilities mob-type)) t)) (when abil-demon (setf (gethash +mob-abil-demon+ (abilities mob-type)) t)) (when abil-see-all (setf (gethash +mob-abil-see-all+ (abilities mob-type)) t)) (when abil-lifesteal (setf (gethash +mob-abil-lifesteal+ (abilities mob-type)) t)) (when abil-call-for-help (setf (gethash +mob-abil-call-for-help+ (abilities mob-type)) t)) (when abil-answer-the-call (setf (gethash +mob-abil-answer-the-call+ (abilities mob-type)) t)) (when abil-loves-infighting (setf (gethash +mob-abil-loves-infighting+ (abilities mob-type)) t)) (when abil-prayer-bless (setf (gethash +mob-abil-prayer-bless+ (abilities mob-type)) t)) (when abil-free-call (setf (gethash +mob-abil-free-call+ (abilities mob-type)) t)) (when abil-prayer-shield (setf (gethash +mob-abil-prayer-shield+ (abilities mob-type)) t)) (when abil-curse (setf (gethash +mob-abil-curse+ (abilities mob-type)) t)) (when abil-keen-senses (setf (gethash +mob-abil-keen-senses+ (abilities mob-type)) t)) (when abil-prayer-reveal (setf (gethash +mob-abil-prayer-reveal+ (abilities mob-type)) t)) (when abil-military-follow-me (setf (gethash +mob-abil-military-follow-me+ (abilities mob-type)) t)) (when abil-blindness (setf (gethash +mob-abil-blindness+ (abilities mob-type)) t)) (when abil-instill-fear (setf (gethash +mob-abil-instill-fear+ (abilities mob-type)) abil-instill-fear)) (when abil-charge (setf (gethash +mob-abil-charge+ (abilities mob-type)) t)) (when abil-momentum (setf (gethash +mob-abil-momentum+ (abilities mob-type)) abil-momentum)) (when abil-animal (setf (gethash +mob-abil-animal+ (abilities mob-type)) t)) (when abil-horseback-riding (setf (gethash +mob-abil-horseback-riding+ (abilities mob-type)) t)) (when abil-horse-can-be-ridden (setf (gethash +mob-abil-horse-can-be-ridden+ (abilities mob-type)) t)) (when abil-dismount (setf (gethash +mob-abil-dismount+ (abilities mob-type)) t)) (when abil-dominate-fiend (setf (gethash +mob-abil-dominate-fiend+ (abilities mob-type)) t)) (when abil-fiend-can-be-ridden (setf (gethash +mob-abil-fiend-can-be-ridden+ (abilities mob-type)) t)) (when abil-starts-with-horse (setf (gethash +mob-abil-starts-with-horse+ (abilities mob-type)) t)) (when abil-independent (setf (gethash +mob-abil-independent+ (abilities mob-type)) t)) (when abil-eagle-eye (setf (gethash +mob-abil-eagle-eye+ (abilities mob-type)) t)) (when abil-facing (setf (gethash +mob-abil-facing+ (abilities mob-type)) t)) (when abil-immovable (setf (gethash +mob-abil-immovable+ (abilities mob-type)) t)) (when abil-mind-burn (setf (gethash +mob-abil-mind-burn+ (abilities mob-type)) t)) (when abil-gargantaur-teleport (setf (gethash +mob-abil-gargantaur-teleport+ (abilities mob-type)) t)) (when abil-dominate-gargantaur (setf (gethash +mob-abil-dominate-gargantaur+ (abilities mob-type)) t)) (when abil-gargantaurs-mind-burn (setf (gethash +mob-abil-gargantaurs-mind-burn+ (abilities mob-type)) t)) (when abil-death-from-above (setf (gethash +mob-abil-death-from-above+ (abilities mob-type)) t)) (when abil-climbing (setf (gethash +mob-abil-climbing+ (abilities mob-type)) t)) (when abil-no-breathe (setf (gethash +mob-abil-no-breathe+ (abilities mob-type)) t)) (when abil-open-close-door (setf (gethash +mob-abil-open-close-door+ (abilities mob-type)) t)) (when abil-toggle-light (setf (gethash +mob-abil-toggle-light+ (abilities mob-type)) t)) (when abil-open-close-window (setf (gethash +mob-abil-open-close-window+ (abilities mob-type)) t)) (when abil-can-possess-toggle (setf (gethash +mob-abil-can-possess-toggle+ (abilities mob-type)) t)) (when abil-sacrifice-host (setf (gethash +mob-abil-sacrifice-host+ (abilities mob-type)) t)) (when abil-reanimate-corpse (setf (gethash +mob-abil-reanimate-corpse+ (abilities mob-type)) t)) (when abil-undead (setf (gethash +mob-abil-undead+ (abilities mob-type)) t)) (when abil-shared-minds (setf (gethash +mob-abil-shared-minds+ (abilities mob-type)) t)) (when abil-ignite-the-fire (setf (gethash +mob-abil-ignite-the-fire+ (abilities mob-type)) t)) (when abil-avatar-of-brilliance (setf (gethash +mob-abil-avatar-of-brilliance+ (abilities mob-type)) t)) (when abil-empower-undead (setf (gethash +mob-abil-empower-undead+ (abilities mob-type)) t)) (when abil-gravity-chains (setf (gethash +mob-abil-gravity-chains+ (abilities mob-type)) t)) (when abil-flying (setf (gethash +mob-abil-flying+ (abilities mob-type)) t)) (when abil-no-corpse (setf (gethash +mob-abil-no-corpse+ (abilities mob-type)) t)) (when abil-smite (setf (gethash +mob-abil-smite+ (abilities mob-type)) t)) (when abil-slow (setf (gethash +mob-abil-slow+ (abilities mob-type)) t)) (when abil-prayer-wrath (setf (gethash +mob-abil-prayer-wrath+ (abilities mob-type)) t)) (when abil-shadow-step (setf (gethash +mob-abil-shadow-step+ (abilities mob-type)) t)) (when abil-extinguish-light (setf (gethash +mob-abil-extinguish-light+ (abilities mob-type)) t)) (when abil-umbral-aura (setf (gethash +mob-abil-umbral-aura+ (abilities mob-type)) t)) (when abil-trinity-mimic (setf (gethash +mob-abil-trinity-mimic+ (abilities mob-type)) t)) (when abil-merge (setf (gethash +mob-abil-merge+ (abilities mob-type)) t)) (when abil-unmerge (setf (gethash +mob-abil-unmerge+ (abilities mob-type)) t)) (when abil-heal-other (setf (gethash +mob-abil-heal-other+ (abilities mob-type)) abil-heal-other)) (when abil-righteous-fury (setf (gethash +mob-abil-righteous-fury+ (abilities mob-type)) t)) (when abil-pain-link (setf (gethash +mob-abil-pain-link+ (abilities mob-type)) t)) (when abil-soul-reinforcement (setf (gethash +mob-abil-soul-reinforcement+ (abilities mob-type)) t)) (when abil-silence (setf (gethash +mob-abil-silence+ (abilities mob-type)) t)) (when abil-confuse (setf (gethash +mob-abil-confuse+ (abilities mob-type)) t)) (when abil-split-soul (setf (gethash +mob-abil-split-soul+ (abilities mob-type)) t)) (when abil-restore-soul (setf (gethash +mob-abil-restore-soul+ (abilities mob-type)) t)) (when abil-resurrection (setf (gethash +mob-abil-resurrection+ (abilities mob-type)) t)) (when abil-sprint (setf (gethash +mob-abil-sprint+ (abilities mob-type)) t)) (when abil-jump (setf (gethash +mob-abil-jump+ (abilities mob-type)) t)) (when abil-bend-space (setf (gethash +mob-abil-bend-space+ (abilities mob-type)) t)) (when abil-cast-shadow (setf (gethash +mob-abil-cast-shadow+ (abilities mob-type)) t)) (when abil-cannibalize (setf (gethash +mob-abil-cannibalize+ (abilities mob-type)) t)) (when abil-primordial (setf (gethash +mob-abil-primordial+ (abilities mob-type)) t)) (when abil-make-disguise (setf (gethash +mob-abil-make-disguise+ (abilities mob-type)) t)) (when abil-remove-disguise (setf (gethash +mob-abil-remove-disguise+ (abilities mob-type)) t)) (when abil-constriction (setf (gethash +mob-abil-constriction+ (abilities mob-type)) t)) (when abil-irradiate (setf (gethash +mob-abil-irradiate+ (abilities mob-type)) t)) (when abil-fission (setf (gethash +mob-abil-fission+ (abilities mob-type)) t)) (when abil-create-parasites (setf (gethash +mob-abil-create-parasites+ (abilities mob-type)) t)) (when abil-adrenal-gland (setf (gethash +mob-abil-adrenal-gland+ (abilities mob-type)) t)) (when abil-mutate-acid-spit (setf (gethash +mob-abil-mutate-acid-spit+ (abilities mob-type)) t)) (when abil-acid-spit (setf (gethash +mob-abil-acid-spit+ (abilities mob-type)) t)) (when abil-mutate-corrosive-bile (setf (gethash +mob-abil-mutate-corrosive-bile+ (abilities mob-type)) t)) (when abil-corrosive-bile (setf (gethash +mob-abil-corrosive-bile+ (abilities mob-type)) t)) (when abil-mutate-clawed-tentacle (setf (gethash +mob-abil-mutate-clawed-tentacle+ (abilities mob-type)) t)) (when abil-clawed-tentacle (setf (gethash +mob-abil-clawed-tentacle+ (abilities mob-type)) t)) (when abil-mutate-chitinous-plating (setf (gethash +mob-abil-mutate-chitinous-plating+ (abilities mob-type)) t)) (when abil-chitinous-plating (setf (gethash +mob-abil-chitinous-plating+ (abilities mob-type)) t)) (when abil-mutate-metabolic-boost (setf (gethash +mob-abil-mutate-metabolic-boost+ (abilities mob-type)) t)) (when abil-metabolic-boost (setf (gethash +mob-abil-metabolic-boost+ (abilities mob-type)) t)) (when abil-mutate-retracting-spines (setf (gethash +mob-abil-mutate-retracting-spines+ (abilities mob-type)) t)) (when abil-retracting-spines (setf (gethash +mob-abil-retracting-spines+ (abilities mob-type)) t)) (when abil-mutate-spawn-locusts (setf (gethash +mob-abil-mutate-spawn-locusts+ (abilities mob-type)) t)) (when abil-spawn-locusts (setf (gethash +mob-abil-spawn-locusts+ (abilities mob-type)) t)) (when abil-mutate-ovipositor (setf (gethash +mob-abil-mutate-ovipositor+ (abilities mob-type)) t)) (when abil-oviposit (setf (gethash +mob-abil-oviposit+ (abilities mob-type)) t)) (when abil-acid-explosion (setf (gethash +mob-abil-acid-explosion+ (abilities mob-type)) t)) (when abil-mutate-acid-locusts (setf (gethash +mob-abil-mutate-acid-locusts+ (abilities mob-type)) t)) (when abil-acid-locusts (setf (gethash +mob-abil-acid-locusts+ (abilities mob-type)) t)) (when abil-mutate-fast-scarabs (setf (gethash +mob-abil-mutate-fast-scarabs+ (abilities mob-type)) t)) (when abil-fast-scarabs (setf (gethash +mob-abil-fast-scarabs+ (abilities mob-type)) t)) (when abil-mutate-oviposit-more-eggs (setf (gethash +mob-abil-mutate-oviposit-more-eggs+ (abilities mob-type)) t)) (when abil-oviposit-more-eggs (setf (gethash +mob-abil-oviposit-more-eggs+ (abilities mob-type)) t)) (when abil-mutate-tougher-locusts (setf (gethash +mob-abil-mutate-tougher-locusts+ (abilities mob-type)) t)) (when abil-tougher-locusts (setf (gethash +mob-abil-tougher-locusts+ (abilities mob-type)) t)) (when abil-cure-mutation (setf (gethash +mob-abil-cure-mutation+ (abilities mob-type)) t)) (when abil-mutate-thick-carapace (setf (gethash +mob-abil-mutate-thick-carapace+ (abilities mob-type)) t)) (when abil-thick-carapace (setf (gethash +mob-abil-thick-carapace+ (abilities mob-type)) t)) (when abil-mutate-acidic-tips (setf (gethash +mob-abil-mutate-acidic-tips+ (abilities mob-type)) t)) (when abil-acidic-tips (setf (gethash +mob-abil-acidic-tips+ (abilities mob-type)) t)) (when abil-mutate-jump (setf (gethash +mob-abil-mutate-jump+ (abilities mob-type)) t)) (when abil-mutate-piercing-needles (setf (gethash +mob-abil-mutate-piercing-needles+ (abilities mob-type)) t)) (when abil-piercing-needles (setf (gethash +mob-abil-piercing-needles+ (abilities mob-type)) t)) (when abil-mutate-corroding-secretion (setf (gethash +mob-abil-mutate-corroding-secretion+ (abilities mob-type)) t)) (when abil-corroding-secretion (setf (gethash +mob-abil-corroding-secretion+ (abilities mob-type)) t)) (when abil-mutate-accurate-bile (setf (gethash +mob-abil-mutate-accurate-bile+ (abilities mob-type)) t)) (when abil-accurate-bile (setf (gethash +mob-abil-accurate-bile+ (abilities mob-type)) t)) (when abil-mutate-hooks-and-suckers (setf (gethash +mob-abil-mutate-hooks-and-suckers+ (abilities mob-type)) t)) (when abil-mutate-disguise-as-human (setf (gethash +mob-abil-mutate-disguise-as-human+ (abilities mob-type)) t)) (when abil-disguise-as-human (setf (gethash +mob-abil-disguise-as-human+ (abilities mob-type)) t)) (when abil-spawn-scarabs (setf (gethash +mob-abil-spawn-scarabs+ (abilities mob-type)) t)) (when abil-mutate-spawn-scarabs (setf (gethash +mob-abil-mutate-spawn-scarabs+ (abilities mob-type)) t)) (when abil-mutate-spawn-larva (setf (gethash +mob-abil-mutate-spawn-larva+ (abilities mob-type)) t)) (when abil-spawn-larva (setf (gethash +mob-abil-spawn-larva+ (abilities mob-type)) t)) (when abil-mutate-spore-colony (setf (gethash +mob-abil-mutate-spore-colony+ (abilities mob-type)) t)) (when abil-spore-colony (setf (gethash +mob-abil-spore-colony+ (abilities mob-type)) t)) (when abil-immobile (setf (gethash +mob-abil-immobile+ (abilities mob-type)) t)) (when abil-float (setf (gethash +mob-abil-float+ (abilities mob-type)) t)) (when abil-ghost-possess (setf (gethash +mob-abil-ghost-possess+ (abilities mob-type)) t)) (when abil-invisibility (setf (gethash +mob-abil-invisibility+ (abilities mob-type)) t)) (when abil-passwall (setf (gethash +mob-abil-passwall+ (abilities mob-type)) t)) (when abil-ghost-release (setf (gethash +mob-abil-ghost-release+ (abilities mob-type)) t)) (when abil-decipher-rune (setf (gethash +mob-abil-decipher-rune+ (abilities mob-type)) t)) (when abil-demon-word-flesh (setf (gethash +mob-abil-demon-word-flesh+ (abilities mob-type)) t)) (when abil-demon-word-knockback (setf (gethash +mob-abil-demon-word-knockback+ (abilities mob-type)) t)) (when abil-demon-word-invasion (setf (gethash +mob-abil-demon-word-invasion+ (abilities mob-type)) t)) (when abil-demon-word-darkness (setf (gethash +mob-abil-demon-word-darkness+ (abilities mob-type)) t)) (when abil-demon-word-plague (setf (gethash +mob-abil-demon-word-plague+ (abilities mob-type)) t)) (when abil-demon-word-power (setf (gethash +mob-abil-demon-word-power+ (abilities mob-type)) t)) (when abil-soul (setf (gethash +mob-abil-soul+ (abilities mob-type)) t)) (when abil-detect-unnatural (setf (gethash +mob-abil-detect-unnatural+ (abilities mob-type)) t)) (when abil-throw-corpse-into-portal (setf (gethash +mob-abil-throw-corpse-into-portal+ (abilities mob-type)) t)) (when abil-throw-relic-into-portal (setf (gethash +mob-abil-throw-relic-into-portal+ (abilities mob-type)) t)) (when abil-create-demon-sigil (setf (gethash +mob-abil-create-demon-sigil+ (abilities mob-type)) t)) (when abil-skinchange-to-melee (setf (gethash +mob-abil-skinchange-to-melee+ (abilities mob-type)) t)) (when abil-skinchange-to-ranged (setf (gethash +mob-abil-skinchange-to-ranged+ (abilities mob-type)) t)) (when abil-skinchange-to-flyer (setf (gethash +mob-abil-skinchange-to-flyer+ (abilities mob-type)) t)) (when abil-mutate-skin-ranged-to-turret (setf (gethash +mob-abil-mutate-skin-ranged-to-turret+ (abilities mob-type)) t)) (when abil-mutate-charge (setf (gethash +mob-abil-mutate-charge+ (abilities mob-type)) t)) (when abil-mutate-explosive-glands (setf (gethash +mob-abil-mutate-explosive-glands+ (abilities mob-type)) t)) (when abil-mutate-poisoning-glands (setf (gethash +mob-abil-mutate-poisoning-glands+ (abilities mob-type)) t)) (when abil-purge-rune (setf (gethash +mob-abil-purge-rune+ (abilities mob-type)) t)) (when abil-civilian (setf (gethash +mob-abil-civilian+ (abilities mob-type)) t)) (when abil-deep-breath (setf (gethash +mob-abil-deep-breath+ (abilities mob-type)) t)) (when abil-nameless (setf (gethash +mob-abil-nameless+ (abilities mob-type)) t)) (when abil-strength-in-numbers (setf (gethash +mob-abil-strength-in-numbers+ (abilities mob-type)) t)) (when abil-coward (setf (gethash +mob-abil-coward+ (abilities mob-type)) t))) (defun get-mob-type-by-id (mob-type-id) (aref *mob-types* mob-type-id)) (defun set-mob-type (mob-type) (when (>= (mob-type mob-type) (length *mob-types*)) (adjust-array *mob-types* (list (1+ (mob-type mob-type))))) (setf (aref *mob-types* (mob-type mob-type)) mob-type)) (defmethod get-weapon-name ((mob-type mob-type)) (get-weapon-name-simple (weapon mob-type))) (defun get-weapon-name-simple (weapon) (first weapon)) (defmethod is-weapon-melee ((mob-type mob-type)) (is-weapon-melee-simple (weapon mob-type))) (defun is-weapon-melee-simple (weapon) (if (second weapon) t nil)) (defmethod get-melee-weapon-dmg-type ((mob-type mob-type)) (get-melee-weapon-dmg-type-simple (weapon mob-type))) (defun get-melee-weapon-dmg-type-simple (weapon) (when (second weapon) (nth 0 (second weapon)))) (defmethod get-melee-weapon-dmg-min ((mob-type mob-type)) (get-melee-weapon-dmg-min-simple (weapon mob-type))) (defun get-melee-weapon-dmg-min-simple (weapon) (when (second weapon) (nth 1 (second weapon)))) (defmethod get-melee-weapon-dmg-max ((mob-type mob-type)) (get-melee-weapon-dmg-max-simple (weapon mob-type))) (defun get-melee-weapon-dmg-max-simple (weapon) (when (second weapon) (nth 2 (second weapon)))) (defmethod get-melee-weapon-speed ((mob-type mob-type)) (get-melee-weapon-speed-simple (weapon mob-type))) (defun get-melee-weapon-speed-simple (weapon) (when (second weapon) (nth 3 (second weapon)))) (defmethod get-melee-weapon-acc ((mob-type mob-type)) (get-melee-weapon-acc-simple (weapon mob-type))) (defun get-melee-weapon-acc-simple (weapon) (when (second weapon) (nth 4 (second weapon)))) (defmethod get-melee-weapon-aux ((mob-type mob-type)) (get-melee-weapon-aux-simple (weapon mob-type))) (defun get-melee-weapon-aux-simple (weapon) (when (second weapon) (nth 5 (second weapon)))) (defmethod get-melee-weapon-aux-param ((mob-type mob-type) aux-feature) (get-melee-weapon-aux-param-simple (weapon mob-type) aux-feature)) (defun get-melee-weapon-aux-param-simple (weapon aux-feature) (when (second weapon) (find aux-feature (nth 5 (second weapon))))) (defmethod is-weapon-ranged ((mob-type mob-type)) (is-weapon-ranged-simple (weapon mob-type))) (defun is-weapon-ranged-simple (weapon) (if (third weapon) t nil)) (defmethod get-ranged-weapon-dmg-type ((mob-type mob-type)) (get-ranged-weapon-dmg-type-simple (weapon mob-type))) (defun get-ranged-weapon-dmg-type-simple (weapon) (when (third weapon) (nth 0 (third weapon)))) (defmethod get-ranged-weapon-dmg-min ((mob-type mob-type)) (get-ranged-weapon-dmg-min-simple (weapon mob-type))) (defun get-ranged-weapon-dmg-min-simple (weapon) (when (third weapon) (nth 1 (third weapon)))) (defmethod get-ranged-weapon-dmg-max ((mob-type mob-type)) (get-ranged-weapon-dmg-max-simple (weapon mob-type))) (defun get-ranged-weapon-dmg-max-simple (weapon) (when (third weapon) (nth 2 (third weapon)))) (defmethod get-ranged-weapon-speed ((mob-type mob-type)) (get-ranged-weapon-speed-simple (weapon mob-type))) (defun get-ranged-weapon-speed-simple (weapon) (when (third weapon) (nth 3 (third weapon)))) (defmethod get-ranged-weapon-cur-charges ((mob-type mob-type)) (get-ranged-weapon-cur-charges-simple (weapon mob-type))) (defun get-ranged-weapon-cur-charges-simple (weapon) (when (third weapon) (nth 4 (third weapon)))) (defmethod get-ranged-weapon-max-charges ((mob-type mob-type)) (get-ranged-weapon-max-charges-simple (weapon mob-type))) (defun get-ranged-weapon-max-charges-simple (weapon) (when (third weapon) (nth 5 (third weapon)))) (defmethod get-ranged-weapon-rof ((mob-type mob-type)) ;; rate of fire - the number of charges the weapon consumes per shoot (get-ranged-weapon-rof-simple (weapon mob-type))) (defun get-ranged-weapon-rof-simple (weapon) ;; rate of fire - the number of charges the weapon consumes per shoot (when (third weapon) (nth 6 (third weapon)))) (defmethod get-ranged-weapon-acc ((mob-type mob-type)) (get-ranged-weapon-acc-simple (weapon mob-type))) (defun get-ranged-weapon-acc-simple (weapon) (when (third weapon) (nth 7 (third weapon)))) (defmethod get-ranged-weapon-shoot-str ((mob-type mob-type)) (get-ranged-weapon-shoot-str-simple (weapon mob-type))) (defun get-ranged-weapon-shoot-str-simple (weapon) (when (third weapon) (nth 8 (third weapon)))) (defmethod get-ranged-weapon-aux ((mob-type mob-type)) (get-ranged-weapon-aux-simple (weapon mob-type))) (defun get-ranged-weapon-aux-simple (weapon) (when (third weapon) (nth 9 (third weapon)))) (defmethod get-ranged-weapon-aux-param ((mob-type mob-type) aux-feature) (get-ranged-weapon-aux-param-simple (weapon mob-type) aux-feature)) (defun get-ranged-weapon-aux-param-simple (weapon aux-feature) (when (third weapon) (find aux-feature (nth 9 (third weapon))))) (defmethod get-weapon-descr-line ((mob-type mob-type)) (let ((str (create-string))) (format str "~A" (get-weapon-name mob-type)) (when (is-weapon-melee mob-type) (format str "~% M: (dmg: ~A-~A) (spd: ~A) (acc: ~A%)" (get-melee-weapon-dmg-min mob-type) (get-melee-weapon-dmg-max mob-type) (get-melee-weapon-speed mob-type) (get-melee-weapon-acc mob-type))) (when (is-weapon-ranged mob-type) (format str "~% R: (dmg: ~A-~A~A) (spd: ~A) (acc: ~A%)~A" (get-ranged-weapon-dmg-min mob-type) (get-ranged-weapon-dmg-max mob-type) (if (= (get-ranged-weapon-rof mob-type) 1) "" (format nil " x~A" (get-ranged-weapon-rof mob-type))) (get-ranged-weapon-speed mob-type) (get-ranged-weapon-acc mob-type) (if (not (find :no-charges (get-ranged-weapon-aux mob-type))) (format nil " ~A/~A" (get-ranged-weapon-charges mob-type) (get-ranged-weapon-charges mob-type)) ""))) str)) (defmethod get-armor-resist ((mob-type mob-type) dmg-type) (if (aref (armor mob-type) dmg-type) (values (first (aref (armor mob-type) dmg-type)) (second (aref (armor mob-type) dmg-type))) nil)) (defmethod get-armor-d-resist ((mob-type mob-type) dmg-type) (when (aref (armor mob-type) dmg-type) (first (aref (armor mob-type) dmg-type)))) (defmethod get-armor-%-resist ((mob-type mob-type) dmg-type) (when (aref (armor mob-type) dmg-type) (second (aref (armor mob-type) dmg-type)))) (defmethod get-armor-descr ((mob-type mob-type)) (let ((str (create-string))) (format str "Armor:~%") (if (get-armor-resist mob-type +weapon-dmg-flesh+) (format str " Flesh: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-flesh+) (get-armor-%-resist mob-type +weapon-dmg-flesh+)) (format str " Flesh: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-iron+) (format str " Iron: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-iron+) (get-armor-%-resist mob-type +weapon-dmg-iron+)) (format str " Iron: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-fire+) (format str " Fire: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-fire+) (get-armor-%-resist mob-type +weapon-dmg-fire+)) (format str " Fire: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-vorpal+) (format str " Vorpal: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-vorpal+) (get-armor-%-resist mob-type +weapon-dmg-vorpal+)) (format str " Vorpal: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-mind+) (format str " Mind: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-mind+) (get-armor-%-resist mob-type +weapon-dmg-mind+)) (format str " Mind: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-radiation+) (format str " Radiation: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-radiation+) (get-armor-%-resist mob-type +weapon-dmg-radiation+)) (format str " Radiation: 0, 0%~%")) (if (get-armor-resist mob-type +weapon-dmg-acid+) (format str " Acid: ~A, ~A%~%" (get-armor-d-resist mob-type +weapon-dmg-acid+) (get-armor-%-resist mob-type +weapon-dmg-acid+)) (format str " Acid: 0, 0%~%")) str)) ;;---------------------- ;; MOB ;;---------------------- (defclass mob () ((id :initform 0 :initarg :id :accessor id :type fixnum) (name :initform nil :accessor name) (alive-name :initform nil :accessor alive-name) (mob-type :initform 0 :initarg :mob-type :accessor mob-type :type fixnum) (x :initarg :x :initform 0 :accessor x :type fixnum) (y :initarg :y :initform 0 :accessor y :type fixnum) (z :initarg :z :initform 0 :accessor z :type fixnum) (dead= :initform nil :accessor dead=) (cur-ap :initform +normal-ap+ :accessor cur-ap :type fixnum) (made-turn :initform nil :accessor made-turn) (cur-hp :initform 0 :initarg :cur-hp :accessor cur-hp) (max-hp :initform 0 :accessor max-hp) (cur-fp :initform 0 :initarg :cur-fp :accessor cur-fp) (worshiped-god :initform nil :initarg :worshiped-god :accessor worshiped-god) ;; when the mob worships a god, this param is (<god id> <piety> <param1>) ;; for Malseraph, param1 - danger level at the end of the previous turn, param2 - cooldown for decreaseing danger level (visible-mobs :initform nil :accessor visible-mobs) (shared-visible-mobs :initform nil :accessor shared-visible-mobs) (proper-visible-mobs :initform nil :accessor proper-visible-mobs) (hear-range-mobs :initform nil :accessor hear-range-mobs) (heard-sounds :initform nil :accessor heard-sounds) (visible-items :initform nil :accessor visible-items) (sense-evil-id :initform nil :accessor sense-evil-id) (sense-good-id :initform nil :accessor sense-good-id) ;; special vars for trinity mimics (mimic-id-list :initform () :accessor mimic-id-list) (merged-id-list :initform () :accessor merged-id-list) (is-merged :initform nil :accessor is-merged) (path :initform nil :accessor path) (path-dst :initform nil :accessor path-dst) ;; is a actually a cons with coords (x y) (momentum-spd :initform 0 :accessor momentum-spd) (momentum-dir :initform (cons 0 0) :accessor momentum-dir) (order :initform nil :accessor order) (objectives :initform nil :initarg :objectives :accessor objectives) (memory-map :initform nil :initarg :memory-map :accessor memory-map) (riding-mob-id :initform nil :accessor riding-mob-id) ;; mob is riding this mob-id (mounted-by-mob-id :initform nil :accessor mounted-by-mob-id) ;; mob is being ridden by this mob-id (order-for-next-turn :initform nil :accessor order-for-next-turn) ;; the order for mounts where to move next turn, type fixnum (direction) (master-mob-id :initform nil :accessor master-mob-id) ;; mob that controls this mob (slave-mob-id :initform nil :accessor slave-mob-id) ;; mob that is being controlled by this mob (face-mob-type-id :initform nil :accessor face-mob-type-id) ;; others see this mob as this mob type (loyal-faction :initform +faction-type-none+ :accessor loyal-faction) (effects :initform (make-hash-table) :accessor effects) (abilities-cd :initform (make-hash-table) :accessor abilities-cd) (abilities :initform (make-hash-table) :accessor abilities) ;; each value is (<is mutation t/nil> <power level>) (weapon :initform nil :initarg :weapon :accessor weapon) ;; of type (<weapon name> (<dmg-type> <dmg min> <dmg max> <attack speed> <accuracy> <list of aux params>) ;; (<dmg-type> <dmg min> <dmg max> <attack speed> <cur charges> <max charges> <rate of fire> <accuracy> <shoot str> <list of aux params>)) ;; <list of aux params> may contain ;; :chops-body-parts ;; :is-fire ;; :constricts ;; :no-charges (cur-sight :initform 6 :initarg :cur-sight :accessor cur-sight) (m-acc :initform +base-accuracy+ :initarg :m-acc :accessor m-acc) (r-acc :initform +base-accuracy+ :initarg :r-acc :accessor r-acc) (cur-dodge :initform 5 :initarg :cur-dodge :accessor cur-dodge) (armor :initform nil :initarg :armor :accessor armor) (cur-speed :initform 100 :initarg :cur-speed :accessor cur-speed) (cur-move-speed :initform 100 :initarg :cur-move-speed :accessor cur-move-speed) (brightness :initform 0 :accessor brightness) (darkness :initform 0 :accessor darkness) (cur-light :initform *base-light-radius* :initarg :cur-light :accessor cur-light) (motion :initform 0 :accessor motion) (motion-set-p :initform nil :accessor motion-set-p) (cur-stealth :initform 0 :accessor cur-stealth) (cur-oxygen :initform *max-oxygen-level* :accessor cur-oxygen) (stat-kills :initform (make-hash-table) :accessor stat-kills) (stat-blesses :initform 0 :accessor stat-blesses) (stat-calls :initform 0 :accessor stat-calls) (stat-answers :initform 0 :accessor stat-answers) (stat-gold :initform 0 :accessor stat-gold) (stat-possess :initform 0 :accessor stat-possess) (stat-raised-dead :initform 0 :accessor stat-raised-dead) (stat-corpses-thrown :initform 0 :accessor stat-corpses-thrown) (inv :initform () :accessor inv) (initial-added :initform nil :accessor initial-added) )) (defmethod initialize-instance :after ((mob mob) &key) (setf (id mob) (find-free-id *mobs*)) (setf (aref *mobs* (id mob)) mob) (setf (max-hp mob) (max-hp (get-mob-type-by-id (mob-type mob)))) (setf (cur-hp mob) (max-hp mob)) (setf (cur-fp mob) 0) (setf (cur-ap mob) (max-ap mob)) (when (or (= (mob-type mob) +mob-type-eater-of-the-dead+) (= (mob-type mob) +mob-type-skinchanger-melee+) (= (mob-type mob) +mob-type-skinchanger-ranged+) (= (mob-type mob) +mob-type-skinchanger-flyer+)) (setf (cur-fp mob) 2)) (setf (face-mob-type-id mob) (mob-type mob)) (when (and *world* (level *world*)) (setf (memory-map mob) (make-array (list (ceiling (array-dimension (terrain (level *world*)) 0) 10) (ceiling (array-dimension (terrain (level *world*)) 1) 10)) :initial-element -1))) (adjust-abilities mob) ;; when starting with a horse - create a horse on the spot and mount it (when (mob-ability-p mob +mob-abil-starts-with-horse+) (let ((horse (make-instance 'mob :mob-type +mob-type-horse+ :x (x mob) :y (y mob) :z (z mob)))) (setf (mounted-by-mob-id horse) (id mob)) (setf (riding-mob-id mob) (id horse)))) (loop for (item-type-id qty-func) in (init-items (get-mob-type-by-id (mob-type mob))) for qty = (funcall qty-func) when (not (zerop qty)) do (mob-pick-item mob (make-instance 'item :item-type item-type-id :x (x mob) :y (y mob) :z (z mob) :qty qty) :spd nil :silent t)) ;; add permanent flying effect, if the mob can fly (when (mob-ability-p mob +mob-abil-flying+) (set-mob-effect mob :effect-type-id +mob-effect-flying+ :actor-id (id mob))) (setf (loyal-faction mob) (faction (get-mob-type-by-id (mob-type mob)))) (set-cur-weapons mob) (adjust-dodge mob) (adjust-armor mob) (adjust-m-acc mob) (adjust-r-acc mob) (adjust-sight mob) ;; setting up name (set-name mob) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities mob) do (setf (gethash ability-id (abilities-cd mob)) 0)) ;; if the mob has climbing ability - start with it turned on (when (mob-ability-p mob +mob-abil-climbing+) (set-mob-effect mob :effect-type-id +mob-effect-climbing-mode+ :actor-id (id mob) :cd t)) ;; if the mob is Malseraph's puppet - automatically worship Malseraph (when (= (mob-type mob) +mob-type-malseraph-puppet+) (set-mob-worshiped-god mob :god-id +god-entity-malseraph+ :init-piety 150 :param1 0 :param2 0)) ) (defun get-mob-by-id (mob-id) (aref *mobs* mob-id)) (defmethod faction ((mob mob)) (faction (get-mob-type-by-id (mob-type mob)))) (defmethod max-fp ((mob mob)) (max-fp (get-mob-type-by-id (mob-type mob)))) (defmethod max-ap ((mob mob)) (max-ap (get-mob-type-by-id (mob-type mob)))) (defmethod base-sight ((mob mob)) (base-sight (get-mob-type-by-id (mob-type mob)))) (defmethod base-light-radius ((mob mob)) (base-light-radius (get-mob-type-by-id (mob-type mob)))) (defmethod base-stealth ((mob mob)) (base-stealth (get-mob-type-by-id (mob-type mob)))) (defmethod strength ((mob mob)) (strength (get-mob-type-by-id (mob-type mob)))) (defmethod evolve-into ((mob mob)) (evolve-mob-id (get-mob-type-by-id (mob-type mob)))) (defmethod ai-packages ((mob mob)) (ai-packages (get-mob-type-by-id (mob-type mob)))) (defun mob-get-ai-package (mob ai-package-id) (gethash ai-package-id (ai-packages mob))) (defun mob-effect-p (mob effect-type-id) (gethash effect-type-id (effects mob))) (defun mob-ability-p (mob ability-type-id) (if (or (gethash ability-type-id (abilities mob)) (and *world* (level *world*) (mission (level *world*)) (find ability-type-id (get-abilities-based-on-faction (faction mob) (mission-type-id (mission (level *world*))))))) t nil)) (defun mob-is-ability-mutation (mob ability-type-id) (if (and (gethash ability-type-id (abilities mob)) (first (gethash ability-type-id (abilities mob)))) t nil)) (defun mob-is-ability-mission (mob ability-type-id) (if (and *world* (level *world*) (mission (level *world*)) (find ability-type-id (get-abilities-based-on-faction (faction mob) (mission-type-id (mission (level *world*)))))) t nil)) (defun mob-ability-value (mob ability-type-id) (if (gethash ability-type-id (abilities mob)) (second (gethash ability-type-id (abilities mob))) nil)) (defun mob-set-mutation (mob ability-type-id &optional (ability-value t)) (let ((has-function nil)) (when (and (null (gethash ability-type-id (abilities mob))) (on-add-mutation (get-ability-type-by-id ability-type-id))) (setf has-function t)) (setf (gethash ability-type-id (abilities mob)) (list t ability-value)) (when has-function (funcall (on-add-mutation (get-ability-type-by-id ability-type-id)) (get-ability-type-by-id ability-type-id) mob)))) (defun mob-remove-mutation (mob ability-type-id) (when (and (on-remove-mutation (get-ability-type-by-id ability-type-id))) (funcall (on-remove-mutation (get-ability-type-by-id ability-type-id)) (get-ability-type-by-id ability-type-id) mob)) (setf (gethash ability-type-id (abilities mob)) nil) ;; place a non-mutation ability if there is one (when (gethash ability-type-id (abilities (get-mob-type-by-id (mob-type mob)))) (setf (gethash ability-type-id (abilities mob)) (list nil (gethash ability-type-id (abilities (get-mob-type-by-id (mob-type mob)))))))) (defun mob-set-ability (mob ability-type-id &optional (ability-value t)) (let ((has-function nil)) (when (and (null (gethash ability-type-id (abilities mob))) (on-add-mutation (get-ability-type-by-id ability-type-id))) (setf has-function t)) (setf (gethash ability-type-id (abilities mob)) (list nil ability-value)) (when has-function (funcall (on-add-mutation (get-ability-type-by-id ability-type-id)) (get-ability-type-by-id ability-type-id) mob)))) (defun mob-remove-ability (mob ability-type-id) (when (and (on-remove-mutation (get-ability-type-by-id ability-type-id))) (funcall (on-remove-mutation (get-ability-type-by-id ability-type-id)) (get-ability-type-by-id ability-type-id) mob)) (setf (gethash ability-type-id (abilities mob)) nil)) (defun set-mob-effect (mob &key effect-type-id actor-id (cd t) (param1 nil)) (if (mob-effect-p mob effect-type-id) (progn (setf (cd (get-effect-by-id (mob-effect-p mob effect-type-id))) cd) (setf (actor-id (get-effect-by-id (mob-effect-p mob effect-type-id))) actor-id)) (progn (let ((effect (make-instance 'effect :effect-type effect-type-id :actor-id actor-id :target-id (id mob) :cd cd :param1 param1))) (setf (gethash (effect-type effect) (effects mob)) (id effect)) (funcall (on-add (get-effect-type-by-id (effect-type effect))) effect mob)))) ) (defun rem-mob-effect (mob effect-type-id) (when (mob-effect-p mob effect-type-id) (let ((effect (get-effect-by-id (mob-effect-p mob effect-type-id)))) (funcall (on-remove (get-effect-type-by-id effect-type-id)) effect mob) (rem-mob-effect-simple mob effect-type-id)))) (defun rem-mob-effect-simple (mob effect-type-id) (when (mob-effect-p mob effect-type-id) (let ((effect (get-effect-by-id (mob-effect-p mob effect-type-id)))) (remove-effect-from-world effect) (remhash effect-type-id (effects mob))))) (defmethod name ((mob mob)) (if (slot-value mob 'name) (values (slot-value mob 'name) +noun-proper+ +noun-singular+) (values (name (get-mob-type-by-id (mob-type mob))) +noun-common+ +noun-singular+))) (defmethod alive-name ((mob mob)) (if (slot-value mob 'alive-name) (values (slot-value mob 'alive-name) +noun-proper+ +noun-singular+) (values (name (get-mob-type-by-id (mob-type mob))) +noun-common+ +noun-singular+))) (defmethod visible-name ((mob mob)) (when (and (not (eq *player* mob)) (or ;(mob-effect-p *player* +mob-effect-blind+) (not (check-mob-visible mob :observer *player*)))) (return-from visible-name (values "somebody" +noun-proper+ +noun-singular+))) (when (= (faction *player*) (faction mob)) (return-from visible-name (name mob))) (if (or (= (face-mob-type-id mob) (mob-type mob)) (mob-effect-p mob +mob-effect-reveal-true-form+)) (name mob) (values (name (get-mob-type-by-id (face-mob-type-id mob))) +noun-common+ +noun-singular+))) (defmethod set-cur-weapons ((mob mob)) (when (weapon (get-mob-type-by-id (mob-type mob))) (setf (weapon mob) (copy-list (weapon (get-mob-type-by-id (mob-type mob))))) (setf (second (weapon mob)) (copy-list (second (weapon (get-mob-type-by-id (mob-type mob)))))) (setf (third (weapon mob)) (copy-list (third (weapon (get-mob-type-by-id (mob-type mob)))))))) (defun adjust-abilities (mob) ;; clear all previous non-mutation abilities (loop for ability-type-id in (get-mob-all-abilities mob) when (not (mob-is-ability-mutation mob ability-type-id)) do (setf (gethash ability-type-id (abilities mob)) nil)) ;; set new abilities from mob-type if no corresponding mutation is there (loop for ability-type-id being the hash-key in (abilities (get-mob-type-by-id (mob-type mob))) using (hash-value ability-value) when (not (mob-is-ability-mutation mob ability-type-id)) do (setf (gethash ability-type-id (abilities mob)) (list nil ability-value)))) (defun adjust-sight (mob) (let ((light (base-light-radius mob))) (when (mob-effect-p mob +mob-effect-extinguished-light+) (setf light 0)) (when (mob-ability-p mob +mob-abil-casts-light+) (setf light 6)) (setf (cur-light mob) light)) (let ((sight (base-sight mob))) (when (mob-effect-p mob +mob-effect-blind+) (setf sight 0)) (setf (cur-sight mob) sight))) (defun adjust-dodge (mob) (let ((dodge 0)) (setf dodge (base-dodge (get-mob-type-by-id (mob-type mob)))) (when (mob-effect-p mob +mob-effect-metabolic-boost+) (incf dodge 50)) (when (and (mob-effect-p mob +mob-effect-constriction-target+) (mob-ability-p (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p mob +mob-effect-constriction-target+)))) +mob-abil-piercing-needles+)) (decf dodge 40)) ;; when riding - your dodge chance is reduced to zero (when (riding-mob-id mob) (setf dodge 0)) (when (< dodge 0) (setf dodge 0)) (setf (cur-dodge mob) dodge))) (defun adjust-armor (mob) (let ((stealth (base-stealth mob))) (setf (cur-stealth mob) stealth)) (let ((armor (make-array (list (length (armor (get-mob-type-by-id (mob-type mob))))) :initial-element nil))) (loop for armor-type across (armor (get-mob-type-by-id (mob-type mob))) for i from 0 do (setf (aref armor i) (copy-list armor-type))) (setf (armor mob) armor) (when (mob-effect-p mob +mob-effect-wet+) (set-armor-%-resist mob +weapon-dmg-fire+ (+ (get-armor-%-resist mob +weapon-dmg-fire+) 25))) (when (mob-ability-p mob +mob-abil-chitinous-plating+) (set-armor-d-resist mob +weapon-dmg-flesh+ (+ (get-armor-d-resist mob +weapon-dmg-flesh+) 2)) (set-armor-d-resist mob +weapon-dmg-fire+ (+ (get-armor-d-resist mob +weapon-dmg-fire+) 2)) (set-armor-d-resist mob +weapon-dmg-iron+ (+ (get-armor-d-resist mob +weapon-dmg-iron+) 2)) (set-armor-d-resist mob +weapon-dmg-vorpal+ (+ (get-armor-d-resist mob +weapon-dmg-vorpal+) 2)) (set-armor-d-resist mob +weapon-dmg-acid+ (+ (get-armor-d-resist mob +weapon-dmg-acid+) 2))) (when (mob-ability-p mob +mob-abil-thick-carapace+) (set-armor-d-resist mob +weapon-dmg-flesh+ (+ (get-armor-d-resist mob +weapon-dmg-flesh+) 1)) (set-armor-d-resist mob +weapon-dmg-fire+ (+ (get-armor-d-resist mob +weapon-dmg-fire+) 1)) (set-armor-d-resist mob +weapon-dmg-iron+ (+ (get-armor-d-resist mob +weapon-dmg-iron+) 1)) (set-armor-d-resist mob +weapon-dmg-vorpal+ (+ (get-armor-d-resist mob +weapon-dmg-vorpal+) 1)) (set-armor-d-resist mob +weapon-dmg-acid+ (+ (get-armor-d-resist mob +weapon-dmg-acid+) 1))) (when (mob-effect-p mob +mob-effect-spines+) (set-armor-%-resist mob +weapon-dmg-flesh+ (+ (get-armor-%-resist mob +weapon-dmg-flesh+) 40)) (set-armor-%-resist mob +weapon-dmg-fire+ (+ (get-armor-%-resist mob +weapon-dmg-fire+) 40)) (set-armor-%-resist mob +weapon-dmg-iron+ (+ (get-armor-%-resist mob +weapon-dmg-iron+) 40)) (set-armor-%-resist mob +weapon-dmg-vorpal+ (+ (get-armor-%-resist mob +weapon-dmg-vorpal+) 40)) (set-armor-%-resist mob +weapon-dmg-acid+ (+ (get-armor-%-resist mob +weapon-dmg-acid+) 40))) (when (mob-ability-p mob +mob-abil-vulnerable-to-vorpal+) (set-armor-d-resist mob +weapon-dmg-vorpal+ (- (get-armor-d-resist mob +weapon-dmg-vorpal+) 2))) (when (mob-ability-p mob +mob-abil-vulnerable-to-fire+) (set-armor-d-resist mob +weapon-dmg-fire+ (- (get-armor-d-resist mob +weapon-dmg-fire+) 2))) (when (mob-effect-p mob +mob-effect-parasite+) (set-armor-d-resist mob +weapon-dmg-flesh+ (- (get-armor-d-resist mob +weapon-dmg-flesh+) 1)) (set-armor-d-resist mob +weapon-dmg-acid+ (- (get-armor-d-resist mob +weapon-dmg-acid+) 1))) (when (mob-effect-p mob +mob-effect-corroded+) (set-armor-d-resist mob +weapon-dmg-flesh+ (- (get-armor-d-resist mob +weapon-dmg-flesh+) 1)) (set-armor-d-resist mob +weapon-dmg-acid+ (- (get-armor-d-resist mob +weapon-dmg-acid+) 1))) (when (mob-effect-p mob +mob-effect-reduce-resitances+) (loop for dmg-type in (list +weapon-dmg-flesh+ +weapon-dmg-iron+ +weapon-dmg-fire+ +weapon-dmg-vorpal+ +weapon-dmg-mind+ +weapon-dmg-radiation+ +weapon-dmg-acid+) when (> (get-armor-d-resist mob dmg-type) 0) do (set-armor-d-resist mob dmg-type 0) when (> (get-armor-%-resist mob dmg-type) -50) do (set-armor-%-resist mob dmg-type -50)) ) )) (defun adjust-m-acc (mob) (setf (m-acc mob) 0) (unless (is-weapon-melee mob) (return-from adjust-m-acc 0)) (let ((accuracy (get-melee-weapon-acc mob))) (when (mob-effect-p mob +mob-effect-cursed+) (setf accuracy 75)) (setf (m-acc mob) accuracy))) (defun adjust-r-acc (mob) (setf (r-acc mob) 0) (unless (is-weapon-ranged mob) (return-from adjust-r-acc 0)) (let ((accuracy (get-ranged-weapon-acc mob))) (when (mob-effect-p mob +mob-effect-cursed+) (decf accuracy 25)) (when (riding-mob-id mob) (decf accuracy 20)) (when (< accuracy 0) (setf accuracy 0)) (setf (r-acc mob) accuracy))) (defun adjust-speed (mob) (let ((speed 100)) (when (mob-effect-p mob +mob-effect-metabolic-boost+) (decf speed 30)) (when (mob-effect-p mob +mob-effect-slow+) (incf speed 50)) (when (<= speed 10) (setf speed 10)) (setf (cur-speed mob) speed))) (defmethod get-weapon-name ((mob mob)) (get-weapon-name-simple (weapon mob))) (defmethod is-weapon-melee ((mob mob)) (is-weapon-melee-simple (weapon mob))) (defmethod get-melee-weapon-dmg-type ((mob mob)) (get-melee-weapon-dmg-type-simple (weapon mob))) (defmethod get-melee-weapon-dmg-min ((mob mob)) (get-melee-weapon-dmg-min-simple (weapon mob))) (defmethod get-melee-weapon-dmg-max ((mob mob)) (get-melee-weapon-dmg-max-simple (weapon mob))) (defmethod get-melee-weapon-speed ((mob mob)) (get-melee-weapon-speed-simple (weapon mob))) (defmethod get-melee-weapon-acc ((mob mob)) (get-melee-weapon-acc-simple (weapon mob))) (defmethod get-melee-weapon-aux ((mob mob)) (get-melee-weapon-aux-simple (weapon mob))) (defmethod get-melee-weapon-aux-param ((mob mob) aux-feature) (get-melee-weapon-aux-param-simple (weapon mob) aux-feature)) (defmethod is-weapon-ranged ((mob mob)) (is-weapon-ranged-simple (weapon mob))) (defmethod get-ranged-weapon-dmg-type ((mob mob)) (get-ranged-weapon-dmg-type-simple (weapon mob))) (defmethod get-ranged-weapon-dmg-min ((mob mob)) (get-ranged-weapon-dmg-min-simple (weapon mob))) (defmethod get-ranged-weapon-dmg-max ((mob mob)) (get-ranged-weapon-dmg-max-simple (weapon mob))) (defmethod get-ranged-weapon-speed ((mob mob)) (get-ranged-weapon-speed-simple (weapon mob))) (defmethod get-ranged-weapon-charges ((mob mob)) (get-ranged-weapon-cur-charges-simple (weapon mob))) (defun set-ranged-weapon-charges (mob value) (when (third (weapon mob)) (setf (nth 4 (third (weapon mob))) value))) (defmethod get-ranged-weapon-max-charges ((mob mob)) (get-ranged-weapon-max-charges-simple (weapon mob))) (defmethod get-ranged-weapon-rof ((mob mob)) (get-ranged-weapon-rof-simple (weapon mob))) (defmethod get-ranged-weapon-acc ((mob mob)) (get-ranged-weapon-acc-simple (weapon mob))) (defmethod get-ranged-weapon-shoot-str ((mob mob)) (get-ranged-weapon-shoot-str-simple (weapon mob))) (defmethod get-ranged-weapon-aux ((mob mob)) (get-ranged-weapon-aux-simple (weapon mob))) (defmethod get-ranged-weapon-aux-param ((mob mob) aux-feature) (get-ranged-weapon-aux-param-simple (weapon mob) aux-feature)) (defmethod get-weapon-descr-line ((mob mob)) (let ((str (create-string))) (when (weapon mob) (format str "~A" (get-weapon-name mob)) (when (is-weapon-melee mob) (format str "~% M: (d: ~A-~A) (s: ~A) (a: ~A%)" (get-melee-weapon-dmg-min mob) (get-melee-weapon-dmg-max mob) (get-melee-weapon-speed mob) (get-melee-weapon-acc mob))) (when (is-weapon-ranged mob) (format str "~% R: (d: ~A-~A~A) (s: ~A) (a: ~A%)~A" (get-ranged-weapon-dmg-min mob) (get-ranged-weapon-dmg-max mob) (if (= (get-ranged-weapon-rof mob) 1) "" (format nil " x~A" (get-ranged-weapon-rof mob))) (get-ranged-weapon-speed mob) (get-ranged-weapon-acc mob) (if (not (find :no-charges (get-ranged-weapon-aux mob))) (format nil " ~A/~A" (get-ranged-weapon-charges mob) (get-ranged-weapon-max-charges mob)) "")))) str)) (defun get-dmg-type-name (dmg-type) (cond ((= dmg-type +weapon-dmg-flesh+) (format nil "Flesh")) ((= dmg-type +weapon-dmg-fire+) (format nil "Fire")) ((= dmg-type +weapon-dmg-iron+) (format nil "Iron")) ((= dmg-type +weapon-dmg-vorpal+) (format nil "Vorpal")) ((= dmg-type +weapon-dmg-mind+) (format nil "Mind")) ((= dmg-type +weapon-dmg-radiation+) (format nil "Radiation")) ((= dmg-type +weapon-dmg-acid+) (format nil "Acid")))) (defmethod get-weapon-descr-long ((mob mob)) (let ((str (create-string))) (format str "~A" (get-weapon-name mob)) (when (is-weapon-melee mob) (format str "~% M: (dmg: ~A, ~A-~A) (spd: ~A) (acc: ~A%)" (get-dmg-type-name (get-melee-weapon-dmg-type mob)) (get-melee-weapon-dmg-min mob) (get-melee-weapon-dmg-max mob) (get-melee-weapon-speed mob) (get-melee-weapon-acc mob))) (when (is-weapon-ranged mob) (format str "~% R: (dmg: ~A, ~A-~A~A) (spd: ~A) (acc: ~A%)~A" (get-dmg-type-name (get-ranged-weapon-dmg-type mob)) (get-ranged-weapon-dmg-min mob) (get-ranged-weapon-dmg-max mob) (if (= (get-ranged-weapon-rof mob) 1) "" (format nil " x~A" (get-ranged-weapon-rof mob))) (get-ranged-weapon-speed mob) (get-ranged-weapon-acc mob) (if (not (find :no-charges (get-ranged-weapon-aux mob))) (format nil " ~A/~A" (get-ranged-weapon-charges mob) (get-ranged-weapon-max-charges mob)) ""))) str)) (defmethod get-armor-resist ((mob mob) dmg-type) (if (aref (armor mob) dmg-type) (values (first (aref (armor mob) dmg-type)) (second (aref (armor mob) dmg-type))) nil)) (defmethod get-armor-d-resist ((mob mob) dmg-type) (if (aref (armor mob) dmg-type) (first (aref (armor mob) dmg-type)) 0)) (defmethod get-armor-%-resist ((mob mob) dmg-type) (if (aref (armor mob) dmg-type) (second (aref (armor mob) dmg-type)) 0)) (defun set-armor-d-resist (mob dmg-type value) (if (aref (armor mob) dmg-type) (setf (first (aref (armor mob) dmg-type)) value) (setf (aref (armor mob) dmg-type) (list value 0)))) (defun set-armor-%-resist (mob dmg-type value) (if (aref (armor mob) dmg-type) (setf (second (aref (armor mob) dmg-type)) value) (setf (aref (armor mob) dmg-type) (list 0 value)))) (defmethod get-armor-descr ((mob mob)) (let ((str (create-string))) (format str "Armor:~%") (if (get-armor-resist mob +weapon-dmg-flesh+) (format str " Flesh: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-flesh+) (get-armor-%-resist mob +weapon-dmg-flesh+)) (format str " Flesh: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-iron+) (format str " Iron: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-iron+) (get-armor-%-resist mob +weapon-dmg-iron+)) (format str " Iron: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-fire+) (format str " Fire: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-fire+) (get-armor-%-resist mob +weapon-dmg-fire+)) (format str " Fire: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-vorpal+) (format str " Vorpal: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-vorpal+) (get-armor-%-resist mob +weapon-dmg-vorpal+)) (format str " Vorpal: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-mind+) (format str " Mind: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-mind+) (get-armor-%-resist mob +weapon-dmg-mind+)) (format str " Mind: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-radiation+) (format str " Radiation: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-radiation+) (get-armor-%-resist mob +weapon-dmg-radiation+)) (format str " Radiation: 0, 0%~%")) (if (get-armor-resist mob +weapon-dmg-acid+) (format str " Acid: ~A, ~A%~%" (get-armor-d-resist mob +weapon-dmg-acid+) (get-armor-%-resist mob +weapon-dmg-acid+)) (format str " Acid: 0, 0%~%")) str)) (defmethod calculate-total-kills ((mob mob)) (loop for killed-mob-stat being the hash-value in (stat-kills mob) sum killed-mob-stat)) (defmethod calculate-total-friendly-kills ((mob mob)) (loop for killed-mob-stat being the hash-value in (stat-kills mob) using (hash-key killed-mob-id) when (get-faction-relation (faction mob) (faction (get-mob-type-by-id killed-mob-id))) sum killed-mob-stat)) (defmethod get-qualified-name ((mob mob)) (if (slot-value mob 'name) (if (and (mob-ability-p mob +mob-abil-undead+) (not (eq mob *player*))) (values (name mob) +noun-proper+ +noun-singular+) (values (format nil "~A the ~A" (name mob) (capitalize-name (name (get-mob-type-by-id (mob-type mob))))) +noun-proper+ +noun-singular+)) (values (format nil "nameless ~A" (name mob)) +noun-common+ +noun-singular+))) (defun set-name (mob) (when (or (eq mob *player*) (mob-ability-p mob +mob-abil-nameless+)) ;; nameless creatures have no name (return-from set-name nil)) (let ((name-pick-n) (surname-pick-n)) (cond ((mob-ability-p mob +mob-abil-angel+) (progn (unless *cur-angel-names* (return-from set-name nil)) (setf name-pick-n (random (length *cur-angel-names*))) (setf (name mob) (nth name-pick-n *cur-angel-names*)) (setf *cur-angel-names* (remove (nth name-pick-n *cur-angel-names*) *cur-angel-names*)))) ((mob-ability-p mob +mob-abil-demon+) (progn (unless *cur-demon-names* (return-from set-name nil)) (setf name-pick-n (random (length *cur-demon-names*))) (setf (name mob) (nth name-pick-n *cur-demon-names*)) (setf *cur-demon-names* (remove (nth name-pick-n *cur-demon-names*) *cur-demon-names*)))) ((or (eq (mob-type mob) +mob-type-satanist+) (eq (mob-type mob) +mob-type-priest+)) (progn (unless *cur-human-names* (return-from set-name nil)) (unless *cur-human-surnames* (return-from set-name nil)) (setf name-pick-n (random (length *cur-human-names*))) (setf surname-pick-n (random (length *cur-human-surnames*))) (setf (name mob) (format nil "~A ~A" (nth name-pick-n *cur-human-names*) (nth surname-pick-n *cur-human-surnames*))) (setf *cur-human-names* (remove (nth name-pick-n *cur-human-names*) *cur-human-names*)) (setf *cur-human-surnames* (remove (nth surname-pick-n *cur-human-surnames*) *cur-human-surnames*)))))) (setf (alive-name mob) (name mob))) (defun get-followers-list (mob) (loop for mob-id in (visible-mobs mob) for follower = (get-mob-by-id mob-id) when (and (order follower) (= (first (order follower)) +mob-order-follow+) (= (second (order follower)) (id mob))) collect mob-id)) (defun count-follower-list (mob) (loop for mob-id in (visible-mobs mob) for follower = (get-mob-by-id mob-id) when (and (order follower) (= (first (order follower)) +mob-order-follow+) (= (second (order follower)) (id mob))) count follower)) (defmethod map-size ((mob mob)) (map-size (get-mob-type-by-id (mob-type mob)))) (defun get-mob-move-mode (mob) (cond ((mob-effect-p mob +mob-effect-flying+) +connect-map-move-fly+) ((mob-effect-p mob +mob-effect-climbing-mode+) +connect-map-move-climb+) (t +connect-map-move-walk+))) (defun incf-mob-motion (mob motion) (if (motion-set-p mob) (incf (motion mob) motion) (setf (motion mob) motion (motion-set-p mob) t))) (defun get-mob-visibility (mob) (let ((visibility 0)) (incf visibility (brightness mob)) (incf visibility (motion mob)) (decf visibility (cur-stealth mob)) (when (mob-effect-p mob +mob-effect-invisibility+) (setf visibility 0)) (when (< visibility 0) (setf visibility 0)) visibility)) (defun check-mob-visible (mob &key (observer nil) (complete-check nil)) ;; you can always see yourself (when (eq mob observer) (return-from check-mob-visible t)) (when (and complete-check observer (not (find (id mob) (visible-mobs observer)))) (return-from check-mob-visible nil)) (when (mounted-by-mob-id mob) (return-from check-mob-visible (check-mob-visible (get-mob-by-id (mounted-by-mob-id mob))))) (let ((exposure (get-mob-visibility mob)) (threshold *mob-visibility-threshold*) (result nil)) (when (riding-mob-id mob) (incf exposure (get-mob-visibility (get-mob-by-id (riding-mob-id mob))))) (when (and observer (mob-effect-p observer +mob-effect-alertness+)) (incf exposure *mob-exposure-alertness*)) (if (>= exposure threshold) (setf result t) (setf result nil)) ;; you always see people of you own faction (when (and observer (eq (faction mob) (faction observer))) (setf result t)) result)) (defun set-mob-worshiped-god (mob &key (god-id +god-entity-malseraph+) (init-piety 0) param1 param2) (setf (worshiped-god mob) (list god-id init-piety param1 param2))) (defun set-mob-worshiped-god-param1 (mob new-value) (setf (third (worshiped-god mob)) new-value)) (defun set-mob-worshiped-god-param2 (mob new-value) (setf (fourth (worshiped-god mob)) new-value)) ;;---------------------- ;; PLAYER ;;---------------------- (defclass player (mob) ((name :initform "Player" :initarg :name :accessor name) (view-x :initform 0 :accessor view-x) (view-y :initform 0 :accessor view-y) (view-z :initform 0 :accessor view-z) (dead-message-displayed :initform nil :accessor dead-message-displayed) (eater-corpses-consumed :initform 0 :accessor eater-corpses-consumed) (sense-unnatural-pos :initform nil :accessor sense-unnatural-pos) (sense-relic-pos :initform nil :accessor sense-relic-pos) (sense-portal-pos :initform nil :accessor sense-portal-pos) (sense-sigil-pos :initform nil :accessor sense-sigil-pos) (sense-machine-pos :initform nil :accessor sense-machine-pos) (sense-stockpile-pos :initform nil :accessor sense-stockpile-pos) (can-move-if-possessed :initform t :accessor can-move-if-possessed) (killed-by :initform nil :accessor killed-by) (cur-score :initform 0 :accessor cur-score) (nearby-light-mobs :initform () :accessor nearby-light-mobs) (nearby-light-sources :initform () :accessor nearby-light-sources) (if-cur-mob-seen-through-shared-vision :initform nil :accessor if-cur-mob-seen-through-shared-vision) (player-outside-level :initform nil :accessor player-outside-level) (visible-z-list :initform () :accessor visible-z-list))) (defmethod name ((mob player)) (values (slot-value mob 'name) +noun-proper+ +noun-singular+)) ;;---------------------- ;; FACTIONS ;;---------------------- (defun get-visible-faction (mob &key (viewer *player*)) (let ((result-faction)) ;; see the faction of the mob's appearance (setf result-faction (faction (get-mob-type-by-id (face-mob-type-id mob)))) ;; but if you are really of the same faction, you know the truth (when (= (faction viewer) (faction mob)) (setf result-faction (faction mob))) result-faction))
74,118
Common Lisp
.lisp
1,290
49.246512
234
0.644447
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
23fd7aa395173a1b96da3770ce09e8970fbb737f9cd56d405ae90cf437c79c19
2,847
[ -1 ]
2,848
items.lisp
gwathlobal_CotD/src/items.lisp
(in-package :cotd) (defclass item-type () ((id :initarg :id :accessor id) (glyph-idx :initform 0 :initarg :glyph-idx :accessor glyph-idx :type fixnum) (glyph-color :initform sdl:*white* :initarg :glyph-color :accessor glyph-color :type sdl:color) (back-color :initform sdl:*black* :initarg :back-color :accessor back-color :type sdl:color) (name :initform "No name item" :initarg :name :accessor name) (plural-name :initform nil :initarg :plural-name :accessor plural-name) (descr :initform nil :initarg :descr :accessor descr) (flavor-quote :initform nil :initarg :flavor-quote :accessor flavor-quote) (max-stack-num :initform 1 :initarg :max-stack-num :accessor max-stack-num) (value :initform 0 :initarg :value :accessor value) (abilities :initform (make-hash-table) :accessor abilities) ;; abil-corpse - +item-abil-corpse+ ;; abil-card - +item-abil-card+ - a list of cards that might appear in this deck (on-use :initform nil :initarg :on-use :accessor on-use) (on-check-applic :initform nil :initarg :on-check-applic :accessor on-check-applic) (on-check-ai :initform nil :initarg :on-check-ai :accessor on-check-ai) (ai-invoke-func :initform nil :initarg :ai-invoke-func :accessor ai-invoke-func) (map-select-func :initform nil :initarg :map-select-func :accessor map-select-func) (start-map-select-func :initform nil :initarg :start-map-select-func :accessor start-map-select-func) )) (defmethod initialize-instance :after ((item-type item-type) &key abil-corpse abil-card) (when abil-corpse (setf (gethash +item-abil-corpse+ (abilities item-type)) abil-corpse)) (when abil-card (setf (gethash +item-abil-card+ (abilities item-type)) abil-card)) ) (defun get-item-type-by-id (item-type-id) (aref *item-types* item-type-id)) (defun set-item-type (item-type) (when (>= (id item-type) (length *item-types*)) (adjust-array *item-types* (list (1+ (id item-type))))) (setf (aref *item-types* (id item-type)) item-type)) (defun remove-item-from-world (item) (setf (item-id-list (level *world*)) (remove (id item) (item-id-list (level *world*)))) (setf (aref (item-quadrant-map (level *world*)) (truncate (x item) 10) (truncate (y item) 10)) (remove (id item) (aref (item-quadrant-map (level *world*)) (truncate (x item) 10) (truncate (y item) 10)))) (setf (aref *items* (id item)) nil)) (defclass item () ((id :initform 0 :accessor id :type fixnum) (name :initform nil :accessor name) (alive-name :initform "" :accessor alive-name) (item-type :initform 0 :initarg :item-type :accessor item-type :type fixnum) (dead-mob :initform nil :initarg :dead-mob :accessor dead-mob) (cards :initform () :initarg :cards :accessor cards) (x :initarg :x :initform 0 :accessor x :type fixnum) (y :initarg :y :initform 0 :accessor y :type fixnum) (z :initarg :z :initform 0 :accessor z :type fixnum) (inv-id :initform nil :accessor inv-id) ;; id of the mob that has this item in its inventory (qty :initform 1 :initarg :qty :accessor qty) )) (defmethod initialize-instance :after ((item item) &key (card-num (+ 3 (random 6)))) (setf (id item) (find-free-id *items*)) (setf (aref *items* (id item)) item) ;(setf (name item) (format nil "~A" (name (get-item-type-by-id (item-type item))))) (when (> (qty item) (max-stack-num item)) (setf (qty item) (max-stack-num item))) (when (and (item-ability-p item +item-abil-card+) (null (cards item))) (loop repeat card-num do (push (nth (random (length (item-ability-p item +item-abil-card+))) (item-ability-p item +item-abil-card+)) (cards item)))) ) (defun copy-item (item) (let ((new-item)) (setf new-item (make-instance 'item :item-type (item-type item) :x (x item) :y (y item) :z (z item) :qty (qty item))) (when (slot-value item 'name) (setf (name new-item) (format nil "~A" (name item)))) (setf (inv-id new-item) (inv-id item)) new-item)) (defun get-item-by-id (item-id) (aref *items* item-id)) (defmethod glyph-idx ((item item)) (glyph-idx (get-item-type-by-id (item-type item)))) (defmethod glyph-color ((item item)) (glyph-color (get-item-type-by-id (item-type item)))) (defmethod back-color ((item item)) (back-color (get-item-type-by-id (item-type item)))) (defmethod max-stack-num ((item item)) (max-stack-num (get-item-type-by-id (item-type item)))) (defmethod value ((item item)) (* (qty item) (value (get-item-type-by-id (item-type item))))) (defmethod on-use ((item item)) (on-use (get-item-type-by-id (item-type item)))) (defmethod on-check-ai ((item item)) (on-check-ai (get-item-type-by-id (item-type item)))) (defmethod on-check-applic ((item item)) (on-check-applic (get-item-type-by-id (item-type item)))) (defmethod ai-invoke-func ((item item)) (ai-invoke-func (get-item-type-by-id (item-type item)))) (defmethod map-select-func ((item item)) (map-select-func (get-item-type-by-id (item-type item)))) (defmethod start-map-select-func ((item item)) (start-map-select-func (get-item-type-by-id (item-type item)))) (defmethod descr ((item item)) (descr (get-item-type-by-id (item-type item)))) (defmethod flavor-quote ((item item)) (flavor-quote (get-item-type-by-id (item-type item)))) (defmethod name ((item item)) (if (slot-value item 'name) (values (slot-value item 'name) +noun-proper+ +noun-singular+) (values (name (get-item-type-by-id (item-type item))) +noun-common+ +noun-singular+))) (defmethod plural-name ((item item)) (if (plural-name (get-item-type-by-id (item-type item))) (plural-name (get-item-type-by-id (item-type item))) (name item))) (defun get-item-descr (item) (let ((str (create-string))) (format str "~A~%~%~AQty: ~A~A~A~%~%" (capitalize-name (prepend-article +article-a+ (name item))) (if (descr item) (format nil "~A~%~%" (descr item)) "") (qty item) (if (not (zerop (value item))) (format nil " Value: ~A" (value item)) "") (if (and (not *cotd-release*) (cards item)) (format nil "~%Cards: (~A)" (loop with str = (create-string) for card-type-id in (cards item) for card-type = (get-card-type-by-id card-type-id) do (format str "~A, " (name card-type)) finally (return str))) "") ) str)) (defun get-inv-item-by-id (inv item-id) (if (find item-id inv) (get-item-by-id item-id) nil)) (defun get-inv-item-by-pos (inv n) (if (and (>= n 0) (< n (length inv))) (get-item-by-id (nth n inv)) nil)) (defun get-inv-items-by-type (inv item-type) (loop for item-id in inv for item = (get-item-by-id item-id) when (= item-type (item-type item)) collect item)) (defun add-to-inv (item inv inv-id) ;; find the same item type (let ((incomplete-stacks (remove-if #'(lambda (a) (if (= (max-stack-num a) (qty a)) t nil)) (get-inv-items-by-type inv (item-type item))))) (if (null incomplete-stacks) (progn (push (id item) inv) (setf (inv-id item) inv-id)) (progn (incf (qty (first incomplete-stacks)) (qty item)) (setf (qty item) 0) (when (> (qty (first incomplete-stacks)) (max-stack-num (first incomplete-stacks))) (setf (qty item) (- (qty (first incomplete-stacks)) (max-stack-num (first incomplete-stacks)))) (setf (qty (first incomplete-stacks)) (max-stack-num (first incomplete-stacks)))) (if (zerop (qty item)) (progn (remove-item-from-world item)) (progn (push (id item) inv) (setf (inv-id item) inv-id))))) ) inv) (defun remove-from-inv (item inv &key (qty (qty item))) (when (zerop qty) (return-from remove-from-inv nil)) (if (/= qty (qty item)) (progn (let ((new-item (copy-item item))) (push (id new-item) inv) (setf (qty new-item) (- (qty new-item) qty)) (setf (qty item) qty) (setf (inv-id item) nil) (remove (id item) inv))) (progn (setf (inv-id item) nil) (remove (id item) inv))) ) (defun remove-from-inv-by-type (item-type inv qty) (when (zerop qty) (return-from remove-from-inv-by-type nil)) (loop for item-id in inv for item = (get-item-by-id item-id) with qty-left = qty when (= (item-type item) item-type) do (if (> qty-left (qty item)) (progn (decf qty-left (qty item)) (setf inv (remove-from-inv item inv))) (progn (setf inv (remove-from-inv item inv :qty qty-left)) (setf qty-left 0))) when (zerop qty-left) do (loop-finish)) inv) (defmethod visible-name ((item item)) (multiple-value-bind (item-name noun-proper noun-singular) (name item) (values (format nil "~A~A" (if (> (qty item) 1) (progn (setf noun-singular +noun-plural+) (format nil "~A " (qty item))) "") (if (> (qty item) 1) (progn (setf noun-singular +noun-plural+) (plural-name item)) item-name)) noun-proper noun-singular) )) (defun get-overall-value (inv) (loop for item-id in inv for item = (get-item-by-id item-id) sum (value item))) (defun item-ability-p (item ability-type-id) (gethash ability-type-id (abilities (get-item-type-by-id (item-type item)))))
10,135
Common Lisp
.lisp
223
37.125561
136
0.592244
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
d3ab83dc2e65742884550690fd7332d31cc618b40837467ec16d7a22045a6597
2,848
[ -1 ]
2,849
random-scenario.lisp
gwathlobal_CotD/src/random-scenario.lisp
(in-package :cotd) (defclass scenario-gen-class () ((world :initform nil :initarg :world :accessor scenario-gen-class/world :type (or null world)) (mission :initform nil :accessor scenario-gen-class/mission :type (or null mission)) (world-sector :initform nil :accessor scenario-gen-class/world-sector :type (or null world-sector)) (avail-mission-type-list :initform () :initarg :avail-mission-type-list :accessor scenario-gen-class/avail-mission-type-list :type list) (avail-world-sector-type-list :initform () :initarg :avail-world-sector-type-list :accessor scenario-gen-class/avail-world-sector-type-list :type list) (avail-lvl-mods-list :initform () :initarg :avail-lvl-mods-list :accessor scenario-gen-class/avail-lvl-mods-list :type list) (overall-lvl-mods-list :initform () :accessor scenario-gen-class/overall-lvl-mods-list :type list) (select-lvl-mods-list :initform () :accessor scenario-gen-class/select-lvl-mods-list :type list) (always-lvl-mods-list :initform () :accessor scenario-gen-class/always-lvl-mods-list :type list) (avail-controlled-list :initform () :accessor scenario-gen-class/avail-controlled-list :type list) (select-controlled-mod :initform nil :accessor scenario-gen-class/select-controlled-mod :type (or null level-modifier)) (avail-feats-list :initform () :accessor scenario-gen-class/avail-feats-list :type list) (select-feats-list :initform () :accessor scenario-gen-class/select-feats-list :type list) (avail-items-list :initform () :accessor scenario-gen-class/avail-items-list :type list) (select-items-list :initform () :accessor scenario-gen-class/select-items-list :type list) (avail-tod-list :initform () :accessor scenario-gen-class/avail-tod-list :type list) (select-tod-mod :initform nil :accessor scenario-gen-class/select-tod-mod :type (or null level-modifier)) (avail-weather-list :initform () :accessor scenario-gen-class/avail-weather-list :type list) (select-weather-list :initform () :accessor scenario-gen-class/select-weather-list :type list) (avail-misc-list :initform () :accessor scenario-gen-class/avail-misc-list :type list) (select-misc-list :initform () :accessor scenario-gen-class/select-misc-list :type list) (avail-faction-list :initform () :accessor scenario-gen-class/avil-faction-list :type list) (cur-faction-list :initform () :accessor scenario-gen-class/cur-faction-list :type list) (specific-faction-list :initform () :accessor scenario-gen-class/specific-faction-list :type list) )) (defun scenario-set-avail-mission-types (scenario &optional (new-mission-type-list ())) (with-slots (avail-mission-type-list) scenario ;; set a list of available mission types (setf avail-mission-type-list new-mission-type-list) ;; if no specific mission list is supplied, find all enabled missions (when (null avail-mission-type-list) (setf avail-mission-type-list (get-all-mission-types-list))) )) (defun scenario-set-avail-world-sector-types (scenario &optional (new-world-sector-type-list ())) (with-slots (avail-world-sector-type-list mission) scenario ;; set a list of available world sector types (setf avail-world-sector-type-list new-world-sector-type-list) ;; if no specific world sector list is supplied, find all world sectors for this mission (when (null avail-world-sector-type-list) (setf avail-world-sector-type-list (loop for world-sector-id in (world-sector-for-custom-scenario (get-mission-type-by-id (mission-type-id mission))) collect (get-world-sector-type-by-id world-sector-id)))) )) (defun scenario-set-avail-lvl-mods (scenario &optional (new-avail-lvl-mods-list ())) (with-slots (overall-lvl-mods-list select-lvl-mods-list select-controlled-mod select-feats-list select-items-list select-tod-mod select-weather-list select-misc-list avail-lvl-mods-list avail-controlled-list avail-feats-list avail-items-list avail-tod-list avail-weather-list avail-misc-list world-sector mission world) scenario ;; set a list of available lvl mods (setf avail-lvl-mods-list new-avail-lvl-mods-list) ;; if no specific lvl mod list is supplied, find all available lvl mods (when (not avail-lvl-mods-list) (setf avail-lvl-mods-list (get-all-lvl-mods-list))) ;; populate lists for specific lvl mod types (loop initially (setf select-lvl-mods-list () select-controlled-mod nil select-feats-list () select-items-list () select-tod-mod nil select-weather-list () avail-controlled-list () avail-feats-list () avail-items-list () avail-tod-list () avail-weather-list () avail-misc-list ()) for lvl-mod in avail-lvl-mods-list when (and (is-available-for-mission lvl-mod) (funcall (is-available-for-mission lvl-mod) (wtype world-sector) (mission-type-id mission) (world-game-time world))) do (case (lm-type lvl-mod) (:level-mod-controlled-by (push lvl-mod avail-controlled-list)) (:level-mod-sector-feat (push lvl-mod avail-feats-list)) (:level-mod-sector-item (push lvl-mod avail-items-list)) (:level-mod-tod (push lvl-mod avail-tod-list)) (:level-mod-weather (push lvl-mod avail-weather-list)) (:level-mod-misc (push lvl-mod avail-misc-list))) finally (setf overall-lvl-mods-list (append avail-controlled-list avail-feats-list avail-items-list avail-tod-list avail-weather-list avail-misc-list))) )) (defun scenario-create-world (scenario) (with-slots (world) scenario (setf world (make-instance 'world)) (with-slots (world-map) world (setf world-map (make-instance 'world-map)) (generate-empty-world-map world-map) (loop for lm-controlled-id in (list +lm-controlled-by-demons+ +lm-controlled-by-military+) do (loop for x = (random *max-x-world-map*) for y = (random *max-y-world-map*) while (or (and (<= x 2) (<= y 2)) (/= (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-none+)) finally (setf (controlled-by (aref (cells world-map) x y)) lm-controlled-id))) (scenario-set-world-date scenario 1915 (random 12) (random 30) 0 0 0)))) (defun scenario-create-mission (scenario mission-type-id &key (x 1) (y 1)) (with-slots (mission) scenario ;; create the mission (setf mission (make-instance 'mission :mission-type-id mission-type-id :x x :y y :faction-list () :level-modifier-list ())) )) (defun scenario-create-sector (scenario world-sector-type-id) (with-slots (world world-sector mission) scenario (loop for x from 0 to 2 do (loop for y from 0 to 2 do (setf (aref (cells (world-map world)) x y) (make-instance 'world-sector :wtype :world-sector-normal-residential :x x :y y)))) (setf world-sector (make-instance 'world-sector :wtype world-sector-type-id :x 1 :y 1)) (setf (aref (cells (world-map world)) 1 1) world-sector) (setf (mission world-sector) mission) (setf (world-sector mission) world-sector) (setf (level-modifier-list mission) ()) (setf (faction-list mission) ()) (when (scenario-enabled-func (get-world-sector-type-by-id (wtype world-sector))) (funcall (scenario-enabled-func (get-world-sector-type-by-id (wtype world-sector))) (world-map world) (x world-sector) (y world-sector))))) (defun scenario-set-world-date (scenario &optional (year 1915) (month 0) (day 0) (hour 0) (min 0) (sec 0)) (with-slots (world) scenario (setf (world-game-time world) (set-current-date-time year month day hour min sec)))) (defun scenario-set-controlled-by-lvl-mod (scenario lvl-mod &key (add-to-sector t) (apply-scenario-func t)) (with-slots (world-sector world select-lvl-mods-list select-controlled-mod) scenario (let ((prev-lvl-mod (get-level-modifier-by-id (controlled-by world-sector)))) ;; remove previous controlled-by from sector (when (and prev-lvl-mod apply-scenario-func (scenario-disabled-func prev-lvl-mod)) (funcall (scenario-disabled-func prev-lvl-mod) (world-map world) (x world-sector) (y world-sector))) ;; set new controlled-by in window (setf select-lvl-mods-list (remove prev-lvl-mod select-lvl-mods-list)) (setf select-controlled-mod lvl-mod) (pushnew lvl-mod select-lvl-mods-list) ;; add new controlled-by to sector (when add-to-sector (setf (controlled-by world-sector) (id lvl-mod))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector)))))) (defun scenario-add/remove-feat-lvl-mod (scenario lvl-mod &key (add-general t) (add-to-sector t) (apply-scenario-func t)) (with-slots (world world-sector select-lvl-mods-list select-feats-list) scenario (if add-general ;; either add... (progn ;; do not add if already added (when (not (find lvl-mod select-lvl-mods-list)) (push lvl-mod select-lvl-mods-list) (push lvl-mod select-feats-list) (when add-to-sector (push (list (id lvl-mod) nil) (feats world-sector))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))))) ;; ...or remove (progn (when (and apply-scenario-func (scenario-disabled-func lvl-mod)) (funcall (scenario-disabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))) (setf (feats world-sector) (remove (id lvl-mod) (feats world-sector) :key #'(lambda (a) (first a)))) (setf select-lvl-mods-list (remove lvl-mod select-lvl-mods-list)) (setf select-feats-list (remove lvl-mod select-feats-list)))))) (defun scenario-add/remove-item-lvl-mod (scenario lvl-mod &key (add-general t) (add-to-sector t) (apply-scenario-func t)) (with-slots (world world-sector select-lvl-mods-list select-items-list) scenario (if add-general ;; either add... (progn ;; do not add if already added (when (not (find lvl-mod select-lvl-mods-list)) (push lvl-mod select-lvl-mods-list) (push lvl-mod select-items-list) (when add-to-sector (push (id lvl-mod) (items world-sector))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))))) ;; ...or remove (progn (when (and apply-scenario-func (scenario-disabled-func lvl-mod)) (funcall (scenario-disabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))) (setf (items world-sector) (remove (id lvl-mod) (items world-sector))) (setf select-lvl-mods-list (remove lvl-mod select-lvl-mods-list)) (setf select-items-list (remove lvl-mod select-items-list)))))) (defun scenario-set-tod-lvl-mod (scenario lvl-mod &key (add-to-sector t) (apply-scenario-func t)) (with-slots (world world-sector mission select-lvl-mods-list select-tod-mod) scenario (let ((prev-lvl-mod (find :level-mod-tod (level-modifier-list mission) :key #'(lambda (a) (lm-type (get-level-modifier-by-id a)))))) (when prev-lvl-mod (setf prev-lvl-mod (get-level-modifier-by-id prev-lvl-mod))) ;; remove previous tod from sector (when (and prev-lvl-mod apply-scenario-func (scenario-disabled-func prev-lvl-mod)) (funcall (scenario-disabled-func prev-lvl-mod) (world-map world) (x world-sector) (y world-sector)) (remove (id prev-lvl-mod) (level-modifier-list mission))) ;; set new tod in window (setf select-lvl-mods-list (remove prev-lvl-mod select-lvl-mods-list)) (setf select-tod-mod lvl-mod) (pushnew lvl-mod select-lvl-mods-list) ;; add new to to sector (when add-to-sector (push (id lvl-mod) (level-modifier-list mission))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector)))))) (defun scenario-add/remove-weather-lvl-mod (scenario lvl-mod &key (add-general t) (add-to-sector t) (apply-scenario-func t)) (with-slots (world world-sector mission select-lvl-mods-list select-weather-list) scenario (if add-general ;; either add... (progn ;; do not add if already added (when (not (find lvl-mod select-lvl-mods-list)) (push lvl-mod select-lvl-mods-list) (push lvl-mod select-weather-list) (when add-to-sector (push (id lvl-mod) (level-modifier-list mission))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))))) ;; ...or remove (progn (when (and apply-scenario-func (scenario-disabled-func lvl-mod)) (funcall (scenario-disabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))) (setf (level-modifier-list mission) (remove (id lvl-mod) (level-modifier-list mission))) (setf select-lvl-mods-list (remove lvl-mod select-lvl-mods-list)) (setf select-weather-list (remove lvl-mod select-weather-list)))))) (defun scenario-add/remove-misc-lvl-mod (scenario lvl-mod &key (add-general t) (add-to-sector t) (apply-scenario-func t)) (with-slots (world world-sector mission select-lvl-mods-list select-misc-list) scenario (if add-general ;; either add... (progn ;; do not add if already added (when (not (find lvl-mod select-lvl-mods-list)) (push lvl-mod select-lvl-mods-list) (push lvl-mod select-misc-list) (when add-to-sector (push (id lvl-mod) (level-modifier-list mission))) (when (and apply-scenario-func (scenario-enabled-func lvl-mod)) (funcall (scenario-enabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))))) ;; ...or remove (progn (when (and apply-scenario-func (scenario-disabled-func lvl-mod)) (funcall (scenario-disabled-func lvl-mod) (world-map world) (x world-sector) (y world-sector))) (setf (level-modifier-list mission) (remove (id lvl-mod) (level-modifier-list mission))) (setf select-lvl-mods-list (remove lvl-mod select-lvl-mods-list)) (setf select-misc-list (remove lvl-mod select-misc-list)))))) (defun scenario-add/remove-lvl-mod (scenario lvl-mod &key (add-general t) (add-to-sector t) (apply-scenario-func t)) (case (lm-type lvl-mod) (:level-mod-controlled-by (scenario-set-controlled-by-lvl-mod scenario lvl-mod :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)) (:level-mod-sector-feat (scenario-add/remove-feat-lvl-mod scenario lvl-mod :add-general add-general :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)) (:level-mod-sector-item (scenario-add/remove-item-lvl-mod scenario lvl-mod :add-general add-general :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)) (:level-mod-tod (scenario-set-tod-lvl-mod scenario lvl-mod :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)) (:level-mod-weather (scenario-add/remove-weather-lvl-mod scenario lvl-mod :add-general add-general :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)) (:level-mod-misc (scenario-add/remove-misc-lvl-mod scenario lvl-mod :add-general add-general :add-to-sector add-to-sector :apply-scenario-func apply-scenario-func)))) (defun scenario-adjust-lvl-mods-after-sector-regeneration (scenario) (with-slots (world world-sector mission overall-lvl-mods-list always-lvl-mods-list select-lvl-mods-list) scenario ;; if there are lvl mods in world sector that are not added properly, add them (availability check is done inside add/remove, so lvl-mods are not duplicated) (loop for (lvl-mod-id aux) in (feats world-sector) for lvl-mod = (get-level-modifier-by-id lvl-mod-id) do (scenario-add/remove-lvl-mod scenario lvl-mod :add-general t :add-to-sector nil)) ;; add feats from always present lvl mods from the world sector & mission (loop initially (setf always-lvl-mods-list ()) for lvl-mod in overall-lvl-mods-list when (and (always-present-func lvl-mod) (funcall (always-present-func lvl-mod) world-sector mission (world-game-time world))) do (scenario-add/remove-lvl-mod scenario lvl-mod :add-general t) (pushnew lvl-mod always-lvl-mods-list)) ;; go through all (select-lvl-mods-list win) and add all lvl-mods they depend on (as well as dependencies of dependencies, etc.) (loop with overall-depend-lvl-mod-list = () with lvl-mod = nil with push-dependent-func = #'(lambda (depend-lvl-mod-list) (loop for depend-lvl-mod-id in depend-lvl-mod-list for depend-lvl-mod = (get-level-modifier-by-id depend-lvl-mod-id) do (pushnew depend-lvl-mod overall-depend-lvl-mod-list))) initially (loop for lvl-mod in select-lvl-mods-list do (funcall push-dependent-func (funcall (depends-on-lvl-mod-func lvl-mod) world-sector (mission-type-id mission) (world-game-time world)))) while (> (length overall-depend-lvl-mod-list) 0) do (setf lvl-mod (pop overall-depend-lvl-mod-list)) (scenario-add/remove-lvl-mod scenario lvl-mod :add-general t) (pushnew lvl-mod always-lvl-mods-list) (funcall push-dependent-func (funcall (depends-on-lvl-mod-func lvl-mod) world-sector (mission-type-id mission) (world-game-time world)))) )) (defun scenario-sort-select-lvl-mods (scenario) (with-slots (select-lvl-mods-list) scenario (setf select-lvl-mods-list (stable-sort select-lvl-mods-list #'(lambda (a b) (if (< (position (lm-type a) (defenum:tags 'level-mod-type-enum)) (position (lm-type b) (defenum:tags 'level-mod-type-enum))) t nil)))))) (defun scenario-adjust-factions (scenario &key (req-faction-id nil) (req-faction-present nil)) (with-slots (world-sector mission avail-faction-list cur-faction-list) scenario ;; find all general factions (loop initially (setf avail-faction-list ()) with sector-factions = (if (faction-list-func (get-world-sector-type-by-id (wtype world-sector))) (funcall (faction-list-func (get-world-sector-type-by-id (wtype world-sector)))) nil) with controlled-by-factions = (if (faction-list-func (get-level-modifier-by-id (controlled-by world-sector))) (funcall (faction-list-func (get-level-modifier-by-id (controlled-by world-sector))) (wtype world-sector)) nil) with feats-factions = (loop for (feat-id) in (feats world-sector) when (faction-list-func (get-level-modifier-by-id feat-id)) append (funcall (faction-list-func (get-level-modifier-by-id feat-id)) (wtype world-sector))) with items-factions = (loop for item-id in (items world-sector) when (faction-list-func (get-level-modifier-by-id item-id)) append (funcall (faction-list-func (get-level-modifier-by-id item-id)) (wtype world-sector))) with mission-factions = (if (faction-list-func (get-mission-type-by-id (mission-type-id mission))) (funcall (faction-list-func (get-mission-type-by-id (mission-type-id mission))) world-sector) nil) with overall-factions = (append sector-factions controlled-by-factions feats-factions items-factions mission-factions) for (faction-id faction-present) in overall-factions for faction-obj = (find faction-id avail-faction-list :key #'(lambda (a) (first a))) do (if faction-obj (progn (when (not (find faction-present (second faction-obj))) (push faction-present (second faction-obj)))) (progn (push (list faction-id (list faction-present)) avail-faction-list))) finally (loop initially (setf cur-faction-list ()) for (faction-id faction-present-list) in avail-faction-list do (if (and req-faction-id (= faction-id req-faction-id)) (push (list faction-id req-faction-present) cur-faction-list) (push (list faction-id (nth (random (length faction-present-list)) faction-present-list)) cur-faction-list)) finally (setf cur-faction-list (stable-sort cur-faction-list #'(lambda (a b) (if (eq (second a) :mission-faction-present) (if (string-lessp (name (get-faction-type-by-id (first a))) (name (get-faction-type-by-id (first b)))) t nil) nil)))) (setf (faction-list mission) cur-faction-list))))) (defun scenario-adjust-specific-factions (scenario) (with-slots (mission cur-faction-list specific-faction-list) scenario (loop initially (setf specific-faction-list ()) for (faction-id faction-present) in cur-faction-list for faction-obj = (get-faction-type-by-id faction-id) when (or (eq faction-present :mission-faction-present) (eq faction-present :mission-faction-delayed)) do (loop for specific-faction-type in (specific-faction-list faction-obj) when (find specific-faction-type (scenario-faction-list (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))) do (push specific-faction-type specific-faction-list)) finally (setf specific-faction-list (reverse specific-faction-list)) (when (not *cotd-release*) (when (find +specific-faction-type-player+ (scenario-faction-list (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))) (push +specific-faction-type-player+ specific-faction-list)) (when (find +specific-faction-type-dead-player+ (scenario-faction-list (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))) (push +specific-faction-type-dead-player+ specific-faction-list))) (remove-duplicates specific-faction-list)))) (defun scenario-set-player-specific-faction (scenario specific-faction-type) (with-slots (mission) scenario (setf (player-specific-faction mission) specific-faction-type) (setf (player-lvl-mod-placement-id mission) (second (find specific-faction-type (scenario-faction-list (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))))))) (defun find-random-scenario-options (specific-faction-type &key (avail-mission-type-list nil) (avail-world-sector-type-list nil) (avail-lvl-mods-list nil) ) (let ((available-faction-list ()) (available-variants-list ())) ;; find all factions that have the required specific faction (setf available-faction-list (loop for faction-type across *faction-types* when (and faction-type (find specific-faction-type (specific-faction-list faction-type))) collect (id faction-type))) (when (null available-faction-list) (return-from find-random-scenario-options (generate-random-scenario nil nil :mission-faction-present specific-faction-type :avail-mission-type-list avail-mission-type-list :avail-world-sector-type-list nil :avail-lvl-mods-list avail-lvl-mods-list))) ;; if available lvl-mods are not supplied, take all of them (when (not avail-lvl-mods-list) (setf avail-lvl-mods-list (get-all-lvl-mods-list))) ;; if available mission-types are not supplied, take all of them (when (not avail-mission-type-list) (setf avail-mission-type-list (get-all-mission-types-list))) ;; if available sector types are not supplied, find all possible sectors in game (when (not avail-world-sector-type-list) (setf avail-world-sector-type-list (get-all-world-sector-types-list))) ;; find all lvl mods that produce the required faction & are available for mission & world-sector (loop for lvl-mod in avail-lvl-mods-list when (faction-list-func lvl-mod) do (loop for world-sector-type in avail-world-sector-type-list do (loop with result-1 = nil for (faction-type-id faction-present) in (funcall (faction-list-func lvl-mod) (wtype world-sector-type)) when (eq faction-present :mission-faction-present) do (setf result-1 (loop with result-2 = nil for target-faction-id in available-faction-list when (= target-faction-id faction-type-id) do (setf result-2 t) (loop-finish) finally (return result-2))) (when result-1 (loop for mission-type in avail-mission-type-list when (world-sector-for-custom-scenario mission-type) do (loop for world-sector-type-id in (world-sector-for-custom-scenario mission-type) when (eq world-sector-type-id (wtype world-sector-type)) do (loop for month in (list 0 1 2 3 4 5 6 7 8 9 10 11) for world-time = (set-current-date-time 1915 month 0 0 0 0) do (when (and (is-available-for-mission lvl-mod) (funcall (is-available-for-mission lvl-mod) (wtype world-sector-type) (id mission-type) world-time)) (push (list lvl-mod world-sector-type mission-type) available-variants-list) (loop-finish))) )))))) ;; find all world-sectors that produce the required faction & are available for mission (loop for world-sector-type in avail-world-sector-type-list when (faction-list-func world-sector-type) do (loop with result-1 = nil for (faction-type-id faction-present) in (funcall (faction-list-func world-sector-type)) when (eq faction-present :mission-faction-present) do (setf result-1 (loop with result-2 = nil for target-faction-id in available-faction-list when (= target-faction-id faction-type-id) do (setf result-2 t) (loop-finish) finally (return result-2))) (when result-1 (loop for mission-type in avail-mission-type-list when (world-sector-for-custom-scenario mission-type) do (loop for world-sector-type-id in (world-sector-for-custom-scenario mission-type) when (eq world-sector-type-id (wtype world-sector-type)) do (push (list nil world-sector-type mission-type) available-variants-list)))))) ;; find all missions that produce the required faction (loop for mission-type in avail-mission-type-list when (faction-list-func mission-type) do (loop for world-sector-type in avail-world-sector-type-list for world-sector = (make-instance 'world-sector :wtype (wtype world-sector-type) :x 1 :y 1) do (loop with result-1 = nil for (faction-type-id faction-present) in (funcall (faction-list-func mission-type) world-sector) when (eq faction-present :mission-faction-present) do (setf result-1 (loop with result-2 = nil for target-faction-id in available-faction-list when (= target-faction-id faction-type-id) do (setf result-2 t) (loop-finish) finally (return result-2))) (when result-1 (when (world-sector-for-custom-scenario mission-type) (loop for world-sector-type-id in (world-sector-for-custom-scenario mission-type) when (eq world-sector-type-id (wtype world-sector-type)) do (push (list nil world-sector-type mission-type) available-variants-list))))) )) (loop for (lvl-mod world-sector-type mission-type) in available-variants-list do (log:debug "Lvl-mod ~A, World Sector: ~A, Mission Type: ~A" (if lvl-mod (name lvl-mod) "NIL") (if world-sector-type (name world-sector-type) "NIL") (if mission-type (name mission-type) "NIL"))) (when available-variants-list ;; generate a mission with all other parameters & exit (let ((lvl-mod-obj (nth (random (length available-variants-list)) available-variants-list))) (return-from find-random-scenario-options (generate-random-scenario (first lvl-mod-obj) (nth (random (length available-faction-list)) available-faction-list) :mission-faction-present specific-faction-type :avail-mission-type-list (list (third lvl-mod-obj)) :avail-world-sector-type-list (list (second lvl-mod-obj)) :avail-lvl-mods-list avail-lvl-mods-list))) ))) (defun generate-random-scenario (req-lvl-mod req-faction-id req-faction-present specific-faction-type &key (avail-mission-type-list nil) (avail-world-sector-type-list nil) (avail-lvl-mods-list nil)) (let ((scenario (make-instance 'scenario-gen-class)) (lvl-mod-controlled-by-set nil) (lvl-mod-feats-set nil) (lvl-mod-items-set nil) (lvl-mod-tod-set nil) (lvl-mod-weather-set nil) (lvl-mod-misc-set nil)) (flet ((add-lvl-mod (lvl-mod &key (add-to-sector t)) (case (lm-type lvl-mod) (:level-mod-controlled-by (progn (setf lvl-mod-controlled-by-set t) (scenario-set-controlled-by-lvl-mod scenario lvl-mod :add-to-sector add-to-sector))) (:level-mod-sector-feat (progn (setf lvl-mod-feats-set t) (scenario-add/remove-feat-lvl-mod scenario lvl-mod :add-general t :add-to-sector add-to-sector))) (:level-mod-sector-item (progn (setf lvl-mod-items-set t) (scenario-add/remove-item-lvl-mod scenario lvl-mod :add-general t :add-to-sector add-to-sector))) (:level-mod-tod (progn (setf lvl-mod-tod-set t) (scenario-set-tod-lvl-mod scenario lvl-mod :add-to-sector add-to-sector))) (:level-mod-weather (progn (setf lvl-mod-weather-set t) (scenario-add/remove-weather-lvl-mod scenario lvl-mod :add-general t :add-to-sector add-to-sector))) (:level-mod-misc (progn (setf lvl-mod-misc-set t) (scenario-add/remove-misc-lvl-mod scenario lvl-mod :add-general t :add-to-sector add-to-sector)))))) (with-slots (world world-sector mission avail-controlled-list avail-feats-list avail-items-list avail-tod-list avail-weather-list avail-misc-list) scenario ;; create the supporting world (scenario-create-world scenario) ;; set up available missions (scenario-set-avail-mission-types scenario avail-mission-type-list) ;; create the mission (scenario-create-mission scenario (id (nth (random (length (scenario-gen-class/avail-mission-type-list scenario))) (scenario-gen-class/avail-mission-type-list scenario)))) ;; set up available world-sectors (scenario-set-avail-world-sector-types scenario avail-world-sector-type-list) ;; create the world sector (scenario-create-sector scenario (wtype (nth (random (length (scenario-gen-class/avail-world-sector-type-list scenario))) (scenario-gen-class/avail-world-sector-type-list scenario)))) ;; set up available lvl mods (scenario-set-avail-lvl-mods scenario avail-lvl-mods-list) ;; add the required lvl-mod (when req-lvl-mod (add-lvl-mod req-lvl-mod)) ;; if controlled-by is not already set, set a random controlled-by lvl-mod (when (not lvl-mod-controlled-by-set) (add-lvl-mod (nth (random (length avail-controlled-list)) avail-controlled-list))) ;; add random feats lvl-mods (loop for lvl-mod in avail-feats-list when (zerop (random 4)) do (add-lvl-mod lvl-mod)) ;; add random items lvl-mods (loop for lvl-mod in avail-items-list when (zerop (random 4)) do (add-lvl-mod lvl-mod)) (generate-feats-for-world-sector world-sector (world-map world)) ;; if tod is not already set, find and set a random time-of-day lvl-mod (when (not lvl-mod-tod-set) (add-lvl-mod (nth (random (length avail-tod-list)) avail-tod-list))) ;; add random weather lvl-mods (loop for lvl-mod in avail-weather-list when (or (not (random-available-for-mission lvl-mod)) (funcall (random-available-for-mission lvl-mod))) do (add-lvl-mod lvl-mod)) ;; add random misc lvl-mods (loop for lvl-mod in avail-misc-list when (or (not (random-available-for-mission lvl-mod)) (funcall (random-available-for-mission lvl-mod))) do (add-lvl-mod lvl-mod)) ;; add all dependent lvl mods, as well as lvl mods after wrold sector generation above (scenario-adjust-lvl-mods-after-sector-regeneration scenario) (scenario-sort-select-lvl-mods scenario) ;; set up a all general factions (scenario-adjust-factions scenario :req-faction-id req-faction-id :req-faction-present req-faction-present) ;; set up the required player faction (scenario-set-player-specific-faction scenario specific-faction-type) (setf *world* world) (return-from generate-random-scenario (values mission world-sector))))))
38,790
Common Lisp
.lisp
555
52.434234
212
0.587251
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5021b83d09ae92571ccfe9dce6dbd780502f1913347b0dddadecc831150fcea3
2,849
[ -1 ]
2,850
init-card-types.lisp
gwathlobal_CotD/src/init-card-types.lisp
(in-package :cotd) (set-card-type (make-instance 'card-type :id +item-card-blink+ :name "Card of Bend Space" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (invoke-bend-space actor)))) (set-card-type (make-instance 'card-type :id +item-card-teleport+ :name "Card of Teleporting" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (invoke-teleport-self actor 30 (z actor))))) (set-card-type (make-instance 'card-type :id +item-card-disguise+ :name "Card of Disguises" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (invoke-disguise actor)))) (set-card-type (make-instance 'card-type :id +item-card-sprint+ :name "Card of Sprinting" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (set-mob-effect actor :effect-type-id +mob-effect-sprint+ :actor-id (id actor) :cd 5)))) (set-card-type (make-instance 'card-type :id +item-card-flying+ :name "Card of Flying" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (set-mob-effect actor :effect-type-id +mob-effect-flying+ :actor-id (id actor) :cd 5)))) (set-card-type (make-instance 'card-type :id +item-card-curse-other+ :name "Card of Curses" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (invoke-curse actor)))) (set-card-type (make-instance 'card-type :id +item-card-blindness-other+ :name "Card of Blindness" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; blind nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for mob = (get-mob-by-id (nth i (visible-mobs actor))) do (set-mob-effect mob :effect-type-id +mob-effect-blind+ :actor-id (id actor) :cd 2) (if (eq *player* mob) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*)) (setf (visible-mobs mob) nil)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A is blind. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :color sdl:*white* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind))) )))) (set-card-type (make-instance 'card-type :id +item-card-fear-other+ :name "Card of Fear" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (invoke-fear actor 3)))) (set-card-type (make-instance 'card-type :id +item-card-slow-other+ :name "Card of Slowness" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; slow nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) do (set-mob-effect target :effect-type-id +mob-effect-slow+ :actor-id (id actor) :cd 5) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is slown. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))) ) ))) (set-card-type (make-instance 'card-type :id +item-card-silence-other+ :name "Card of Silence" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; silence nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) do (set-mob-effect target :effect-type-id +mob-effect-silence+ :actor-id (id actor) :cd 5) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is silenced. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))) )))) (set-card-type (make-instance 'card-type :id +item-card-confuse-other+ :name "Card of Confusion" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; confuse nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) do (if (> (1+ (random 6)) (strength target)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is confused. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-confuse+ :actor-id (id actor) :cd 4)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists confusion. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) )))) (set-card-type (make-instance 'card-type :id +item-card-polymorph-other+ :name "Card of the Sheep" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; polymorph nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) with polymorphed-once = nil when (not (get-faction-relation (faction actor) (faction target))) do (if (> (1+ (random 6)) (strength target)) (progn (set-mob-effect target :effect-type-id +mob-effect-polymorph-sheep+ :actor-id (id actor) :cd 5 :param1 (list (mob-type target) (max-hp target))) (setf polymorphed-once t)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists polymorph. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) finally (when polymorphed-once (increase-piety-for-god +god-entity-malseraph+ actor 50)) )))) (set-card-type (make-instance 'card-type :id +item-card-polymorph-self+ :name "Card of the Sheep" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (if (> (1+ (random 6)) (strength actor)) (progn (set-mob-effect actor :effect-type-id +mob-effect-polymorph-sheep+ :actor-id (id actor) :cd 5 :param1 (list (mob-type actor) (max-hp actor)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists polymorph. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ))) (set-card-type (make-instance 'card-type :id +item-card-irradiate-other+ :name "Card of Radiation" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) do (if (mob-effect-p target +mob-effect-irradiated+) (progn (let ((effect (get-effect-by-id (mob-effect-p target +mob-effect-irradiated+)))) (incf (param1 effect) (+ 2 (random 3))))) (progn (set-mob-effect target :effect-type-id +mob-effect-irradiated+ :actor-id (id actor) :cd t :param1 (+ 2 (random 3))))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is irradiated. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )))) (set-card-type (make-instance 'card-type :id +item-card-irradiate-self+ :name "Card of Radiation" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (if (mob-effect-p actor +mob-effect-irradiated+) (progn (let ((effect (get-effect-by-id (mob-effect-p actor +mob-effect-irradiated+)))) (incf (param1 effect) (+ 2 (random 3))))) (progn (set-mob-effect actor :effect-type-id +mob-effect-irradiated+ :actor-id (id actor) :cd t :param1 (+ 2 (random 3))))) ))) (set-card-type (make-instance 'card-type :id +item-card-confuse-self+ :name "Card of Confusion" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; confuse nearby mobs (if (> (1+ (random 6)) (strength actor)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is confused. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) )) (set-mob-effect actor :effect-type-id +mob-effect-confuse+ :actor-id (id actor) :cd 4)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists confusion. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))))) (set-card-type (make-instance 'card-type :id +item-card-silence-self+ :name "Card of Silence" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (set-mob-effect actor :effect-type-id +mob-effect-silence+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is silenced. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))) (set-card-type (make-instance 'card-type :id +item-card-slow-self+ :name "Card of Slowness" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (set-mob-effect actor :effect-type-id +mob-effect-slow+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is slown. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))) (set-card-type (make-instance 'card-type :id +item-card-fear-self+ :name "Card of Fear" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (if (> (random (+ (strength actor) 3)) (strength actor)) (progn (set-mob-effect actor :effect-type-id +mob-effect-fear+ :actor-id (id actor) :cd 3) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is feared. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists fear. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))))) (set-card-type (make-instance 'card-type :id +item-card-blindness-self+ :name "Card of Blindness" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (set-mob-effect actor :effect-type-id +mob-effect-blind+ :actor-id (id actor) :cd 2) (if (eq *player* actor) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*)) (setf (visible-mobs actor) nil)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is blind. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))) (set-card-type (make-instance 'card-type :id +item-card-curse-self+ :name "Card of Curses" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (let ((protected nil)) ;; divine shield and blessings also grant one-time protection from curses (when (and (not protected) (mob-effect-p actor +mob-effect-blessed+)) (rem-mob-effect actor +mob-effect-blessed+) (setf protected t)) (when (and (not protected) (mob-effect-p actor +mob-effect-divine-shield+)) (rem-mob-effect actor +mob-effect-divine-shield+) (setf protected t)) (if protected (progn (log:info (format nil "MOB-CURSE: ~A [~A] was protected, so the curse removes protection only~%" (name actor) (id actor))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Malseraph's curse removed divine protection from ~A. " (prepend-article +article-the+ (visible-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) (progn (log:info (format nil "MOB-CURSE: Malseraph affects ~A [~A] with a curse~%" (name actor) (id actor))) (set-mob-effect actor :effect-type-id +mob-effect-cursed+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is cursed. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) )))) (set-card-type (make-instance 'card-type :id +item-card-give-deck+ :name "Card of Gifts" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (let* ((deck-types (list +item-type-deck-of-war+ +item-type-deck-of-escape+)) (r (random (length deck-types))) (deck-item (make-instance 'item :item-type (nth r deck-types) :x (x actor) :y (y actor) :z (z actor) :qty 1))) (when (or (eq actor *player*) (not (mob-effect-p actor +mob-effect-disguised+))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Malseraph grants ~A ~A. " (prepend-article +article-the+ (visible-name actor)) (prepend-article +article-a+ (visible-name deck-item))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (mob-pick-item actor deck-item :spd nil :silent t)) ))) (set-card-type (make-instance 'card-type :id +item-card-glowing-all+ :name "Card of Glowing" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (let ((targets nil)) (loop for x from (- (x actor) 6) to (+ (x actor) 6) do (loop for y from (- (y actor) 6) to (+ (y actor) 6) do (loop for z from (- (z actor) 6) to (+ (z actor) 6) when (and (>= x 0) (< x (array-dimension (terrain (level *world*)) 0)) (>= y 0) (< y (array-dimension (terrain (level *world*)) 1)) (>= z 0) (< z (array-dimension (terrain (level *world*)) 2)) (get-mob-* (level *world*) x y z)) do (pushnew (get-mob-* (level *world*) x y z) targets) ))) (loop for target in targets do (set-mob-effect target :effect-type-id +mob-effect-glowing+ :actor-id (id actor) :cd 5) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is glowing. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ))) (set-card-type (make-instance 'card-type :id +item-card-cure-mutation+ :name "Card of Cure Mutation" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (let ((was-cured nil)) (when (mob-ability-p actor +mob-abil-casts-light+) (mob-remove-mutation actor +mob-abil-casts-light+) (setf was-cured t)) (when (mob-ability-p actor +mob-abil-vulnerable-to-fire+) (mob-remove-mutation actor +mob-abil-vulnerable-to-fire+) (setf was-cured t)) (when (mob-ability-p actor +mob-abil-vulnerable-to-vorpal+) (mob-remove-mutation actor +mob-abil-vulnerable-to-vorpal+) (setf was-cured t)) (when was-cured (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is cured of all malmutations. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ))) (set-card-type (make-instance 'card-type :id +item-card-lignify-other+ :name "Card of the Tree" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) ;; polymorph nearby mobs (loop for i from 0 below (length (visible-mobs actor)) for target = (get-mob-by-id (nth i (visible-mobs actor))) with polymorphed-once = nil when (not (get-faction-relation (faction actor) (faction target))) do (if (> (1+ (random 6)) (strength target)) (progn (set-mob-effect target :effect-type-id +mob-effect-polymorph-tree+ :actor-id (id actor) :cd 5 :param1 (list (mob-type target) (max-hp target))) (setf polymorphed-once t)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists polymorph. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) finally (when polymorphed-once (increase-piety-for-god +god-entity-malseraph+ actor 50)) )))) (set-card-type (make-instance 'card-type :id +item-card-lignify-self+ :name "Card of the Tree" :on-use #'(lambda (card-type actor) (log:info (format nil "INVOKE-CARD: ~A [~A] invokes card: ~A.~%" (name actor) (id actor) (name card-type))) (if (> (1+ (random 6)) (strength actor)) (progn (set-mob-effect actor :effect-type-id +mob-effect-polymorph-tree+ :actor-id (id actor) :cd 5 :param1 (list (mob-type actor) (max-hp actor)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A resists polymorph. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) )))
42,763
Common Lisp
.lisp
390
48.189744
227
0.313678
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
f6fe031d6118f34a0cc7fdfe492a75fc28b25ce25e1d8d1e77e5bcfdf1f9787b
2,850
[ -1 ]
2,851
los-fov.lisp
gwathlobal_CotD/src/los-fov.lisp
(in-package :cotd) (defun get-distance (sx sy tx ty) (declare (type fixnum sx sy tx ty)) (sqrt (+ (* (- sx tx) (- sx tx)) (* (- sy ty) (- sy ty))))) (defun get-distance-3d (sx sy sz tx ty tz) (declare (type fixnum sx sy sz tx ty tz)) (sqrt (+ (* (- sx tx) (- sx tx)) (* (- sy ty) (- sy ty)) (* (- sz tz) (- sz tz))))) (defun check-LOS-propagate (dx dy dz prev-cell &key (check-move nil) (check-vision nil) (check-projectile nil) (player-reveal-cell nil) (check-sound nil)) ;(declare (optimize (speed 3))) (let ((terrain) (vision-block-power 0)) (when (or (< dx 0) (>= dx (array-dimension (terrain (level *world*)) 0)) (< dy 0) (>= dy (array-dimension (terrain (level *world*)) 1)) (< dz 0) (>= dz (array-dimension (terrain (level *world*)) 2))) (return-from check-LOS-propagate nil)) ;; check if LOS propagates vertically through floors (depending on the type of LOS) (when (and prev-cell (/= (- (third prev-cell) dz) 0)) (loop for (check trait) in `((,check-move ,+terrain-trait-blocks-move-floor+) (,check-vision ,+terrain-trait-blocks-vision-floor+) (,check-projectile ,+terrain-trait-blocks-projectiles-floor+)) when check do (if (> (- (third prev-cell) dz) 0) ;; prev is up, the tile above current has trait & the prev tile has trait (when (and (get-terrain-* (level *world*) dx dy (third prev-cell)) (or (eq (get-terrain-type-trait (get-terrain-* (level *world*) dx dy (third prev-cell)) trait) t) (eq (get-terrain-type-trait (get-terrain-* (level *world*) dx dy (third prev-cell)) trait) 100)) (or (eq (get-terrain-type-trait (get-terrain-* (level *world*) (first prev-cell) (second prev-cell) (third prev-cell)) trait) t) (eq (get-terrain-type-trait (get-terrain-* (level *world*) (first prev-cell) (second prev-cell) (third prev-cell)) trait) 100))) (return-from check-LOS-propagate nil)) ;; prev is down (when (and (get-terrain-* (level *world*) (first prev-cell) (second prev-cell) dz) (or (eq (get-terrain-type-trait (get-terrain-* (level *world*) (first prev-cell) (second prev-cell) dz) trait) t) (eq (get-terrain-type-trait (get-terrain-* (level *world*) (first prev-cell) (second prev-cell) dz) trait) 100)) (get-terrain-* (level *world*) dx dy dz) (or (eq (get-terrain-type-trait (get-terrain-* (level *world*) dx dy dz) +terrain-trait-blocks-move-floor+) t) (eq (get-terrain-type-trait (get-terrain-* (level *world*) dx dy dz) +terrain-trait-blocks-move-floor+) 100))) (return-from check-LOS-propagate nil))))) (when player-reveal-cell (when (and (<= (abs (- (x *player*) dx)) 5) (<= (abs (- (y *player*) dy)) 5) (/= (z *player*) dz)) (pushnew dz (visible-z-list *player*))) (reveal-cell-on-map (level *world*) dx dy dz :reveal-mob (if (or (null (get-mob-* (level *world*) dx dy dz)) (eq (get-mob-* (level *world*) dx dy dz) *player*)) t (check-mob-visible (get-mob-* (level *world*) dx dy dz) :observer *player*)))) (setf terrain (get-terrain-* (level *world*) dx dy dz)) (unless terrain (return-from check-LOS-propagate nil)) (when (and check-move (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (return-from check-LOS-propagate nil)) (when (and check-vision (get-terrain-type-trait terrain +terrain-trait-blocks-vision+)) (if (eq (get-terrain-type-trait terrain +terrain-trait-blocks-vision+) t) (incf vision-block-power 100) (incf vision-block-power (get-terrain-type-trait terrain +terrain-trait-blocks-vision+)))) (when (and check-projectile (get-terrain-type-trait terrain +terrain-trait-blocks-projectiles+)) (return-from check-LOS-propagate nil)) (when (and check-sound (or (eq (get-terrain-type-trait terrain +terrain-trait-blocks-sound+) t) (eq (get-terrain-type-trait terrain +terrain-trait-blocks-sound+) 100))) (return-from check-LOS-propagate nil)) (loop for feature-id in (get-features-* (level *world*) dx dy dz) for lvl-feature = (get-feature-by-id feature-id) when (and check-vision (get-feature-type-trait lvl-feature +feature-trait-blocks-vision+)) do (if (eq (get-feature-type-trait lvl-feature +feature-trait-blocks-vision+) t) (incf vision-block-power 100) (incf vision-block-power (get-feature-type-trait lvl-feature +feature-trait-blocks-vision+))) ) (when check-vision (return-from check-LOS-propagate vision-block-power)) t)) (defun calculate-single-tile-brightness (level x y z &key (calc-for-player nil)) (let ((brightness 0) (darkness 0)) ;; iterate through all mobs (loop for mob-id of-type fixnum in (if calc-for-player (nearby-light-mobs *player*) (mob-id-list level)) for tmob of-type mob = (get-mob-by-id mob-id) for light-power of-type fixnum = (* *light-power-faloff* (abs (cur-light tmob))) for vision-pwr of-type fixnum = (abs (cur-light tmob)) for vision-power of-type fixnum = (abs (cur-light tmob)) do (when (< (get-distance-3d (x tmob) (y tmob) (z tmob) x y z) (abs (cur-light tmob))) (line-of-sight (x tmob) (y tmob) (z tmob) x y z #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (pwr-decrease 0)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) (if (> (cur-light tmob) 0) (progn ;; if the light emitted by a mob is positive - increase brightness (when (and (= x dx) (= y dy) (= z dz) (> light-power brightness)) (setf brightness light-power) (setf exit-result 'exit) (return)) (decf light-power *light-power-faloff*)) (progn ;; if the light emitted by a mob is negative - increase darkness (when (and (= x dx) (= y dy) (= z dz) (> light-power darkness)) (setf darkness light-power) (setf exit-result 'exit) (return)) (decf light-power *dark-power-faloff*))) (when (<= vision-pwr 0) (setf exit-result 'exit) (return))) exit-result)))) ) ;; iterate through all stationary sources (loop for (tx ty tz light-radius) in (if calc-for-player (nearby-light-sources *player*) (coerce (light-sources level) 'list)) for light-power of-type fixnum = (* *light-power-faloff* light-radius) for vision-pwr of-type fixnum = light-radius for vision-power of-type fixnum = light-radius do (when (and (not (zerop light-radius)) (< (get-distance-3d tx ty tz x y z) light-radius)) (line-of-sight tx ty tz x y z #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (pwr-decrease 0)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) ;; insert set light func here (when (and (= x dx) (= y dy) (= z dz) (> light-power brightness)) (setf brightness light-power) (setf exit-result 'exit) (return)) (decf light-power *light-power-faloff*) (when (<= vision-pwr 0) (setf exit-result 'exit) (return))) exit-result))))) ;; increase brigtness by outdoor brightness (incf brightness (get-outdoor-light-* level x y z)) (decf brightness darkness) ;; find nearby mobs that are casting shadows and check if the tile in question is the tile they are casting shadows to (when (>= brightness *mob-visibility-threshold*) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (< dx (array-dimension (terrain level) 0)) (>= dy 0) (< dy (array-dimension (terrain level) 1)) (get-mob-* level dx dy z) (mob-effect-p (get-mob-* level dx dy z) +mob-effect-casting-shadow+)) (let ((effect (get-effect-by-id (mob-effect-p (get-mob-* level dx dy z) +mob-effect-casting-shadow+)))) (when (and (= (+ dx (first (param1 effect))) x) (= (+ dy (second (param1 effect))) y)) (setf brightness (- *mob-visibility-threshold* 10)))))))) (when (< brightness 0) (setf brightness 0)) brightness )) (defun calc-lit-tiles-for-player (mob) (log:info "CALC-LIT-TILES: ~A [~A]" (name mob) (id mob)) (dotimes (x1 (array-dimension (memo (level *world*)) 0)) (declare (type fixnum x1)) (dotimes (y1 (array-dimension (memo (level *world*)) 1)) (declare (type fixnum y1)) (dotimes (z1 (array-dimension (memo (level *world*)) 2)) (declare (type fixnum z1)) (set-single-memo-* (level *world*) x1 y1 z1 :light 0) ))) (loop for tx of-type fixnum from (- (x mob) (cur-sight mob)) to (+ (x mob) (cur-sight mob)) do (loop for ty of-type fixnum from (- (y mob) (cur-sight mob)) to (+ (y mob) (cur-sight mob)) do (loop for tz of-type fixnum from (- (z mob) (cur-sight mob)) to (+ (z mob) (cur-sight mob)) with brightness of-type fixnum = 0 when (and (>= tx 0) (< tx (array-dimension (terrain (level *world*)) 0)) (>= ty 0) (< ty (array-dimension (terrain (level *world*)) 1)) (>= tz 0) (< tz (array-dimension (terrain (level *world*)) 2))) do (setf brightness (calculate-single-tile-brightness (level *world*) tx ty tz :calc-for-player t)) (when (> brightness (get-single-memo-light (get-memo-* (level *world*) tx ty tz))) (set-single-memo-* (level *world*) tx ty tz :light brightness))))) ) (defun update-visible-mobs-normal (mob) (declare (optimize (speed 3) (safety 0))) (setf (brightness mob) 0) (setf (darkness mob) 0) (when (eq mob *player*) (setf (nearby-light-mobs *player*) nil) (setf (nearby-light-sources *player*) nil)) (let ((quad-x (truncate (x mob) 10)) (quad-y (truncate (y mob) 10))) (declare (type fixnum quad-x quad-y)) ;; check through all stationary light sources (loop with light-list = (loop with result = () for (qx qy) of-type (fixnum fixnum) in '((-1 -1) (-1 0) (-1 1) (0 -1) (0 0) (0 1) (1 -1) (1 0) (1 1)) when (and (>= (+ quad-x qx) 0) (>= (+ quad-y qy) 0) (< (+ quad-x qx) (array-dimension (light-quadrant-map (level *world*)) 0)) (< (+ quad-y qy) (array-dimension (light-quadrant-map (level *world*)) 1))) do (setf result (append result (aref (light-quadrant-map (level *world*)) (+ quad-x qx) (+ quad-y qy)))) finally (return result)) for (x y z light-radius) of-type (fixnum fixnum fixnum fixnum) in light-list for i of-type fixnum from 0 below (length light-list) for light-power of-type fixnum = (* *light-power-faloff* light-radius) for vision-pwr of-type fixnum = light-radius for vision-power of-type fixnum = light-radius do ;; set up mob brightness (when (and (not (zerop light-radius)) (< (get-distance-3d x y z (x mob) (y mob) (z mob)) light-radius)) (line-of-sight x y z (x mob) (y mob) (z mob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (pwr-decrease 0)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) (when (and (get-mob-* (level *world*) dx dy dz) (eq (get-mob-* (level *world*) dx dy dz) mob) (> light-power (brightness mob))) (setf (brightness mob) light-power)) (decf light-power *light-power-faloff*) (when (<= vision-pwr 0) (setf exit-result 'exit) (return))) exit-result)))) ;; set up nearby stationary light sources for player (when (and (eq mob *player*) (< (get-distance-3d x y z (x mob) (y mob) (z mob)) (+ light-radius (cur-sight mob)))) (push (list x y z light-radius) (nearby-light-sources *player*))) ) (loop with nearest-evil = nil with nearest-good = nil for mob-id of-type fixnum in (if (mob-ability-p mob +mob-abil-shared-minds+) (mob-id-list (level *world*)) (loop with result = () for (qx qy) of-type (fixnum fixnum) in '((-1 -1) (-1 0) (-1 1) (0 -1) (0 0) (0 1) (1 -1) (1 0) (1 1)) when (and (>= (+ quad-x qx) 0) (>= (+ quad-y qy) 0) (< (+ quad-x qx) (array-dimension (mob-quadrant-map (level *world*)) 0)) (< (+ quad-y qy) (array-dimension (mob-quadrant-map (level *world*)) 1))) do (setf result (append result (aref (mob-quadrant-map (level *world*)) (+ quad-x qx) (+ quad-y qy)))) finally (return result))) for tmob of-type mob = (get-mob-by-id mob-id) for vision-pwr of-type fixnum = (cur-sight mob) for vision-power of-type fixnum = (cur-sight mob) for light-power of-type fixnum = (* *light-power-faloff* (abs (cur-light tmob))) for light-pwr of-type fixnum = (abs (cur-light tmob)) for light-power-base of-type fixnum = (abs (cur-light tmob)) do ;; find nearest evil mob (when (and (not (check-dead tmob)) (mob-ability-p tmob +mob-abil-demon+) (not (eq tmob mob))) (unless nearest-evil (setf nearest-evil tmob)) (when (< (get-distance (x mob) (y mob) (x tmob) (y tmob)) (get-distance (x mob) (y mob) (x nearest-evil) (y nearest-evil))) (setf nearest-evil tmob))) ;; find nearest good mob (when (and (not (check-dead tmob)) (mob-ability-p tmob +mob-abil-angel+) (not (eq tmob mob))) (unless nearest-good (setf nearest-good tmob)) (when (< (get-distance (x mob) (y mob) (x tmob) (y tmob)) (get-distance (x mob) (y mob) (x nearest-good) (y nearest-good))) (setf nearest-good tmob))) ;; if you share minds with your faction - add all your faction mobs and all mobs that they see ;; except for trinity mimic - they share minds only with their own union (when (and (not (eq mob tmob)) (mob-ability-p mob +mob-abil-shared-minds+) (mob-ability-p tmob +mob-abil-shared-minds+) (= (faction mob) (faction tmob)) (or (and (not (mob-ability-p mob +mob-abil-trinity-mimic+)) (not (mob-ability-p tmob +mob-abil-trinity-mimic+))) (and (mob-ability-p mob +mob-abil-trinity-mimic+) (mob-ability-p tmob +mob-abil-trinity-mimic+) (find (id mob) (mimic-id-list tmob))))) (pushnew mob-id (shared-visible-mobs mob)) ;(format t "~A [~A] sees ~A~%" (name tmob) (id tmob) (visible-mobs tmob)) (loop for vmob-id in (proper-visible-mobs tmob) when (and (not (check-dead (get-mob-by-id vmob-id))) (not (is-merged (get-mob-by-id vmob-id)))) do (pushnew vmob-id (shared-visible-mobs mob))) (setf (shared-visible-mobs mob) (remove (id mob) (shared-visible-mobs mob)))) ;; you see all mobs that you have parasites on (when (and (not (eq mob tmob)) (mob-ability-p mob +mob-abil-primordial+) (mob-effect-p tmob +mob-effect-parasite+)) (pushnew mob-id (shared-visible-mobs mob)) (setf (shared-visible-mobs mob) (remove (id mob) (shared-visible-mobs mob)))) ;; set up mob brightness (when (and (< (get-distance-3d (x tmob) (y tmob) (z tmob) (x mob) (y mob) (z mob)) (abs (cur-light tmob))) ;(not (eq mob tmob)) ) (line-of-sight (x tmob) (y tmob) (z tmob) (x mob) (y mob) (z mob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (pwr-decrease 0)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf light-pwr (truncate (* light-power-base pwr-decrease) 100)) (decf light-pwr) (if (> (cur-light tmob) 0) (progn ;; if the light emitted by a mob is positive - increase brightness (when (and (get-mob-* (level *world*) dx dy dz) (eq (get-mob-* (level *world*) dx dy dz) mob) (> light-power (brightness mob))) (setf (brightness mob) light-power)) (decf light-power *light-power-faloff*)) (progn ;; if the light emitted by a mob is positive - increase darkness (when (and (get-mob-* (level *world*) dx dy dz) (eq (get-mob-* (level *world*) dx dy dz) mob) (> light-power (darkness mob))) (setf (darkness mob) light-power)) (decf light-power *dark-power-faloff*))) (when (<= light-pwr 0) (setf exit-result 'exit) (return))) exit-result)))) ;; set up visible mobs (when (and (not (eq mob tmob)) (< (get-distance-3d (x mob) (y mob) (z mob) (x tmob) (y tmob) (z tmob)) (cur-sight mob))) (line-of-sight (x mob) (y mob) (z mob) (x tmob) (y tmob) (z tmob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (mob-id 0) (pwr-decrease 0)) (declare (type fixnum mob-id)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) (when (and (get-mob-* (level *world*) dx dy dz) (not (eq (get-mob-* (level *world*) dx dy dz) mob)) (check-mob-visible (get-mob-* (level *world*) dx dy dz) :observer mob)) ;;(format t "VISIBILITY ~A ~A" (name (get-mob-* (level *world*) dx dy dz)) (get-mob-visibility (get-mob-* (level *world*) dx dy dz))) (setf mob-id (id (get-mob-* (level *world*) dx dy dz))) (pushnew mob-id (proper-visible-mobs mob))) (when (<= vision-pwr 0) (setf exit-result 'exit) (return)) ) exit-result)))) ;; set up nearby mobs that are light sources for player (when (and (eq mob *player*) (not (zerop (cur-light tmob))) (< (get-distance-3d (x tmob) (y tmob) (z tmob) (x mob) (y mob) (z mob)) (+ (cur-light tmob) (cur-sight mob)))) (push (id tmob) (nearby-light-mobs *player*))) ;; set up mobs that potentially hear you (when (and (not (eq mob tmob)) (< (get-distance-3d (x tmob) (y tmob) (z tmob) (x mob) (y mob) (z mob)) *max-hearing-range*)) (pushnew mob-id (hear-range-mobs mob))) finally (if (and nearest-evil (mob-ability-p mob +mob-abil-detect-evil+)) (setf (sense-evil-id mob) (id nearest-evil)) (setf (sense-evil-id mob) nil)) (if (and nearest-good (mob-ability-p mob +mob-abil-detect-good+)) (setf (sense-good-id mob) (id nearest-good)) (setf (sense-good-id mob) nil)) ) ) (when (eq mob *player*) (calc-lit-tiles-for-player *player*)) (incf (brightness mob) (get-outdoor-light-* (level *world*) (x mob) (y mob) (z mob))) (decf (brightness mob) (darkness mob)) ;; find nearby mobs that are casting shadows and check if the tile in question is the tile they are casting shadows to (when (>= (brightness mob) *mob-visibility-threshold*) (check-surroundings (x mob) (y mob) nil #'(lambda (dx dy) (when (and (>= dx 0) (< dx (array-dimension (terrain (level *world*)) 0)) (>= dy 0) (< dy (array-dimension (terrain (level *world*)) 1)) (get-mob-* (level *world*) dx dy (z mob)) (mob-effect-p (get-mob-* (level *world*) dx dy (z mob)) +mob-effect-casting-shadow+)) (let ((effect (get-effect-by-id (mob-effect-p (get-mob-* (level *world*) dx dy (z mob)) +mob-effect-casting-shadow+)))) (when (and (= (+ dx (first (param1 effect))) (x mob)) (= (+ dy (second (param1 effect))) (y mob))) (setf (brightness mob) (- *mob-visibility-threshold* 10)))))))) ;; if the mob is glowing - increase its brightness by 100 (when (mob-effect-p mob +mob-effect-glowing+) (incf (brightness mob) 100)) (when (< (brightness mob) 0) (setf (brightness mob) 0)) (setf (visible-mobs mob) (append (proper-visible-mobs mob) (shared-visible-mobs mob))) (setf (visible-mobs mob) (remove-duplicates (visible-mobs mob)))) (defun update-visible-mobs-fov (mob) (declare (optimize (speed 3))) (draw-fov (x mob) (y mob) (z mob) (cur-sight mob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (mob-id 0) (cur-sight (cur-sight mob)) (cur-sight-1 (1+ cur-sight)) (dist (get-distance-3d (x mob) (y mob) (z mob) dx dy dz))) (declare (type fixnum mob-id cur-sight cur-sight-1) (type float dist)) (block nil (when (> dist cur-sight-1) (setf exit-result 'exit) (return)) (unless (check-LOS-propagate dx dy dz prev-cell :check-vision t) (setf exit-result 'exit) (return)) (when (and (get-mob-* (level *world*) dx dy dz) (not (eq (get-mob-* (level *world*) dx dy dz) mob))) (setf mob-id (id (get-mob-* (level *world*) dx dy dz))) (pushnew mob-id (visible-mobs mob))) ) exit-result))) ) (defun update-visible-mobs-all (mob) (loop for mob-id in (mob-id-list (level *world*)) do (when (/= mob-id (id mob)) (pushnew mob-id (visible-mobs mob))))) (defun update-visible-mobs (mob) (setf (visible-mobs mob) nil) (setf (proper-visible-mobs mob) nil) (setf (shared-visible-mobs mob) nil) (setf (hear-range-mobs mob) nil) (if (mob-ability-p mob +mob-abil-see-all+) (update-visible-mobs-all mob) (update-visible-mobs-normal mob)) (when (eq mob *player*) (setf (view-x *player*) (x *player*)) (setf (view-y *player*) (y *player*))) (log:info "~A [~A] sees ~A" (name mob) (id mob) (visible-mobs mob)) ) (defun update-visible-items (mob) (declare (optimize (speed 3) (safety 0))) (setf (visible-items mob) nil) (loop for item-id in (loop with result = () for (qx qy) of-type (fixnum fixnum) in '((-1 -1) (-1 0) (-1 1) (0 -1) (0 0) (0 1) (1 -1) (1 0) (1 1)) when (and (>= (+ (truncate (x mob) 10) qx) 0) (>= (+ (truncate (y mob) 10) qy) 0) (< (+ (truncate (x mob) 10) qx) (array-dimension (item-quadrant-map (level *world*)) 0)) (< (+ (truncate (y mob) 10) qy) (array-dimension (item-quadrant-map (level *world*)) 1))) do (setf result (append result (aref (item-quadrant-map (level *world*)) (+ (truncate (x mob) 10) qx) (+ (truncate (y mob) 10) qy)))) finally (return result)) for item = (get-item-by-id item-id) for vision-pwr = (cur-sight mob) for vision-power = (cur-sight mob) when (< (get-distance-3d (x mob) (y mob) (z mob) (x item) (y item) (z item)) (cur-sight mob)) do ;; set up visible mobs (line-of-sight (x mob) (y mob) (z mob) (x item) (y item) (z item) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (pwr-decrease 0)) (block nil (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) ;(unless (check-LOS-propagate dx dy dz prev-cell :check-vision t) ; (setf exit-result 'exit) ; (return)) (when (get-items-* (level *world*) dx dy dz) (loop for n-item-id in (get-items-* (level *world*) dx dy dz) when (= item-id n-item-id) do (pushnew n-item-id (visible-items mob)))) (when (<= vision-pwr 0) (setf exit-result 'exit) (return)) ) exit-result)))) (log:info "~A [~A] sees ~A" (name mob) (id mob) (visible-items mob))) (defun update-visible-items-player () (setf (visible-items *player*) nil) (let ((vision-power (1+ (cur-sight *player*))) (vision-pwr (1+ (cur-sight *player*)))) (draw-fov (x *player*) (y *player*) (z *player*) (cur-sight *player*) #'(lambda (dx dy dz prev-cell) (let ((exit-result t) (pwr-decrease)) (block nil (when (> (get-distance-3d (x *player*) (y *player*) (z *player*) dx dy dz) (1+ (cur-sight *player*))) (setf exit-result 'exit) (return)) (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t )) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) (when (get-items-* (level *world*) dx dy dz) (loop for n-item-id in (get-items-* (level *world*) dx dy dz) do (pushnew n-item-id (visible-items *player*)))) (when (<= vision-pwr 0) (setf exit-result 'exit) (return)) ) exit-result)) :LOS-start-func #'(lambda () (setf vision-pwr (1+ (cur-sight *player*)))) :no-z nil )) ) (defun reveal-cell-on-map (level map-x map-y map-z &key (reveal-mob t)) ;; drawing terrain (let ((glyph-idx) (glyph-color) (back-color) (player nil)) (if (and (or (eq (get-terrain-* level map-x map-y map-z) +terrain-floor-air+) (eq (get-terrain-* level map-x map-y map-z) +terrain-border-air+)) (> map-z 0) (get-terrain-type-trait (get-terrain-* level map-x map-y (1- map-z)) +terrain-trait-water+)) (progn (setf glyph-idx (glyph-idx (get-terrain-type-by-id (get-terrain-* level map-x map-y (1- map-z))))) (setf glyph-color (sdl:color :r 0 :g 0 :b 128)) (setf back-color (back-color (get-terrain-type-by-id (get-terrain-* level map-x map-y (1- map-z)))))) (progn (setf glyph-idx (glyph-idx (get-terrain-type-by-id (get-terrain-* level map-x map-y map-z)))) (setf glyph-color (glyph-color (get-terrain-type-by-id (get-terrain-* level map-x map-y map-z)))) (setf back-color (back-color (get-terrain-type-by-id (get-terrain-* level map-x map-y map-z)))) (when (< (get-single-memo-light (get-memo-* level map-x map-y map-z)) *mob-visibility-threshold*) (setf glyph-color (sdl:color :r 25 :g 25 :b 112))))) ;; then feature, if any (if (and (or (eq (get-terrain-* level map-x map-y map-z) +terrain-floor-air+) (eq (get-terrain-* level map-x map-y map-z) +terrain-border-air+)) (> map-z 0) (get-terrain-type-trait (get-terrain-* level map-x map-y (1- map-z)) +terrain-trait-water+) (null (get-features-* level map-x map-y map-z))) (progn (when (get-features-* level map-x map-y (1- map-z)) (let ((ftr (get-feature-by-id (first (get-features-* level map-x map-y (1- map-z)))))) (when (glyph-idx (get-feature-type-by-id (feature-type ftr))) (setf glyph-idx (glyph-idx (get-feature-type-by-id (feature-type ftr))))) (when (glyph-color (get-feature-type-by-id (feature-type ftr))) (setf glyph-color (glyph-color (get-feature-type-by-id (feature-type ftr))))) (when (back-color (get-feature-type-by-id (feature-type ftr))) (setf back-color (back-color (get-feature-type-by-id (feature-type ftr))))) ))) (progn (when (get-features-* level map-x map-y map-z) (let ((ftr (get-feature-by-id (first (get-features-* level map-x map-y map-z))))) (when (glyph-idx (get-feature-type-by-id (feature-type ftr))) (setf glyph-idx (glyph-idx (get-feature-type-by-id (feature-type ftr))))) (when (glyph-color (get-feature-type-by-id (feature-type ftr))) (setf glyph-color (glyph-color (get-feature-type-by-id (feature-type ftr)))) (when (< (get-single-memo-light (get-memo-* level map-x map-y map-z)) *mob-visibility-threshold*) (setf glyph-color (sdl:color :r 25 :g 25 :b 112)))) (when (back-color (get-feature-type-by-id (feature-type ftr))) (setf back-color (back-color (get-feature-type-by-id (feature-type ftr))))) )))) ;; then item, if any (when (get-items-* level map-x map-y map-z) (let ((vitem (get-item-by-id (first (get-items-* level map-x map-y map-z))))) (setf glyph-idx (glyph-idx vitem)) (setf glyph-color (glyph-color vitem)) (setf back-color (back-color vitem)) (when (< (get-single-memo-light (get-memo-* level map-x map-y map-z)) *mob-visibility-threshold*) (setf glyph-color (sdl:color :r 25 :g 25 :b 112))) )) ;; finally mob, if any (when (and reveal-mob (get-mob-* level map-x map-y map-z)) (let ((vmob (get-mob-* level map-x map-y map-z))) (setf glyph-idx (get-current-mob-glyph-idx vmob :x map-x :y map-y :z map-z)) (setf glyph-color (get-current-mob-glyph-color vmob)) (setf back-color (get-current-mob-back-color vmob)) (when (eq vmob *player*) (setf player t)) ) ) (set-single-memo-* level map-x map-y map-z :glyph-idx glyph-idx :glyph-color glyph-color :back-color back-color :visibility t :revealed t :player player) )) (defun update-visible-area-normal (level x y z &key (no-z nil)) (let ((vision-power (1+ (cur-sight *player*))) (vision-pwr (1+ (cur-sight *player*)))) (setf (visible-z-list *player*) ()) (draw-fov x y z (cur-sight *player*) #'(lambda (dx dy dz prev-cell) (let ((exit-result t) (pwr-decrease)) (block nil (when (> (get-distance-3d x y z dx dy dz) (1+ (cur-sight *player*))) (setf exit-result 'exit) (return)) (setf pwr-decrease (check-LOS-propagate dx dy dz prev-cell :check-vision t :player-reveal-cell t)) (unless pwr-decrease (setf exit-result 'exit) (return)) (decf vision-pwr (truncate (* vision-power pwr-decrease) 100)) (decf vision-pwr) (when (and (get-mob-* level dx dy dz) (not (eq (get-mob-* level dx dy dz) *player*)) (check-mob-visible (get-mob-* level dx dy dz) :observer *player*) ) ;(format t "~A [~A] (~A ~A ~A)~%" (name (get-mob-* level dx dy dz)) (id (get-mob-* level dx dy dz)) dx dy dz) (pushnew (id (get-mob-* level dx dy dz)) (proper-visible-mobs *player*)) ) (when (<= vision-pwr 0) (setf exit-result 'exit) (return)) ) exit-result)) :LOS-start-func #'(lambda () (setf vision-pwr (1+ (cur-sight *player*)))) :no-z no-z )) (setf (visible-mobs *player*) (append (proper-visible-mobs *player*) (shared-visible-mobs *player*))) (setf (visible-mobs *player*) (remove-duplicates (visible-mobs *player*))) (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) do (reveal-cell-on-map (level *world*) (x mob) (y mob) (z mob) :reveal-mob t) ;; if the terrain has no floor, you can see an indication that there is a mob on the tile below (when (and (< (z mob) (1- (array-dimension (terrain (level *world*)) 2))) (get-single-memo-visibility (get-memo-* level (x mob) (y mob) (1+ (z mob)))) (get-single-memo-revealed (get-memo-* level (x mob) (y mob) (1+ (z mob)))) (not (get-terrain-type-trait (get-terrain-* level (x mob) (y mob) (1+ (z mob))) +terrain-trait-blocks-move-floor+)) ) (if (get-faction-relation (faction *player*) (get-visible-faction mob)) (set-single-memo-* (level *world*) (x mob) (y mob) (1+ (z mob)) :back-color sdl:*blue*) (set-single-memo-* (level *world*) (x mob) (y mob) (1+ (z mob)) :back-color sdl:*red*)))) ) (defun update-visible-area-all (level x y z) (declare (ignore x y z)) ;; update visible area (dotimes (x1 (array-dimension (memo (level *world*)) 0)) (dotimes (y1 (array-dimension (memo (level *world*)) 1)) (dotimes (z1 (array-dimension (memo (level *world*)) 2)) (reveal-cell-on-map level x1 y1 z1) )))) (defun update-visible-area (level x y z &key (no-z nil)) ;; make the the whole level invisible (dotimes (x1 (array-dimension (memo (level *world*)) 0)) (dotimes (y1 (array-dimension (memo (level *world*)) 1)) (dotimes (z1 (array-dimension (memo (level *world*)) 2)) (if (get-single-memo-revealed (get-memo-* level x1 y1 z1)) (set-single-memo-* level x1 y1 z1 :glyph-color (sdl:color :r 50 :g 50 :b 50) :back-color sdl:*black* :visibility nil) (set-single-memo-* level x1 y1 z1 :visibility nil)) ))) (setf (visible-mobs *player*) nil) (setf (proper-visible-mobs *player*) nil) ;(setf (shared-visible-mobs *player*) nil) (if (mob-ability-p *player* +mob-abil-see-all+) (update-visible-area-all level x y z) (update-visible-area-normal level x y z :no-z no-z)) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) (log:info "PLAYER-VISIBLE-MOBS: ~A" (visible-mobs *player*)) ) (defun draw-fov (cx cy cz r func &key (limit-z nil) (no-z nil) (LOS-start-func #'(lambda () nil))) (declare (optimize (speed 3))) (declare (type fixnum cx cy cz r) (type function func LOS-start-func)) (let ((target-cells nil) (max-z (if limit-z (if (>= (+ cz r) (array-dimension (terrain (level *world*)) 2)) (1- (array-dimension (terrain (level *world*)) 2)) (+ cz r)) (+ cz r))) (min-z (if limit-z (if (< (- cz r) 0) 0 (- cz r)) (- cz r)))) (declare (type fixnum max-z min-z)) (when no-z (setf min-z cz max-z cz)) ;; push the top & bottom z-plane (loop for x from (- r) to r for dx of-type fixnum = (+ cx x) do (loop for y from (- r) to r for dy of-type fixnum = (+ cy y) do (push (list dx dy min-z) target-cells) (push (list dx dy max-z) target-cells))) ;; push all z-planes in between (loop for z of-type fixnum from (1+ min-z) to (1- max-z) for xr+ of-type fixnum = (+ cx r) for xr- of-type fixnum = (- cx r) for yr+ of-type fixnum = (+ cy r) for yr- of-type fixnum = (- cy r) do (loop for n from (- r) to r for xn of-type fixnum = (+ cx n) do (push (list xn yr+ z) target-cells) (push (list xn yr- z) target-cells)) (loop for n from (- r) to r for yn of-type fixnum = (+ cy n) do (push (list xr+ yn z) target-cells) (push (list xr- yn z) target-cells)) ) ;; check LOS for all perimeter cells (loop for (tx ty tz) in target-cells do (funcall LOS-start-func) (line-of-sight cx cy cz tx ty tz func)) )) (defun draw-fov-old (cx cy cz r func) (declare (optimize (speed 3))) (declare (type fixnum cx cy cz r) (type function func)) (let ((target-cells nil)) (loop for i of-type fixnum from 0 to 360 by 1 for tx of-type fixnum = (+ cx (round (* r (cos (* i (/ pi 180)))))) for ty of-type fixnum = (- cy (round (* r (sin (* i (/ pi 180 )))))) do (unless (find (cons tx ty) target-cells :test #'equal) (push (cons tx ty) target-cells))) (loop for (tx . ty) in target-cells do (line-of-sight cx cy cz tx ty cz func)) )) (defun line-of-sight (x0 y0 z0 x1 y1 z1 func) (declare (optimize (speed 3)) (type fixnum x0 x1 y0 y1 z0 z1) (type function func)) (let* ((dx (abs (- x1 x0))) (dy (abs (- y1 y0))) (dz (abs (- z1 z0))) (sx (if (< x0 x1) 1 -1)) (sy (if (< y0 y1) 1 -1)) (sz (if (< z0 z1) 1 -1)) (dm (max dx dy dz)) (i dm)) (declare (type fixnum dx dy dz sx sy sz dm i)) (setf x1 (truncate dm 2) y1 (truncate dm 2) z1 (truncate dm 2)) (loop with prev-cell = nil while (and (not (< i 0)) (not (eq (funcall func x0 y0 z0 prev-cell) 'exit))) do (decf i) (setf prev-cell (list x0 y0 z0)) (decf x1 dx) (decf y1 dy) (decf z1 dz) (when (< x1 0) (incf x1 dm) (incf x0 sx)) (when (< y1 0) (incf y1 dm) (incf y0 sy)) (when (< z1 0) (incf z1 dm) (incf z0 sz)) )) ) (defun update-visible-mobs-cube (mob) (let ((max-x (if (>= (+ (x mob) (cur-sight mob)) (array-dimension (terrain (level *world*)) 0)) (1- (array-dimension (terrain (level *world*)) 0)) (+ (x mob) (cur-sight mob)))) (min-x (if (< (- (x mob) (cur-sight mob)) 0) 0 (- (x mob) (cur-sight mob)))) (max-y (if (>= (+ (y mob) (cur-sight mob)) (array-dimension (terrain (level *world*)) 1)) (1- (array-dimension (terrain (level *world*)) 1)) (+ (y mob) (cur-sight mob)))) (min-y (if (< (- (y mob) (cur-sight mob)) 0) 0 (- (y mob) (cur-sight mob)))) (max-z (if (>= (+ (z mob) (cur-sight mob)) (array-dimension (terrain (level *world*)) 2)) (1- (array-dimension (terrain (level *world*)) 2)) (+ (z mob) (cur-sight mob)))) (min-z (if (< (- (z mob) (cur-sight mob)) 0) 0 (- (z mob) (cur-sight mob))))) (loop for dx from min-x to max-x do (loop for dy from min-y to max-y do (loop for dz from min-z to max-z do (block nil ;(when (or (< dx 0) (< dy 0) (< dz 0) (>= dx (array-dimension (terrain (level *world*)) 0)) (>= dy (array-dimension (terrain (level *world*)) 1)) (>= dz (array-dimension (terrain (level *world*)) 2))) ; (return)) (when (get-mob-* (level *world*) dx dy dz) (line-of-sight (x mob) (y mob) (z mob) dx dy dz #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t) (mob-id 0) (cur-sight (cur-sight mob)) (cur-sight-1 (1+ cur-sight)) (dist (get-distance-3d (x mob) (y mob) (z mob) dx dy dz))) (declare (type fixnum mob-id cur-sight cur-sight-1) (type float dist)) (block nil (when (> dist cur-sight-1) (setf exit-result 'exit) (return)) (unless (check-LOS-propagate dx dy dz prev-cell :check-vision t) (setf exit-result 'exit) (return)) (when (and (get-mob-* (level *world*) dx dy dz) (not (eq (get-mob-* (level *world*) dx dy dz) mob))) (setf mob-id (id (get-mob-* (level *world*) dx dy dz))) (pushnew mob-id (visible-mobs mob))) ) exit-result)))) )))))) (defun fov-shadow-casting (cx cy r opaque-func vis-func) (funcall vis-func cx cy) (labels ((compute (octant sx sy r x top bottom) (loop for x1 from x to r with top-y with bottom-y with was-opaque do (setf top-y (if (= (car top) 1) x1 (truncate (+ (* (1+ (* x1 2)) (cdr top)) (car top) -1) (* 2 (car top))))) (setf bottom-y (if (= (cdr bottom) 0) 0 (truncate (+ (* (- (* 2 x1) 1) (cdr bottom)) (car bottom)) (* 2 (car bottom))))) (setf was-opaque -1) ;; 0:false, 1:true, -1:not applicable ;(format t "LOOP 1: x1 ~A was-opaque ~A~%" x1 was-opaque) (loop for y1 from top-y downto bottom-y with tx with ty with in-range with is-opaque do (setf tx sx) (setf ty sy) (cond ((= octant 0) (incf tx x1) (decf ty y1)) ((= octant 1) (incf tx y1) (decf ty x1)) ((= octant 2) (decf tx y1) (decf ty x1)) ((= octant 3) (decf tx x1) (decf ty y1)) ((= octant 4) (decf tx x1) (incf ty y1)) ((= octant 5) (decf tx y1) (incf ty x1)) ((= octant 6) (incf tx y1) (incf ty x1)) ((= octant 7) (incf tx x1) (incf ty y1)) ) (setf in-range (< (get-distance sx sy tx ty) r)) (when (and in-range (or (/= y1 top-y) (>= (* (cdr top) x1) (* (car top) y1))) (or (/= y1 bottom-y) (<= (* (cdr bottom) x1) (* (car bottom) y1))) ) (funcall vis-func tx ty)) (setf is-opaque (or (not in-range) (funcall opaque-func tx ty))) ;(format t "LOOP 2: tx ~A, ty ~A, was-opaque ~A, is-opaque ~A, octant ~A~%" tx ty was-opaque is-opaque octant) (when (/= x1 r) (if is-opaque (progn (when (= was-opaque 0) (if (or (not in-range) (= y1 bottom-y)) (progn (setf bottom (cons (- (* x1 2) 1) (1+ (* y1 2)) )) (loop-finish)) (progn ;(format t "LOOP: tx ~A, ty ~A, opaque ~A, was-opaque ~A, dist ~A vs r ~A~%" tx ty is-opaque was-opaque (get-distance sx sy tx ty) r) (compute octant sx sy r (1+ x1) top (cons (- (* x1 2) 1) (1+ (* y1 2)))))) ) (setf was-opaque 1)) (progn (when (> was-opaque 0) (setf top (cons (1+ (* x1 2)) (1+ (* y1 2)) ))) (setf was-opaque 0)))) ) (when (/= was-opaque 0) (loop-finish)) ))) (loop for octant from 0 below 8 do (compute octant cx cy r 1 (cons 1 1) (cons 1 0))) ) ) (defun fov-milazzo-algorithm (cx cy r opaque-func vis-func) (declare (optimize (speed 3))) (declare (type fixnum cx cy r) (type function opaque-func vis-func)) (funcall vis-func cx cy) (labels ((>-slope (slope x y) (declare (type fixnum x y) (type cons slope)) (return-from >-slope (> (* (cdr slope) x) (* (car slope) y)))) (>=-slope (slope x y) (declare (type fixnum x y) (type cons slope)) (return-from >=-slope (>= (* (cdr slope) x) (* (car slope) y)))) (<-slope (slope x y) (declare (type fixnum x y) (type cons slope)) (return-from <-slope (< (* (cdr slope) x) (* (car slope) y)))) (<=-slope (slope x y) (declare (type fixnum x y) (type cons slope)) (return-from <=-slope (<= (* (cdr slope) x) (* (car slope) y)))) (blocks-light (x y octant sx sy) (declare (type fixnum x y octant sx sy)) (let ((nx sx) (ny sy)) (cond ((= octant 0) (incf nx x) (decf ny y)) ((= octant 1) (incf nx y) (decf ny x)) ((= octant 2) (decf nx y) (decf ny x)) ((= octant 3) (decf nx x) (decf ny y)) ((= octant 4) (decf nx x) (incf ny y)) ((= octant 5) (decf nx y) (incf ny x)) ((= octant 6) (incf nx y) (incf ny x)) ((= octant 7) (incf nx x) (incf ny y))) (funcall opaque-func nx ny))) (set-visible (x y octant sx sy) (declare (type fixnum x y octant sx sy)) (let ((nx sx) (ny sy)) (cond ((= octant 0) (incf nx x) (decf ny y)) ((= octant 1) (incf nx y) (decf ny x)) ((= octant 2) (decf nx y) (decf ny x)) ((= octant 3) (decf nx x) (decf ny y)) ((= octant 4) (decf nx x) (incf ny y)) ((= octant 5) (decf nx y) (incf ny x)) ((= octant 6) (incf nx y) (incf ny x)) ((= octant 7) (incf nx x) (incf ny y))) (funcall vis-func nx ny))) (compute (octant sx sy r x top bottom) (declare (type fixnum sx sy r x) (type cons top bottom)) (loop for x1 from x to r with top-y of-type fixnum with ax of-type fixnum with bottom-y of-type fixnum with was-opaque of-type fixnum do (if (= (cdr top) 1) (setf top-y x1) (progn (setf top-y (truncate (+ (* (- (* x1 2) 1) (cdr top)) (car top)) (* 2 (car top)))) (if (blocks-light x1 top-y octant sx sy) (progn (when (and (>=-slope top (* x1 2) (1+ (* top-y 2))) (not (blocks-light x1 (1+ top-y) octant sx sy))) (incf top-y))) (progn (setf ax (* x1 2)) (when (blocks-light (1+ x1) (1+ top-y) octant sx sy) (incf ax)) (when (>-slope top ax (1+ (* top-y 2))) (incf top-y)))))) (if (= (cdr bottom) 0) (setf bottom-y 0) (progn (setf bottom-y (truncate (+ (* (- (* x1 2) 1) (cdr bottom)) (car bottom)) (* 2 (car bottom)))) (when (and (>=-slope bottom (* x1 2) (1+ (* bottom-y 2))) (blocks-light x1 bottom-y octant sx sy) (not (blocks-light x1 (1+ bottom-y) octant sx sy))) (incf bottom-y)))) (setf was-opaque -1) ;;0:false, 1:true, -1:not applicable (loop for y1 from top-y downto bottom-y with is-opaque of-type boolean with is-visible of-type boolean with nx of-type fixnum with ny of-type fixnum do (when (< (get-distance 0 0 x1 y1) r) (setf is-opaque (blocks-light x1 y1 octant sx sy)) (setf is-visible (or is-opaque (and (or (/= y1 top-y) (>=-slope top x1 y1)) (or (/= y1 bottom-y) (<=-slope bottom x1 y1))))) ;(setf is-visible (or is-opaque ; (and (or (/= y1 top-y) ; (>-slope top (1+ (* x1 7)) (- (* y1 7) 1))) ; (or (/= y1 bottom-y) ; (<-slope bottom (- (* x1 7) 1) (+ (* y1 7) 1)))))) (when is-visible (set-visible x1 y1 octant sx sy)) (when (/= x1 r) (if is-opaque (progn (when (= was-opaque 0) (setf nx (* x1 2)) (setf ny (1+ (* y1 2))) (when (blocks-light x1 (1+ y1) octant sx sy) (decf nx)) (if (>-slope top nx ny) (if (= y1 bottom-y) (progn (setf bottom (cons nx ny)) (loop-finish)) (compute octant sx sy r (1+ x1) top (cons nx ny))) (when (= y1 bottom-y) (return-from compute nil)))) (setf was-opaque 1)) (progn (when (> was-opaque 0) (setf nx (* x1 2)) (setf ny (1+ (* y1 2))) (when (blocks-light (1+ x1) (1+ y1) octant sx sy) (incf nx)) (when (>=-slope bottom nx ny) (return-from compute nil)) (setf top (cons nx ny))) (setf was-opaque 0)))))) (when (/= was-opaque 0) (loop-finish)) ))) (loop for octant from 0 below 8 do (compute octant cx cy r 1 (cons 1 1) (cons 1 0))) ))
65,117
Common Lisp
.lisp
1,020
38.218627
218
0.419378
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
67bb4006d85f8cda7a8bf865e1550f39ae90b2a8d9a0d7f43dcc9376034e56d4
2,851
[ -1 ]
2,852
lvl-features.lisp
gwathlobal_CotD/src/lvl-features.lisp
(in-package :cotd) ;;---------------------- ;; FEATURE-TYPE ;;---------------------- (defclass feature-type () ((id :initarg :id :accessor id :type fixnum) (glyph-idx :initform 0 :initarg :glyph-idx :accessor glyph-idx) (glyph-color :initform sdl:*white* :initarg :glyph-color :accessor glyph-color :type sdl:color) (back-color :initform sdl:*black* :initarg :back-color :accessor back-color :type sdl:color) (name :initform "No name feature" :initarg :name :accessor name) (trait :initform (make-hash-table) :initarg :trait :accessor trait) ;; :trait-blocks-vision - +feature-trait-blocks-vision+ ;; :trait-smoke - +feature-trait-smoke+ ;; :trait-no-gravity - +feature-trait-no-gravity+ ;; :trait-fire - +feature-trait-fire+ ;; :trait-remove-on-dungeon-generation - +feature-trait-remove-on-dungeon-generation+ ;; :trait-can-have-rune - +feature-trait-can-have-rune+ ;; :trait-demonic-rune - +feature-trait-demonic-rune+ (takes item-type-id that will be later used in deciphering the rune into an item) (can-merge-func :initform #'(lambda (level feature-new) (let ((result nil)) (loop for feat-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feat-old = (get-feature-by-id feat-old-id) when (= (feature-type feature-new) (feature-type feat-old)) do (setf result t) (loop-finish) ) result)) :initarg :can-merge-func :accessor can-merge-func) (merge-func :initform #'(lambda (level feature-new) (loop for feat-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feat-old = (get-feature-by-id feat-old-id) when (= (feature-type feature-new) (feature-type feat-old)) do (remove-feature-from-level-list (level *world*) feature-new) (remove-feature-from-world feature-new) (loop-finish) ) ) :initarg :merge-func :accessor merge-func) (on-tick-func :initform nil :initarg :on-tick-func :accessor on-tick-func) ;; a funcation that takes (level feature) )) (defun get-feature-type-by-id (feature-type-id) (aref *feature-types* feature-type-id)) (defun set-feature-type (feature-type) (when (>= (id feature-type) (length *feature-types*)) (adjust-array *feature-types* (list (1+ (id feature-type))))) (setf (aref *feature-types* (id feature-type)) feature-type)) (defmethod initialize-instance :after ((feature-type feature-type) &key trait-blocks-vision trait-smoke trait-no-gravity trait-fire trait-remove-on-dungeon-generation trait-demonic-rune) (when trait-blocks-vision (setf (gethash +feature-trait-blocks-vision+ (trait feature-type)) trait-blocks-vision)) (when trait-smoke (setf (gethash +feature-trait-smoke+ (trait feature-type)) trait-smoke)) (when trait-no-gravity (setf (gethash +feature-trait-no-gravity+ (trait feature-type)) trait-no-gravity)) (when trait-fire (setf (gethash +feature-trait-fire+ (trait feature-type)) trait-fire)) (when trait-remove-on-dungeon-generation (setf (gethash +feature-trait-remove-on-dungeon-generation+ (trait feature-type)) trait-remove-on-dungeon-generation)) (when trait-demonic-rune (setf (gethash +feature-trait-demonic-rune+ (trait feature-type)) trait-demonic-rune)) ) ;;-------------------- ;; FEATURE ;;-------------------- (defclass feature () ((id :initform 0 :initarg :id :accessor id :type fixnum) (feature-type :initform 0 :initarg :feature-type :accessor feature-type :type fixnum) (x :initarg :x :initform 0 :accessor x :type fixnum) (y :initarg :y :initform 0 :accessor y :type fixnum) (z :initarg :z :initform 0 :accessor z :type fixnum) (counter :initform 0 :initarg :counter :accessor counter :type fixnum) (param1 :initform nil :initarg :param1 :accessor param1) )) (defmethod initialize-instance :after ((feature feature) &key) (setf (id feature) (find-free-id *lvl-features*)) (setf (aref *lvl-features* (id feature)) feature) (when (and (zerop (counter feature)) (or (get-feature-type-trait feature +feature-trait-smoke+) (get-feature-type-trait feature +feature-trait-fire+))) (setf (counter feature) 1)) ) (defun get-feature-by-id (feature-id) (aref *lvl-features* feature-id)) (defun remove-feature-from-world (feature) (setf (feature-id-list (level *world*)) (remove (id feature) (feature-id-list (level *world*)))) (setf (aref *lvl-features* (id feature)) nil)) (defmethod name ((feature feature)) (name (get-feature-type-by-id (feature-type feature)))) (defmethod on-tick-func ((feature feature)) (on-tick-func (get-feature-type-by-id (feature-type feature)))) (defmethod can-merge-func ((feature feature)) (can-merge-func (get-feature-type-by-id (feature-type feature)))) (defmethod merge-func ((feature feature)) (merge-func (get-feature-type-by-id (feature-type feature)))) (defun get-feature-type-trait (feature feature-trait-id) (gethash feature-trait-id (trait (get-feature-type-by-id (feature-type feature))))) (defun feature-smoke-on-tick (level feature) (when (zerop (random 3)) (if (= (counter feature) 1) (progn (if (zerop (random 2)) (progn (remove-feature-from-level-list level feature) (remove-feature-from-world feature)) (progn (let ((dir (1+ (random 9))) (dir-z (1- (random 3))) (dx) (dy)) (cond ((= dir-z -1) (when (and (not (zerop (z feature))) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-projectiles+))) (remove-feature-from-level-list level feature) (decf (z feature)) (add-feature-to-level-list level feature))) ((= dir-z 1) (when (and (< (z feature) (1- (array-dimension (terrain level) 2))) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-projectiles+))) (remove-feature-from-level-list level feature) (incf (z feature)) (add-feature-to-level-list level feature))) (t (if (= (wind-dir level) 5) (multiple-value-setq (dx dy) (x-y-dir dir)) (multiple-value-setq (dx dy) (x-y-dir (wind-dir level)))) (setf dx (+ (x feature) dx) dy (+ (y feature) dy)) (when (and (not (get-terrain-type-trait (get-terrain-* level dx dy (z feature)) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level dx dy (z feature)) +terrain-trait-blocks-projectiles+))) (remove-feature-from-level-list level feature) (setf (x feature) dx) (setf (y feature) dy) (add-feature-to-level-list level feature)))) )))) (progn (let ((feature-new nil) (dir (1+ (random 9))) (dir-z (1- (random 3))) (dx) (dy)) (cond ((= dir-z -1) (when (and (not (zerop (z feature))) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (z feature)) +terrain-trait-blocks-projectiles+))) (setf feature-new (make-instance 'feature :feature-type (get-feature-type-trait feature +feature-trait-smoke+) :x (x feature) :y (y feature) :z (z feature))) (decf (counter feature)) (decf (z feature-new)) (add-feature-to-level-list level feature-new))) ((= dir-z 1) (when (and (< (z feature) (1- (array-dimension (terrain level) 2))) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level (x feature) (y feature) (1+ (z feature))) +terrain-trait-blocks-projectiles+))) (setf feature-new (make-instance 'feature :feature-type (get-feature-type-trait feature +feature-trait-smoke+) :x (x feature) :y (y feature) :z (z feature))) (decf (counter feature)) (incf (z feature-new)) (add-feature-to-level-list level feature-new))) (t (multiple-value-setq (dx dy) (x-y-dir dir)) (setf dx (+ (x feature) dx) dy (+ (y feature) dy)) (when (and (not (get-terrain-type-trait (get-terrain-* level dx dy (z feature)) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level dx dy (z feature)) +terrain-trait-blocks-projectiles+))) (setf feature-new (make-instance 'feature :feature-type (get-feature-type-trait feature +feature-trait-smoke+) :x (x feature) :y (y feature) :z (z feature))) (decf (counter feature)) (setf (x feature-new) dx) (setf (y feature-new) dy) (add-feature-to-level-list level feature-new)))) )))))
11,383
Common Lisp
.lisp
167
51.54491
187
0.553945
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
b5230ac914c6b3b2cecf9cc9e44e8f059e5346904e39904e6c8ad01eee2bfb2f
2,852
[ -1 ]
2,853
level-city.lisp
gwathlobal_CotD/src/level-city.lisp
(in-package :cotd) (defun create-template-city (template-level max-x max-y max-z set-max-buildings-func set-reserved-buildings-func &optional (terrains (list +level-city-park+ +building-city-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-floor+) +level-city-terrain-dirt+ #'(lambda () (if (< (random 100) 20) +terrain-floor-dirt-bright+ +terrain-floor-dirt+)) +level-city-terrain-grass+ #'(lambda () +terrain-floor-grass+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-birch+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-bush+) +level-city-terrain-earth+ #'(lambda () +terrain-wall-earth+)))) (log:info "Start") ;; make a template level ;; and an enlarged grid with scale 1 to 10 cells of template level ;; grid will be used to make reservations for buildings ;; once all places on grid are reserved, put actual buildings to the template level in places that were reserved (let* ((reserv-max-x (array-dimension template-level 0)) (reserv-max-y (array-dimension template-level 1)) ;(reserv-max-z max-z) (terrain-level (make-array (list max-x max-y max-z) :element-type 'fixnum :initial-element (funcall (getf terrains +level-city-terrain-border+)))) (feature-list ()) (mob-list ()) (item-list ()) (build-list ()) (max-building-types (make-hash-table)) (reserved-building-types (make-hash-table)) ) ;; set up maximum building types for this kind of map (when set-max-buildings-func (setf max-building-types (funcall set-max-buildings-func))) ;; set up reserved building types for this kind of map (when set-reserved-buildings-func (setf reserved-building-types (funcall set-reserved-buildings-func))) (print-reserved-level template-level) ;; make reservations from reserved buildings on the grid level (loop for gen-building-type-id being the hash-key in reserved-building-types do (loop repeat (gethash gen-building-type-id reserved-building-types) with build-cur-list = nil with build-picked = nil with x = 0 with y = 0 for avail-cells-list = (loop with result = () for x1 from 0 below reserv-max-x do (loop for y1 from 0 below reserv-max-y do (push (list x1 y1) result)) finally (return result)) do ;; prepare a list of buildings of this reserved type (setf build-cur-list (prepare-spec-build-id-list gen-building-type-id)) ;; pick a specific building type (setf build-picked (nth (random (length build-cur-list)) build-cur-list)) ;; try to pick an unoccupied place (loop for cell-pick = (nth (random (length avail-cells-list)) avail-cells-list) until (level-city-can-place-build-on-grid build-picked (first cell-pick) (second cell-pick) 2 template-level) do (setf avail-cells-list (remove cell-pick avail-cells-list)) (when (null avail-cells-list) (log:info "Could not place reserved building ~A" build-picked) (print-reserved-level template-level) (return-from create-template-city (values nil nil nil nil))) finally (setf x (first cell-pick) y (second cell-pick))) ;; if an unoccupied place is found, place the building (when build-picked ;; add the building to the building list and reserve the tiles for the bilding (level-city-reserve-build-on-grid build-picked x y 2 template-level) ;; decrease the maximum available number of buildings of this type (when (and (gethash (building-type (get-building-type build-picked)) max-building-types) (not (eq (gethash (building-type (get-building-type build-picked)) max-building-types) t))) (decf (gethash (building-type (get-building-type build-picked)) max-building-types)))) )) ;; make reservations for random buildings of the grid level (loop for y from 0 below reserv-max-y do (loop for x from 0 below reserv-max-x with build-picked = nil with build-cur-list = nil do ;; prepare the list of buildings ;; so that it becomes ((1 2 3) (4) (5 6) ...) (setf build-cur-list (prepare-gen-build-id-list max-building-types +building-type-house+)) ;; randomly pick a building and remove it from the list if it does not fit or the maximum number of this kind of buildings have been reached ;; until we find a building that fits or nothing is left (loop initially (multiple-value-setq (build-picked build-cur-list) (pick-building-randomly build-cur-list)) until (or (and (gethash (building-type (get-building-type build-picked)) max-building-types) (or (eq (gethash (building-type (get-building-type build-picked)) max-building-types) t) (> (gethash (building-type (get-building-type build-picked)) max-building-types) 0)) (level-city-can-place-build-on-grid build-picked x y 2 template-level)) ) do (unless build-cur-list (setf build-picked nil) (loop-finish)) (multiple-value-setq (build-picked build-cur-list) (pick-building-randomly build-cur-list)) ) ;; check if there was a building picked (when build-picked ;; if yes, add the building to the building list and reserve the tiles for the building (level-city-reserve-build-on-grid build-picked x y 2 template-level) ;; decrease the maximum available number of buildings of this type (when (and (gethash (building-type (get-building-type build-picked)) max-building-types) (not (eq (gethash (building-type (get-building-type build-picked)) max-building-types) t))) (decf (gethash (building-type (get-building-type build-picked)) max-building-types))) ) )) ;; fill all free spaces left with +level-city-park+ (loop for y from 0 below reserv-max-y do (loop for x from 0 below reserv-max-x do ;; check if you can place a tiny park (when (level-city-can-place-build-on-grid (getf terrains +level-city-park+) x y 2 template-level) ;; if yes, add the building to the building list & reserve the tiles for the building (level-city-reserve-build-on-grid (getf terrains +level-city-park+) x y 2 template-level) ) )) (loop for y from 0 below max-y do (loop for x from 0 below max-x do (loop for z from 3 below max-z do (setf (aref terrain-level x y z) +terrain-border-air+)))) (loop for y from 0 below max-y do (loop for x from 0 below max-x do (loop for z from 0 below 2 do (setf (aref terrain-level x y z) (if (getf terrains +level-city-terrain-earth+) (funcall (getf terrains +level-city-terrain-earth+)) +terrain-wall-earth+))))) (loop for y from 1 below (1- max-y) do (loop for x from 1 below (1- max-x) do (setf (aref terrain-level x y 2) (funcall (getf terrains +level-city-terrain-dirt+))) (loop for z from 3 below max-z do (setf (aref terrain-level x y z) +terrain-floor-air+)))) (print-reserved-level template-level) ;; create a building list from template-level (loop for x from 0 below reserv-max-x do (loop for y from 0 below reserv-max-y for building = (aref template-level x y 2) when (and (not (eq building t)) (not (eq building nil)) (not (find building build-list))) do (push building build-list))) ;; take buildings from the building list and actually place them on the template level (loop for (build-type-id gx gy gz) in build-list with px = 0 with py = 0 for building-mobs = nil for building-features = nil for building-items = nil do ;; find a random position within the grid on the template level so that the building does not violate the grid boundaries (destructuring-bind (adx . ady) (building-act-dim (get-building-type build-type-id)) (destructuring-bind (gdx . gdy) (building-grid-dim (get-building-type build-type-id)) (setf px (random (1+ (- (* *level-grid-size* gdx) adx)))) (setf py (random (1+ (- (* *level-grid-size* gdy) ady)))))) ;; place the actual building (when (building-func (get-building-type build-type-id)) (multiple-value-setq (building-mobs building-features building-items) (funcall (building-func (get-building-type build-type-id)) (+ (* gx *level-grid-size*) px) (+ (* gy *level-grid-size*) py) gz terrain-level terrains))) ;(log:info (format nil "CREATE-TEMPLATE-CITY: Building type ~A, mob list ~A~%" build-type-id building-mobs)) ;; add mobs to the mob-list (when building-mobs (loop for (mob-id lx ly lz) in building-mobs do (pushnew (list mob-id (+ (* gx *level-grid-size*) px lx) (+ (* gy *level-grid-size*) py ly) lz) mob-list))) ;; add features to the feature list (when building-features (loop for (feature-id lx ly lz) in building-features do (pushnew (list feature-id (+ (* gx *level-grid-size*) px lx) (+ (* gy *level-grid-size*) py ly) lz) feature-list))) ;; add items to the item list (when building-items (loop for (item-id lx ly lz qty) in building-items do (pushnew (list item-id (+ (* gx *level-grid-size*) px lx) (+ (* gy *level-grid-size*) py ly) lz qty) item-list))) ) ;; restore borders (loop for x from 0 below max-x do (loop for z from 0 below max-z for y-0 = 0 for y-max = (1- (array-dimension terrain-level 1)) do (cond ((= (aref terrain-level x y-0 z) +terrain-floor-air+) (setf (aref terrain-level x y-0 z) +terrain-border-air+)) ((= (aref terrain-level x y-0 z) +terrain-water-liquid+) (setf (aref terrain-level x y-0 z) +terrain-border-water+)) ((= (aref terrain-level x y-0 z) +terrain-water-liquid-nofreeze+) (setf (aref terrain-level x y-0 z) +terrain-border-water+))) (cond ((= (aref terrain-level x y-max z) +terrain-floor-air+) (setf (aref terrain-level x y-max z) +terrain-border-air+)) ((= (aref terrain-level x y-max z) +terrain-water-liquid+) (setf (aref terrain-level x y-max z) +terrain-border-water+)) ((= (aref terrain-level x y-max z) +terrain-water-liquid-nofreeze+) (setf (aref terrain-level x y-max z) +terrain-border-water+))))) (loop for y from 0 below max-y do (loop for z from 0 below max-z for x-0 = 0 for x-max = (1- (array-dimension terrain-level 0)) do (cond ((= (aref terrain-level x-0 y z) +terrain-floor-air+) (setf (aref terrain-level x-0 y z) +terrain-border-air+)) ((= (aref terrain-level x-0 y z) +terrain-water-liquid+) (setf (aref terrain-level x-0 y z) +terrain-border-water+)) ((= (aref terrain-level x-0 y z) +terrain-water-liquid-nofreeze+) (setf (aref terrain-level x-0 y z) +terrain-border-water+))) (cond ((= (aref terrain-level x-max y z) +terrain-floor-air+) (setf (aref terrain-level x-max y z) +terrain-border-air+)) ((= (aref terrain-level x-max y z) +terrain-water-liquid+) (setf (aref terrain-level x-max y z) +terrain-border-water+)) ((= (aref terrain-level x-max y z) +terrain-water-liquid-nofreeze+) (setf (aref terrain-level x-max y z) +terrain-border-water+))))) (values terrain-level mob-list item-list feature-list) )) (defun print-reserved-level (reserved-level) (let ((str (create-string))) (format str "~%") (loop for y from 0 below (array-dimension reserved-level 1) do (loop for x from 0 below (array-dimension reserved-level 0) do (format str "~3@A " (cond ((null (aref reserved-level x y 2)) "F") ((eq (aref reserved-level x y 2) t) "R") (t (first (aref reserved-level x y 2)))))) (format str "~%")) (log:info str))) (defun pick-building-randomly (build-cur-list) (let ((building-picked nil) (type-picked nil)) ;; first pick a general building type (setf type-picked (random (length build-cur-list))) ;; within a general building type pick a specific building type (setf building-picked (nth (random (length (nth type-picked build-cur-list))) (nth type-picked build-cur-list))) ;; remove the specific building type from the list (setf (nth type-picked build-cur-list) (remove building-picked (nth type-picked build-cur-list))) ;; remove the general building type if no specific ones are left (unless (nth type-picked build-cur-list) (setf build-cur-list (remove nil build-cur-list))) (values building-picked build-cur-list))) (defun prepare-gen-build-id-list (max-building-types &optional increased-build-type-id) ;; a hack to make houses appear 3 times more frequently (append (loop repeat 3 collect (prepare-spec-build-id-list increased-build-type-id)) (loop for gen-build-type-id being the hash-key in max-building-types collect (prepare-spec-build-id-list gen-build-type-id)))) (defun prepare-spec-build-id-list (gen-build-type-id) (loop for spec-build-type being the hash-value in *building-types* when (= (building-type spec-build-type) gen-build-type-id) collect (building-id spec-build-type)))
16,507
Common Lisp
.lisp
240
48.4625
161
0.538548
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
4dc21b214966fe75752af56172f44edfb7480ec47f73f0a7f25c818a2b0c72e3
2,853
[ -1 ]
2,854
gods.lisp
gwathlobal_CotD/src/gods.lisp
(in-package :cotd) (defconstant +malseraphs-piety-very-low+ 40) (defconstant +malseraphs-piety-low+ 80) (defconstant +malseraphs-piety-medium+ 120) (defconstant +malseraphs-piety-high+ 160) (defconstant +malseraphs-piety-very-high+ 200) (defclass god () ((id :initarg :id :accessor id) (name :initform "Unnamed god" :initarg :name :accessor name) (piety-level-func :initform #'(lambda (god piety-num) (declare (ignore god piety-num)) "") :initarg :piety-level-func :accessor piety-level-func) (piety-str-func :initform #'(lambda (god piety-num) (declare (ignore god piety-num)) "") :initarg :piety-str-func :accessor piety-str-func) (piety-tick-func :initform #'(lambda (god mob) (declare (ignore god mob)) nil) :initarg :piety-tick-func :accessor piety-tick-func) (piety-change-str-func :initform #'(lambda (god piety-num-new piety-num-old) (declare (ignore god piety-num-new piety-num-old)) "") :initarg :piety-change-str-func :accessor piety-change-str-func) )) (defun get-god-by-id (god-id) (aref *gods* god-id)) (defun set-god-type (god) (when (>= (id god) (length *gods*)) (adjust-array *gods* (list (1+ (id god))))) (setf (aref *gods* (id god)) god)) (defun return-piety-str (god-id piety-num) (funcall (piety-str-func (get-god-by-id god-id)) (get-god-by-id god-id) piety-num)) (defun get-worshiped-god-type (worshiped-god) (first worshiped-god)) (defun get-worshiped-god-piety (worshiped-god) (second worshiped-god)) (defun get-worshiped-god-param1 (worshiped-god) (third worshiped-god)) (defun get-worshiped-god-param2 (worshiped-god) (fourth worshiped-god)) (defun check-piety-level-changed (god-id piety-num-old piety-num-new) (let ((god (get-god-by-id god-id))) (if (/= (funcall (piety-level-func god) god piety-num-old) (funcall (piety-level-func god) god piety-num-new)) t nil))) (defun return-piety-change-str (god-id piety-num-new piety-num-old) (funcall (piety-change-str-func (get-god-by-id god-id)) (get-god-by-id god-id) piety-num-new piety-num-old)) (defun increase-piety-for-god (god-id mob piety-inc) (when (and (worshiped-god mob) (= (get-worshiped-god-type (worshiped-god mob)) god-id)) (set-mob-piety mob (+ (get-worshiped-god-piety (worshiped-god mob)) piety-inc))))
2,667
Common Lisp
.lisp
54
39.62963
110
0.605921
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
0cc6ee1252a204bb14c3f84e30e7fdd1da4c63d86ac832b7fb0bb7c45db57c15
2,854
[ -1 ]
2,855
highscores.lisp
gwathlobal_CotD/src/highscores.lisp
(in-package :cotd) (defclass highscores-record () ((player-name :initarg :player-name :accessor highscore-record/player-name :type string) (score :initarg :score :accessor highscore-record/score :type fixnum) (mob-type :initarg :mob-type :accessor highscore-record/mob-type :type string) (turns-num :initarg :turns-num :accessor highscore-record/turns-num :type fixnum) (result :initarg :result :accessor highscore-record/result :type string) (sector-name :initarg :sector-name :accessor highscore-record/sector-name :type string) (params :initform () :initarg :params :accessor highscore-record/params :type list))) (defclass highscores-table () ((version :initform 1 :initarg :version :accessor highscores-table/version :type fixnum) (records :initform () :initarg :records :accessor highscores-table/records :type list) (params :initform () :initarg :params :accessor highscores-table/params :type list))) (defun save-highscores-to-disk () (handler-case (let ((file-pathname (merge-pathnames (make-pathname :name *highscores-filename*) *current-dir*))) (cl-store:store *highscores* file-pathname)) (t (c) (log:info (format nil "~%SAVE-HIGHSCORES-TO-DISK: Error occured while saving to file: ~A.~%~%" c)))) nil) (defun load-highscores-from-disk () (let ((file-pathname (merge-pathnames (make-pathname :name *highscores-filename*) *current-dir*))) (handler-case (if (probe-file file-pathname) (setf *highscores* (cl-store:restore file-pathname)) (progn (log:info (format nil "~%LOAD-HIGHSCORES-FROM-DISK: No file ~A to read the highscores from. Overwriting with defaults.~%~%" file-pathname)) (save-highscores-to-disk) nil)) (t (c) (log:info (format nil "~%LOAD-HIGHSCORES-FROM-DISK: Error occured while reading the highscores from file ~A: ~A. Overwriting with defaults.~%~%" file-pathname c)) (save-highscores-to-disk) nil))) *highscores*) (defun add-highscore-record (highscores &key name-str score mob-type-str turns result-str sector-name-str params) (let ((record (make-instance 'highscores-record :player-name name-str :score score :mob-type mob-type-str :turns-num turns :result result-str :sector-name sector-name-str :params params)) (pos 0)) (push record (highscores-table/records highscores)) (setf (highscores-table/records highscores) (stable-sort (highscores-table/records highscores) #'> :key #'(lambda (a) (highscore-record/score a)))) (setf pos (position record (highscores-table/records highscores))) (when (and (> (length (highscores-table/records highscores)) 10) (< pos 10)) (truncate-highscores highscores)) pos)) (defun truncate-highscores (highscores) (setf (highscores-table/records highscores) (loop repeat 10 for record in (highscores-table/records highscores) collect record))) (defun write-highscore-record-to-str (highscores-record) (format nil "~10@<~D~> ~20@<~A~> ~20@<~A~> ~10@<~A~> ~20@<~A~>~% ~A~%" (highscore-record/score highscores-record) (highscore-record/player-name highscores-record) (highscore-record/mob-type highscores-record) (format nil "~D turn~:P" (highscore-record/turns-num highscores-record)) (highscore-record/sector-name highscores-record) (highscore-record/result highscores-record)))
3,758
Common Lisp
.lisp
63
48.968254
170
0.641479
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
6c302d31dacfafa3df2152603dfb6e61f721e927dd1a7eb60b4ba984fef7e9f9
2,855
[ -1 ]
2,856
options.lisp
gwathlobal_CotD/src/options.lisp
(in-package :cotd) (defstruct options (tiles 'large) ;;; 'large - use small tiles ;;; 'small - use large tiles (font 'font-8x13) ;;; 'font-6x13 - use small font ;;; 'font-8x13 - use large font (player-name "Player") ;;; default name of the player (ignore-singlemind-messages nil) ;;; if the singlemind messages shall be hidden from the player ) (defun read-options (s-expr options) (log:info "S-EXPR = ~A" s-expr) (unless (typep s-expr 'list) (return-from read-options nil)) (cond ((equal (first s-expr) 'tiles) (set-options-tiles s-expr options)) ((equal (first s-expr) 'font) (set-options-font s-expr options)) ((equal (first s-expr) 'name) (set-options-name s-expr options)) ((equal (first s-expr) 'ignore-singlemind-messages) (set-options-ignore-singlemind-messages s-expr options)) ) ) (defun set-options-tiles (s-expr options) (log:info "S-EXPR = ~A" s-expr) (setf (options-tiles options) (second s-expr))) (defun set-options-font (s-expr options) (log:info "S-EXPR = ~A" s-expr) (setf (options-font options) (second s-expr))) (defun set-options-name (s-expr options) (log:info "S-EXPR = ~A" s-expr) (loop for c across (second s-expr) with str = "" when (and (or (find (string-downcase (string c)) *char-list* :test #'string=) (char= c #\Space) (char= c #\-)) (< (length str) *max-player-name-length*)) do (setf str (format nil "~A~A" str (string c))) finally (setf (options-player-name options) str)) ) (defun set-options-ignore-singlemind-messages (s-expr options) (log:info "S-EXPR = ~A" s-expr) (setf (options-ignore-singlemind-messages options) (second s-expr))) (defun create-options-file-string (options) (let ((str (create-string))) (format str ";; FONT: Changes the size of text font~%;; Format (font <font type>)~%;; <font type> can be (without quotes) \"font-6x13\" or \"font-8x13\"~A~%" (new-line)) (format str "(font ~A)~A~%~A~%" (string-downcase (string (options-font options))) (new-line) (new-line)) (format str ";; NAME: Sets the default name of the player~%;; Format (name \"<player name>\"). Only alphabetical ASCII characters, spaces and minuses are allowed in names.~A~%" (new-line)) (format str "(name \"~A\")~A~%~A~%" (options-player-name options) (new-line) (new-line)) (format str ";; IGNORE-SINGLEMIND-MESSAGES: Defines if the player will see messages that are available through angel's 'singlemind' ability.~%;; Format (ignore-singlemind-messages <value>). <value> can be t (show messages) or nil (do not show messages).~A~%" (new-line)) (format str "(ignore-singlemind-messages \"~A\")~A~%~A~%" (options-ignore-singlemind-messages options) (new-line) (new-line)) str))
2,908
Common Lisp
.lisp
50
51.06
275
0.632394
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
22b1c9409e0ee00b75241edd01ca47214af4f28e761d32c7e8e9fc8cc3ca76e0
2,856
[ -1 ]
2,857
mission.lisp
gwathlobal_CotD/src/mission.lisp
(in-package :cotd) (defclass mission () ((mission-type-id :initarg :mission-type-id :accessor mission-type-id) (x :initarg :x :accessor x) (y :initarg :y :accessor y) (world-sector :initarg :world-sector :accessor world-sector) (faction-list :initform () :initarg :faction-list :accessor faction-list) ;; list of faction-type-id (level-modifier-list :initform () :initarg :level-modifier-list :accessor level-modifier-list) ;; list of level-modifier-id (player-lvl-mod-placement-id :initarg :player-lvl-mod-placement-id :accessor player-lvl-mod-placement-id) ;; serves the id of the player specific faction placement function (player-specific-faction :initarg :player-specific-faction :accessor player-specific-faction) )) (defmethod name ((mission mission)) (name (get-mission-type-by-id (mission-type-id mission)))) ;;======================= ;; Auxiliary funcs ;;======================= (defun populate-level-with-mobs (level mob-template-list placement-func) (loop for (mob-template-id num is-player) in mob-template-list do (loop repeat num do (if is-player (progn (setf *player* (make-instance 'player :mob-type mob-template-id)) (funcall placement-func level *player*)) (funcall placement-func level (make-instance 'mob :mob-type mob-template-id)))))) (defun find-unoccupied-place-on-top (level mob) (loop with max-x = (array-dimension (terrain level) 0) with max-y = (array-dimension (terrain level) 1) with nz = nil for x = (random max-x) for y = (random max-y) for z = (1- (array-dimension (terrain level) 2)) do (setf (x mob) x (y mob) y (z mob) z) (setf nz (apply-gravity mob)) until (and (and (> x 10) (< x (- max-x 10)) (> y 10) (< y (- max-y 10))) (get-terrain-type-trait (get-terrain-* level x y nz) +terrain-trait-blocks-move-floor+) nz (> nz 2) (not (get-mob-* level x y nz)) (eq (check-move-on-level mob x y nz) t) (/= (get-level-connect-map-value level x y nz (if (riding-mob-id mob) (map-size (get-mob-by-id (riding-mob-id mob))) (map-size mob)) (get-mob-move-mode mob)) +connect-room-none+) (or (not (mob-ability-p mob +mob-abil-demon+)) (and (mob-ability-p mob +mob-abil-demon+) (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) with result = t when (and (= (feature-type feature) +feature-start-repel-demons+) (< (get-distance x y (x feature) (y feature)) 15)) do (setf result nil) (loop-finish) when (and (= (feature-type feature) +feature-start-strong-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist-strong*)) do (setf result nil) (loop-finish) finally (return result))))) finally (setf (x mob) x (y mob) y (z mob) nz) (add-mob-to-level-list level mob))) (defun find-unoccupied-place-water (level mob) (let ((water-cells nil) (r-cell)) (loop for x from 0 below (array-dimension (terrain level) 0) do (loop for y from 0 below (array-dimension (terrain level) 1) do (loop for z from 0 below (array-dimension (terrain level) 2) when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-water+) (eq (check-move-on-level mob x y z) t)) do (push (list x y z) water-cells)))) (if water-cells (progn (setf r-cell (nth (random (length water-cells)) water-cells)) (setf (x mob) (first r-cell) (y mob) (second r-cell) (z mob) (third r-cell)) (add-mob-to-level-list level mob)) (progn (find-unoccupied-place-outside level mob))) ) ) (defun find-unoccupied-place-outside (level mob) (loop with max-x = (array-dimension (terrain level) 0) with max-y = (array-dimension (terrain level) 1) for x = (random max-x) for y = (random max-y) for z = 2 until (and (not (and (> x 7) (< x (- max-x 7)) (> y 7) (< y (- max-y 7)))) (eq (check-move-on-level mob x y z) t) (not (get-mob-* level x y z)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (/= (get-level-connect-map-value level x y z (if (riding-mob-id mob) (map-size (get-mob-by-id (riding-mob-id mob))) (map-size mob)) (get-mob-move-mode mob)) +connect-room-none+) (or (not (mob-ability-p mob +mob-abil-demon+)) (and (mob-ability-p mob +mob-abil-demon+) (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) with result = t when (and (= (feature-type feature) +feature-start-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist*)) do (setf result nil) (loop-finish) when (and (= (feature-type feature) +feature-start-strong-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist-strong*)) do (setf result nil) (loop-finish) finally (return result))))) finally (setf (x mob) x (y mob) y (z mob) z) (add-mob-to-level-list level mob))) (defun find-unoccupied-place-inside (level mob) (loop with max-x = (array-dimension (terrain level) 0) with max-y = (array-dimension (terrain level) 1) for x = (random max-x) for y = (random max-y) for z = 2 until (and (and (> x 10) (< x (- max-x 10)) (> y 10) (< y (- max-y 10))) (eq (check-move-on-level mob x y z) t) (not (get-mob-* level x y z)) (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (/= (get-level-connect-map-value level x y z (if (riding-mob-id mob) (map-size (get-mob-by-id (riding-mob-id mob))) (map-size mob)) (get-mob-move-mode mob)) +connect-room-none+) (or (and (not (mob-ability-p mob +mob-abil-demon+)) (not (mob-ability-p mob +mob-abil-angel+))) (and (or (mob-ability-p mob +mob-abil-demon+) (mob-ability-p mob +mob-abil-angel+)) (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) with result = t when (and (= (feature-type feature) +feature-start-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist*)) do (setf result nil) (loop-finish) when (and (= (feature-type feature) +feature-start-strong-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist-strong*)) do (setf result nil) (loop-finish) when (and (get-feature-type-trait feature +feature-trait-remove-on-dungeon-generation+) (< (get-distance x y (x feature) (y feature)) 2)) do (setf result nil) (loop-finish) finally (return result))))) finally (setf (x mob) x (y mob) y (z mob) z) (add-mob-to-level-list level mob))) (defun find-unoccupied-place-around (level mob sx sy sz &key (no-center nil)) (loop with min-x = sx with max-x = sx with min-y = sy with max-y = sy with max-x-level = (array-dimension (terrain level) 0) with max-y-level = (array-dimension (terrain level) 1) for cell-list = nil do ;; prepare the list of cells ;; north (setf cell-list (append cell-list (loop with y = min-y for x from min-x to max-x collect (cons x y)))) ;; east (setf cell-list (append cell-list (loop with x = max-x for y from min-y to max-y collect (cons x y)))) ;; south (setf cell-list (append cell-list (loop with y = max-y for x from min-x to max-x collect (cons x y)))) ;; west (setf cell-list (append cell-list (loop with x = min-x for y from min-y to max-y collect (cons x y)))) ;; iterate through the list of cells (loop for (x . y) in cell-list when (and (>= x 0) (< x max-x-level) (>= y 0) (< y max-y-level) (eq (check-move-on-level mob x y sz) t) (get-terrain-type-trait (get-terrain-* level x y sz) +terrain-trait-blocks-move-floor+) (/= (get-level-connect-map-value level x y sz (if (riding-mob-id mob) (map-size (get-mob-by-id (riding-mob-id mob))) (map-size mob)) (get-mob-move-mode mob)) +connect-room-none+) (or (null no-center) (and no-center (or (/= x sx) (/= y sy))))) do (setf (x mob) x (y mob) y (z mob) sz) (add-mob-to-level-list level mob) (return-from find-unoccupied-place-around mob)) ;; if the loop is not over - increase the boundaries (decf min-x) (decf min-y) (incf max-x) (incf max-y) )) (defun find-unoccupied-place-mimic (level mob1 mob2 mob3 &key (inside nil)) ;; function specifically for mimics (loop with max-x = (array-dimension (terrain level) 0) with max-y = (array-dimension (terrain level) 1) for x = (random max-x) for y = (random max-y) for z = 2 until (and (if inside (and (> x 10) (< x (- max-x 10)) (> y 10) (< y (- max-y 10))) (not (and (> x 7) (< x (- max-x 7)) (> y 7) (< y (- max-y 7))))) (eq (check-move-on-level mob1 (1- x) (1- y) z) t) (eq (check-move-on-level mob2 (1+ x) (1- y) z) t) (eq (check-move-on-level mob3 x (1+ y) z) t) (not (get-mob-* level (1- x) (1- y) z)) (not (get-mob-* level (1+ x) (1- y) z)) (not (get-mob-* level x (1+ y) z)) (get-terrain-type-trait (get-terrain-* level (1- x) (1- y) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level (1+ x) (1- y) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level x (1+ y) z) +terrain-trait-blocks-move-floor+) (/= (get-level-connect-map-value level (1- x) (1- y) z (if (riding-mob-id mob1) (map-size (get-mob-by-id (riding-mob-id mob1))) (map-size mob1)) (get-mob-move-mode mob1)) +connect-room-none+) (/= (get-level-connect-map-value level (1+ x) (1- y) z (if (riding-mob-id mob2) (map-size (get-mob-by-id (riding-mob-id mob2))) (map-size mob2)) (get-mob-move-mode mob2)) +connect-room-none+) (/= (get-level-connect-map-value level x (1+ y) z (if (riding-mob-id mob3) (map-size (get-mob-by-id (riding-mob-id mob3))) (map-size mob3)) (get-mob-move-mode mob3)) +connect-room-none+) ) finally (setf (x mob1) (1- x) (y mob1) (1- y) (z mob1) z) (add-mob-to-level-list level mob1) (setf (x mob2) (1+ x) (y mob2) (1- y) (z mob2) z) (add-mob-to-level-list level mob2) (setf (x mob3) x (y mob3) (1+ y) (z mob3) z) (add-mob-to-level-list level mob3) )) (defun find-player-start-position (level mob feature-type-id) (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) feature-type-id) do (setf (x mob) (x feature) (y mob) (y feature) (z mob) (z feature)) (add-mob-to-level-list level mob) (loop-finish))) (defun set-up-outdoor-light (level light-power) (setf (outdoor-light level) light-power) ;; propagate light from above to determine which parts of the map are outdoor and which are "inside" ;; also set up all stationary light sources (loop for x from 0 below (array-dimension (light-map level) 0) do (loop for y from 0 below (array-dimension (light-map level) 1) for light-pwr = 100 do (loop for z from (1- (array-dimension (light-map level) 2)) downto 0 do (setf (aref (light-map level) x y z) light-pwr) (when (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (setf light-pwr 0)) (when (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-light-source+) (add-light-source level (make-light-source x y z (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-light-source+)))) ))) )
16,512
Common Lisp
.lisp
271
38.173432
175
0.444864
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
9635fb0b2cc00deca8f06ae7507065bad7d513298608c14f69a7bd820be6ca94
2,857
[ -1 ]
2,858
init-world-sectors.lisp
gwathlobal_CotD/src/init-world-sectors.lisp
(in-package :cotd) ;;============ ;; TEST ;;============ (set-world-sector-type :wtype :world-sector-test :glyph-idx +glyph-id-large-t+ :glyph-color sdl:*white* :name "A test district" :general-type :world-sector-normal :faction-list-func #'(lambda () ()) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (declare (ignore template-level)) (create-template-test-city max-x max-y max-z)) ) ;;============ ;; NORMAL ;;============ (set-world-sector-type :wtype :world-sector-normal-residential :glyph-idx 40 :glyph-color sdl:*white* :name "An ordinary district" :general-type :world-sector-normal :faction-list-func #'(lambda () (list (list +faction-type-civilians+ :mission-faction-present) (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) (list +faction-type-criminals+ :mission-faction-present) (list +faction-type-criminals+ :mission-faction-absent) (list +faction-type-ghost+ :mission-faction-present) (list +faction-type-ghost+ :mission-faction-absent))) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-normal #'get-reserved-buildings-normal)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place civilians if they are available (push #'place-civilians-on-level func-list) func-list)) ) (set-world-sector-type :wtype :world-sector-normal-port :glyph-idx 48 :glyph-color sdl:*white* :name "A seaport district" :general-type :world-sector-normal :faction-list-func #'(lambda () (list (list +faction-type-civilians+ :mission-faction-present) (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) (list +faction-type-criminals+ :mission-faction-present) (list +faction-type-criminals+ :mission-faction-absent) (list +faction-type-ghost+ :mission-faction-present) (list +faction-type-ghost+ :mission-faction-absent))) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-port #'get-reserved-buildings-port)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world mission)) (log:info "TEMPLATE LEVEL FUNC: World Sector Normal Seaport") (let ((seaport-params (second (find +lm-feat-sea+ (feats world-sector) :key #'(lambda (a) (first a)))))) (cond ;; north ((find :n seaport-params) (place-seaport-north template-level +building-city-warehouse-port-1+ +building-city-warehouse-port-2+)) ;; south ((find :s seaport-params) (place-seaport-south template-level +building-city-warehouse-port-1+ +building-city-warehouse-port-2+)) ;; east ((find :e seaport-params) (place-seaport-east template-level +building-city-warehouse-port-1+ +building-city-warehouse-port-2+)) ;; west ((find :w seaport-params) (place-seaport-west template-level +building-city-warehouse-port-1+ +building-city-warehouse-port-2+))) ) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place civilians if they are available (push #'place-civilians-on-level func-list) func-list)) :scenario-enabled-func #'(lambda (world-map x y) ;; choose random sides where to add a sea (let ((side (nth (random 4) '(:n :s :e :w)))) (case side (:n (setf (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-sea)) (:s (setf (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-sea)) (:w (setf (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-sea)) (:e (setf (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-sea))) )) ) (set-world-sector-type :wtype :world-sector-normal-forest :glyph-idx 38 :glyph-color sdl:*white* :name "The outskirts of the city" :general-type :world-sector-normal :faction-list-func #'(lambda () (list (list +faction-type-civilians+ :mission-faction-present) (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) (list +faction-type-criminals+ :mission-faction-present) (list +faction-type-criminals+ :mission-faction-absent) (list +faction-type-ghost+ :mission-faction-present) (list +faction-type-ghost+ :mission-faction-absent))) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-normal #'get-reserved-buildings-normal)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (log:info "TEMPLATE LEVEL FUNC: World Sector Outskirts") (place-outskirts-on-template-level template-level +building-city-normal-forest-border+ +building-city-park-3+) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place civilians if they are available (push #'place-civilians-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-normal-lake :glyph-idx 44 :glyph-color sdl:*white* :name "A district upon a lake" :general-type :world-sector-normal :faction-list-func #'(lambda () (list (list +faction-type-civilians+ :mission-faction-present) (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) (list +faction-type-criminals+ :mission-faction-present) (list +faction-type-criminals+ :mission-faction-absent) (list +faction-type-ghost+ :mission-faction-present) (list +faction-type-ghost+ :mission-faction-absent))) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-normal #'get-reserved-buildings-normal)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (log:info "TEMPLATE LEVEL FUNC: World Sector Lake") (place-lake-on-template-level template-level +building-city-central-lake+)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place civilians if they are available (push #'place-civilians-on-level func-list) func-list)) ) (set-world-sector-type :wtype :world-sector-normal-sea :glyph-idx 51 :glyph-color sdl:*white* :name "Sea" :general-type :world-sector-sea) (set-world-sector-type :wtype :world-sector-normal-island :glyph-idx 41 :glyph-color sdl:*white* :name "An island district" :general-type :world-sector-normal :faction-list-func #'(lambda () (list (list +faction-type-civilians+ :mission-faction-present) (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) (list +faction-type-criminals+ :mission-faction-present) (list +faction-type-criminals+ :mission-faction-absent) (list +faction-type-ghost+ :mission-faction-present) (list +faction-type-ghost+ :mission-faction-absent))) :angel-disguised-mob-type-id +mob-type-man+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-port #'get-reserved-buildings-port)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'place-island-on-template-level :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place civilians if they are available (push #'place-civilians-on-level func-list) func-list)) ) ;;============ ;; ABANDONED ;;============ (set-world-sector-type :wtype :world-sector-abandoned-residential :glyph-idx 40 :glyph-color (sdl:color :r 150 :g 150 :b 150) :name "An abandoned residential district" :general-type :world-sector-abandoned :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-ruined-normal #'get-reserved-buildings-ruined-normal)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-abandoned-port :glyph-idx 48 :glyph-color (sdl:color :r 150 :g 150 :b 150) :name "An abandoned seaport district" :general-type :world-sector-abandoned :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-ruined-port #'get-reserved-buildings-ruined-port)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world mission)) (log:info "TEMPLATE LEVEL FUNC: World Sector Abandonded Seaport") (let ((seaport-params (second (find +lm-feat-sea+ (feats world-sector) :key #'(lambda (a) (first a)))))) (cond ;; north ((find :n seaport-params) (place-seaport-north template-level +building-city-ruined-warehouse-port-1+ +building-city-ruined-warehouse-port-2+)) ;; south ((find :s seaport-params) (place-seaport-south template-level +building-city-ruined-warehouse-port-1+ +building-city-ruined-warehouse-port-2+)) ;; east ((find :e seaport-params) (place-seaport-east template-level +building-city-ruined-warehouse-port-1+ +building-city-ruined-warehouse-port-2+)) ;; west ((find :w seaport-params) (place-seaport-west template-level +building-city-ruined-warehouse-port-1+ +building-city-ruined-warehouse-port-2+))) ) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list)) :scenario-enabled-func #'(lambda (world-map x y) ;; choose random side where to place a sea (let ((side (nth (random 4) '(:n :s :e :w)))) (case side (:n (setf (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-sea)) (:s (setf (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-sea)) (:w (setf (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-sea)) (:e (setf (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-sea))) )) ) (set-world-sector-type :wtype :world-sector-abandoned-forest :glyph-idx 38 :glyph-color (sdl:color :r 150 :g 150 :b 150) :name "The abandoned outskirts of the city" :general-type :world-sector-abandoned :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-ruined-normal #'get-reserved-buildings-ruined-normal)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (format t "TEMPLATE LEVEL FUNC: WORLD SECTOR OUTSKIRTS~%") (place-outskirts-on-template-level template-level +building-city-normal-forest-border+ +building-city-ruined-park-3+) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-abandoned-lake :glyph-idx 44 :glyph-color (sdl:color :r 150 :g 150 :b 150) :name "An abandoned district upon a lake" :general-type :world-sector-abandoned :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-ruined-normal #'get-reserved-buildings-ruined-normal)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (format t "TEMPLATE LEVEL FUNC: WORLD SECTOR LAKE~%") (place-lake-on-template-level template-level +building-city-central-lake+)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-abandoned-island :glyph-idx 41 :glyph-color (sdl:color :r 150 :g 150 :b 150) :name "An abandoned island district" :general-type :world-sector-abandoned :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-ruined-port #'get-reserved-buildings-ruined-port)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'place-island-on-template-level :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place coins to always enable thief's victory (push #'place-coins-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place blood (push #'place-blood-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) ;;============ ;; CORRUPTED ;;============ (set-world-sector-type :wtype :world-sector-corrupted-residential :glyph-idx 40 :glyph-color sdl:*magenta* :name "A corrupted residential district" :general-type :world-sector-corrupted :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-corrupted-normal #'get-reserved-buildings-corrupted-normal (list +level-city-park+ +building-city-corrupted-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+)))) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore world-sector mission world)) (log:info (format nil "TEMPLATE LEVEL FUNC: World Sector Corrupted Residential~%")) (place-demonic-sigils-on-template-level template-level) ) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; add demonic sigils (push #'place-demonic-sigils-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-corrupted-port :glyph-idx 48 :glyph-color sdl:*magenta* :name "A corrupted seaport district" :general-type :world-sector-corrupted :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-corrupted-port #'get-reserved-buildings-corrupted-port (list +level-city-park+ +building-city-corrupted-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+)))) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world mission)) (log:info (format nil "TEMPLATE LEVEL FUNC: World Sector Corrupted Seaport~%")) (let ((seaport-params (second (find +lm-feat-sea+ (feats world-sector) :key #'(lambda (a) (first a)))))) (cond ;; north ((find :n seaport-params) (place-seaport-north template-level +building-city-corrupted-warehouse-port-1+ +building-city-corrupted-warehouse-port-2+)) ;; south ((find :s seaport-params) (place-seaport-south template-level +building-city-corrupted-warehouse-port-1+ +building-city-corrupted-warehouse-port-2+)) ;; east ((find :e seaport-params) (place-seaport-east template-level +building-city-corrupted-warehouse-port-1+ +building-city-corrupted-warehouse-port-2+)) ;; west ((find :w seaport-params) (place-seaport-west template-level +building-city-corrupted-warehouse-port-1+ +building-city-corrupted-warehouse-port-2+))) ) (place-demonic-sigils-on-template-level template-level) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; add demonic sigils (push #'place-demonic-sigils-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list)) :scenario-enabled-func #'(lambda (world-map x y) ;; choose random side where to place a sea (let ((side (nth (random 4) '(:n :s :e :w)))) (case side (:n (setf (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-sea)) (:s (setf (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-sea)) (:w (setf (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-sea)) (:e (setf (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-sea))) )) ) (set-world-sector-type :wtype :world-sector-corrupted-forest :glyph-idx 38 :glyph-color sdl:*magenta* :name "The corrupted outskirts of the city" :general-type :world-sector-corrupted :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-corrupted-normal #'get-reserved-buildings-corrupted-normal (list +level-city-park+ +building-city-corrupted-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+)))) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (log:info (format nil "TEMPLATE LEVEL FUNC: World Sector Corrupted Outskirts~%")) (place-outskirts-on-template-level template-level +building-city-corrupted-forest-border+ +building-city-corrupted-park-3+) (place-demonic-sigils-on-template-level template-level) ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; add demonic sigils (push #'place-demonic-sigils-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-corrupted-lake :glyph-idx 44 :glyph-color sdl:*magenta* :name "A corrupted district upon a lake" :general-type :world-sector-corrupted :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-corrupted-normal #'get-reserved-buildings-corrupted-normal (list +level-city-park+ +building-city-corrupted-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+)))) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore mission world world-sector)) (log:info (format nil "TEMPLATE LEVEL FUNC: World Sector Corrupted Lake~%")) (place-lake-on-template-level template-level +building-city-central-lake+) (place-demonic-sigils-on-template-level template-level)) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; add demonic sigils (push #'place-demonic-sigils-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) (set-world-sector-type :wtype :world-sector-corrupted-island :glyph-idx 41 :glyph-color sdl:*magenta* :name "A corrupted island district" :general-type :world-sector-corrupted :faction-list-func #'(lambda () (list (list +faction-type-eater+ :mission-faction-present) ;(list +faction-type-eater+ :mission-faction-absent) )) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-corrupted-port #'get-reserved-buildings-corrupted-port (list +level-city-park+ +building-city-corrupted-park-tiny+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+)))) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :template-level-gen-func #'(lambda (template-level world-sector mission world) (log:info "TEMPLATE LEVEL FUNC: World Sector Corrupted Island") (place-island-on-template-level template-level world-sector mission world) (place-demonic-sigils-on-template-level template-level)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; add demonic sigils (push #'place-demonic-sigils-on-level func-list) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list))) ;;============ ;; HELL ;;============ (set-world-sector-type :wtype :world-sector-hell-jungle :glyph-idx 40 :glyph-color sdl:*magenta* :name "A hell jungle" :general-type :world-sector-hell :faction-list-func #'(lambda () (list (list +faction-type-demons+ :mission-faction-present))) :angel-disguised-mob-type-id +mob-type-soldier+ :sector-level-gen-func #'(lambda (template-level max-x max-y max-z) (create-template-city template-level max-x max-y max-z #'get-max-buildings-hell-normal #'get-reserved-buildings-hell-normal (list +level-city-park+ +building-city-hell-border+ +level-city-terrain-border+ #'(lambda () +terrain-border-creep+) +level-city-terrain-dirt+ #'(lambda () (let ((r (random 100))) (cond ((< r 3) +terrain-floor-creep-dreadtubes+) ((< r 6) +terrain-floor-creep-spores+) ((< r 10) +terrain-wall-razorthorns+) ((< r 13) +terrain-floor-creep-glowshroom+) ((< r 20) +terrain-floor-creep+) (t +terrain-floor-creep-bright+) ))) +level-city-terrain-grass+ #'(lambda () +terrain-floor-creep+) +level-city-terrain-tree+ #'(lambda () +terrain-tree-twintube+) +level-city-terrain-bush+ #'(lambda () +terrain-wall-gloomtwigs+) +level-city-terrain-earth+ #'(lambda () +terrain-wall-compressed-bones+)))) :template-level-gen-func #'(lambda (template-level world-sector mission world) (declare (ignore template-level world-sector mission world)) (log:info (format nil "TEMPLATE LEVEL FUNC: World Sector Hell Plain~%")) ) :terrain-post-process-func-list #'(lambda () (let ((func-list ())) ;; add arrival points for angels, demons & military (push #'add-arrival-points-on-level func-list) func-list)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; place outsider beasts (push #'place-outsider-beasts-on-level func-list) ;; place outsider beasts twice (push #'place-outsider-beasts-on-level func-list) ;; place irradiated spots (push #'place-irradation-on-level func-list) ;; add demonic runes (push #'place-demonic-runes-on-level func-list) func-list)))
77,574
Common Lisp
.lisp
834
35.477218
180
0.29531
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
8f9dee19aee08d92dd34955df9ce91ce8eef4068748bbf9ade22088f601d18d1
2,858
[ -1 ]
2,859
file-storage.lisp
gwathlobal_CotD/src/file-storage.lisp
(in-package :cotd) (defun get-txt-from-file (filename) (with-open-file (file (merge-pathnames filename *current-dir*) :direction :input :if-does-not-exist nil) (when file (loop for line = (read-line file nil) with str = (create-string "") while line do (format str "~A~%" line) finally (return str))))) (defun populate-txt-from-filelist (file-path-list) (append (list nil) (map 'list #'get-txt-from-file file-path-list)) )
478
Common Lisp
.lisp
11
37.454545
106
0.643011
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e7150bc253f23966369f2de093870e98cc391b4dba44203eadafc710a3067d93
2,859
[ -1 ]
2,860
init-effect-types.lisp
gwathlobal_CotD/src/init-effect-types.lisp
(in-package :cotd) (set-effect-type (make-instance 'effect-type :id +mob-effect-possessed+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Possessed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-blessed+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Blessed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*blue*) :on-add #'(lambda (effect actor) (declare (ignore actor)) (incf (total-blessed (level *world*))) (incf (stat-blesses (get-mob-by-id (actor-id effect)))) (when (eq *player* (get-mob-by-id (actor-id effect))) (incf (cur-score *player*) 5)) ) :on-remove #'(lambda (effect actor) (declare (ignore effect actor)) (decf (total-blessed (level *world*))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-reveal-true-form+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Revealed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-disguise-for-mob actor) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-reveal-true-form+) (adjust-disguise-for-mob actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-divine-concealed+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Concealed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-disguise-for-mob actor) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-divine-concealed+) (adjust-disguise-for-mob actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-calling-for-help+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Concealed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-called-for-help+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Called") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-divine-shield+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Divine shield") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-cursed+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Cursed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 139 :g 69 :b 19)) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-m-acc actor) (adjust-r-acc actor) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-m-acc actor) (adjust-r-acc actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-blind+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Blind") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-sight actor) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-sight actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-fear+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Fear") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-climbing-mode+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Climbing") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-climbing-mode+) (when (apply-gravity actor) (set-mob-location actor (x actor) (y actor) (z actor)) (make-act actor +normal-ap+))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-alertness+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "On alert") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-ready-to-possess+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Ready to possess") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-avatar-of-brilliance+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Avatar of Brilliance") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-archangel+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) (set-mob-effect actor :effect-type-id +mob-effect-flying+ :actor-id (id actor)) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms itself into an Avatar of Brilliance. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) +mob-type-angel+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A.~%" str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms itself back into a chrome angel. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect actor +mob-effect-flying+)) :on-tick #'(lambda (effect actor) (declare (ignore effect)) (when (not (mob-effect-p actor +mob-effect-gravity-pull+)) (set-mob-effect actor :effect-type-id +mob-effect-flying+ :actor-id (id actor)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-empowered-undead+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Empowered") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (setf (param1 effect) (mob-type actor)) ;; store mob-type-id in param1 of the effect (set-mob-effect (get-mob-by-id (actor-id effect)) :effect-type-id +mob-effect-necrolink+ :actor-id (actor-id effect) :cd t :param1 (target-id effect)) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-reanimated-empowered+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (let ((was-ghost nil)) (when (mob-ability-p actor +mob-abil-ghost-possess+) (setf was-ghost t)) (adjust-abilities actor) (when was-ghost (mob-set-ability actor +mob-abil-ghost-possess+ t) (mob-set-ability actor +mob-abil-ghost-release+ t) (mob-remove-ability actor +mob-abil-possessable+))) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) (setf (order actor) (list +mob-order-follow+ (actor-id effect))) ;(set-name actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is empowered. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) :on-remove #'(lambda (effect actor) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) (param1 effect)) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (let ((was-ghost nil)) (when (mob-ability-p actor +mob-abil-ghost-possess+) (setf was-ghost t)) (adjust-abilities actor) (when was-ghost (mob-set-ability actor +mob-abil-ghost-possess+ t) (mob-set-ability actor +mob-abil-ghost-release+ t) (mob-remove-ability actor +mob-abil-possessable+))) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;(set-name actor) (setf (order actor) nil) ;; remove necrolink from master (rem-mob-effect (get-mob-by-id (actor-id effect)) +mob-effect-necrolink+) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A.~%" str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A loses its power. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-necrolink+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Necrolink") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (setf (order actor) nil)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-gravity-pull+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Gravity pull") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-flying+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Flying") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (apply-gravity actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-slow+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Slowed") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-speed actor) ) :on-remove #'(lambda (effect actor) (rem-mob-effect-simple actor (effect-type effect)) (adjust-speed actor) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-holy-touch+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Holy touch") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-add #'(lambda (effect actor) (setf (param1 effect) (weapon actor)) (setf (weapon actor) (list "Holy touch" (list +weapon-dmg-fire+ 2 3 +normal-ap+ 100 (list :is-fire)) nil)) ) :on-remove #'(lambda (effect actor) (setf (weapon actor) (param1 effect)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-extinguished-light+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Extinguished light") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)) :on-add #'(lambda (effect actor) (setf (param1 effect) (cur-light actor)) (setf (cur-light actor) 0) ) :on-remove #'(lambda (effect actor) (setf (cur-light actor) (param1 effect)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-merged+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Merged") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (let ((singer nil) (gazer nil) (mender nil) (cur-hp 0) (final-mob-type nil)) (loop for mob-id in (append (list (id actor)) (merged-id-list actor)) for mob = (get-mob-by-id mob-id) do (incf cur-hp (cur-hp mob)) (cond ((= (mob-type mob) +mob-type-star-singer+) (setf singer t)) ((= (mob-type mob) +mob-type-star-gazer+) (setf gazer t)) ((= (mob-type mob) +mob-type-star-mender+) (setf mender t)))) (loop for mob-id in (append (list (id actor)) (merged-id-list actor)) for mob = (get-mob-by-id mob-id) do (setf (is-merged mob) t) (setf (cur-hp mob) (truncate cur-hp (length (append (list (id actor)) (merged-id-list actor)))))) (setf (is-merged actor) nil) (cond ((and singer gazer mender) (setf final-mob-type +mob-type-star-singer-gazer-mender+)) ((and singer mender) (setf final-mob-type +mob-type-star-singer-mender+)) ((and singer gazer) (setf final-mob-type +mob-type-star-singer-gazer+)) ((and gazer mender) (setf final-mob-type +mob-type-star-gazer-mender+))) (setf (mob-type actor) final-mob-type) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) ) ) :on-remove #'(lambda (effect actor) (setf (mob-type actor) (param1 effect)) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0))) :on-tick #'(lambda (effect actor) (declare (ignore effect)) (let ((cur-hp 0)) (loop for mob-id in (append (list (id actor)) (merged-id-list actor)) for mob = (get-mob-by-id mob-id) do (incf cur-hp (cur-hp mob))) (loop for mob-id in (append (list (id actor)) (merged-id-list actor)) for mob = (get-mob-by-id mob-id) do (setf (cur-hp mob) (truncate cur-hp (length (append (list (id actor)) (merged-id-list actor))))) (when (check-dead mob) (make-dead mob :splatter t :msg t :msg-newline t :killer nil :corpse t :aux-params () :keep-items nil))))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-righteous-fury+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Righteous fury") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 255 :g 140 :b 0)) :on-add #'(lambda (effect actor) (declare (ignore effect)) (setf (weapon actor) (list "Flaming sword" (list +weapon-dmg-fire+ 4 7 (truncate +normal-ap+ 1.3) 100 (list :chops-body-parts :is-fire)) nil)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is filled with righteous fury. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (set-cur-weapons actor) (set-mob-effect actor :effect-type-id +mob-effect-slow+ :actor-id (id actor) :cd 3) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is no longer filled with righteous fury. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-wet+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Wet") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*blue*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-pain-link-source+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Pain link") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-remove #'(lambda (effect actor) (declare (ignore actor)) ;; param1 - id of the mob, affected by the +mob-effect-pain-link-source+ (when (param1 effect) (rem-mob-effect (get-mob-by-id (param1 effect)) +mob-effect-pain-link-target+)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-pain-link-target+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Pain link") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*) :on-remove #'(lambda (effect actor) (declare (ignore actor)) ;; I need this otherwise there will be an infinite recursion (when (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-pain-link-source+) (setf (param1 (get-effect-by-id (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-pain-link-source+))) nil)) (rem-mob-effect (get-mob-by-id (actor-id effect)) +mob-effect-pain-link-source+) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-soul-reinforcement+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Reinforced soul") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-silence+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Silenced") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-confuse+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Confused") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-split-soul-source+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Split soul") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-remove #'(lambda (effect actor) (declare (ignore actor)) ;; param1 - id of the mob, affected by the +mob-effect-split-soul-target+ (when (param1 effect) (rem-mob-effect (get-mob-by-id (param1 effect)) +mob-effect-split-soul-target+)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-split-soul-target+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Split soul") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-remove #'(lambda (effect actor) ;; I need this otherwise there will be an infinite recursion (when (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-split-soul-source+) (setf (param1 (get-effect-by-id (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-split-soul-source+))) nil)) (rem-mob-effect (get-mob-by-id (actor-id effect)) +mob-effect-split-soul-source+) ;; have to avoid recursion in make-dead with this (rem-mob-effect-simple actor +mob-effect-split-soul-target+) (when (> (cur-hp actor) 0) (setf (cur-hp actor) 0) (make-dead actor :splatter nil :msg nil :msg-newline nil :killer nil :corpse nil :aux-params nil)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-sprint+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Sprint") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect actor +mob-effect-climbing-mode+) (decf (cur-move-speed actor) 25) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (incf (cur-move-speed actor) 25) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-exerted+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Exerted") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-casting-shadow+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Casting shadows") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-disguised+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Disguised") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*) :on-add #'(lambda (effect actor) (declare (ignore effect)) ;; Malseraph likes when you lose disguises (increase-piety-for-god +god-entity-malseraph+ actor 30)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-disguised+) (adjust-disguise-for-mob actor) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals itself as ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-qualified-name actor)) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; Malseraph likes when you lose disguises (increase-piety-for-god +god-entity-malseraph+ actor 30)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-constriction-source+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Constricting") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*) :on-remove #'(lambda (effect actor) ;; the param1 here is (list (list x y z) - xyz coordinates of the constrictor ;; (list id1 id2 id3 ...)) - collection of mob IDs that are being constricted by this constrictor (rem-mob-effect-simple actor +mob-effect-constriction-source+) (loop for target-id in (second (param1 effect)) for target = (get-mob-by-id target-id) do (rem-mob-effect target +mob-effect-constriction-target+)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-constriction-target+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Constricted") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-dodge actor)) :on-remove #'(lambda (effect actor) ;; the param1 here is (list x y z) - xyz coordinates of the mob being constricted (when (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-constriction-source+) (let ((source-effect (get-effect-by-id (mob-effect-p (get-mob-by-id (actor-id effect)) +mob-effect-constriction-source+)))) (setf (second (param1 source-effect)) (remove (id actor) (second (param1 source-effect)))) (unless (second (param1 source-effect)) (rem-mob-effect (get-mob-by-id (actor-id effect)) +mob-effect-constriction-source+)))) ) :on-tick #'(lambda (effect actor) (inflict-damage actor :min-dmg (get-melee-weapon-dmg-min (get-mob-by-id (actor-id effect))) :max-dmg (get-melee-weapon-dmg-min (get-mob-by-id (actor-id effect))) :dmg-type (get-melee-weapon-dmg-type (get-mob-by-id (actor-id effect))) :att-spd nil :weapon-aux () :acc 100 :actor (get-mob-by-id (actor-id effect)) :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A constricts around ~A for ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name (get-mob-by-id (actor-id effect))))) (prepend-article +article-the+ (visible-name actor)) cur-dmg)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-irradiated+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Irradiated") :color-func #'(lambda (effect actor) (declare (ignore actor)) (cond ((> (param1 effect) 10) sdl:*red*) ((> (param1 effect) 5) sdl:*yellow*) (t sdl:*green*))) :on-tick #'(lambda (effect actor) (when (zerop (random 3)) (decf (param1 effect))) (when (> (param1 effect) 0) (let ((r (random 200))) (cond ((= r 0) (when (not (mob-ability-p actor +mob-abil-casts-light+)) (mob-set-mutation actor +mob-abil-casts-light+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now casting light. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((= r 1) (when (not (mob-ability-p actor +mob-abil-vulnerable-to-fire+)) (mob-set-mutation actor +mob-abil-vulnerable-to-fire+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now vulnerable to fire. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((= r 2) (when (not (mob-ability-p actor +mob-abil-vulnerable-to-vorpal+)) (mob-set-mutation actor +mob-abil-vulnerable-to-vorpal+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now vulnerable to vorpal. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))))) (when (<= (param1 effect) 0) (rem-mob-effect actor (effect-type effect)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-deep-breath+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Deep breath") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 100 :g 100 :b 100)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (generate-sound actor (x actor) (y actor) (z actor) 50 #'(lambda (str) (format nil "You hear someone exhaling~A. " str))) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((target (get-mob-* (level *world*) dx dy (z actor)))) (when target (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A irradiates ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let* ((malseraph (get-god-by-id (get-worshiped-god-type (worshiped-god actor)))) (irradiate-bonus (funcall (piety-level-func malseraph) malseraph (get-worshiped-god-piety (worshiped-god actor)))) (irradiate-value (if (zerop irradiate-bonus) -1 (random irradiate-bonus)))) (if (mob-effect-p target +mob-effect-irradiated+) (progn (let ((effect (get-effect-by-id (mob-effect-p target +mob-effect-irradiated+)))) (incf (param1 effect) (+ 2 irradiate-value)))) (progn (set-mob-effect target :effect-type-id +mob-effect-irradiated+ :actor-id (id actor) :cd t :param1 (+ 2 irradiate-value))))) )) )) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-polymorph-sheep+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Polymorhped") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*) :on-add #'(lambda (effect actor) (when (mob-effect-p actor +mob-effect-avatar-of-brilliance+) (rem-mob-effect actor +mob-effect-avatar-of-brilliance+)) (when (mob-effect-p actor +mob-effect-empowered-undead+) (rem-mob-effect actor +mob-effect-empowered-undead+)) (when (mob-effect-p actor +mob-effect-polymorph-tree+) (rem-mob-effect actor +mob-effect-polymorph-tree+)) (when (mob-effect-p actor +mob-effect-demonic-power+) (rem-mob-effect actor +mob-effect-demonic-power+)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms into a sheep. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) +mob-type-sheep+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) ;; polymorph block mutations (loop for ability-type-id in (get-mob-all-abilities actor) with mutation-list = () when (and (mob-is-ability-mutation actor ability-type-id) (on-remove-mutation (get-ability-type-by-id ability-type-id))) do (mob-remove-mutation actor ability-type-id) (pushnew ability-type-id mutation-list) finally (setf (param1 effect) (append (param1 effect) (list mutation-list)))) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (increase-piety-for-god +god-entity-malseraph+ actor 50)) :on-remove #'(lambda (effect actor) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A.~%" str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms back into a ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (name (get-mob-type-by-id (first (param1 effect))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) (first (param1 effect))) (setf (max-hp actor) (second (param1 effect))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) ;; polymorph returns mutations (loop for ability-type-id in (third (param1 effect)) when (on-add-mutation (get-ability-type-by-id ability-type-id)) do (mob-set-mutation actor ability-type-id)) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (increase-piety-for-god +god-entity-malseraph+ actor 50)) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-glowing+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Glowing") :color-func #'(lambda (effect actor) (declare (ignore actor effect)) sdl:*yellow*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-parasite+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Parasite") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 0 :g 100 :b 0)) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-evolving+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Evolving") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-remove #'(lambda (effect actor) ;; evolution finished, give the ability (when (eq (cd effect) 0) (let ((ability-type-id (first (param1 effect))) (str (second (param1 effect)))) (mob-set-mutation actor ability-type-id) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A finishes evolving and ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) str) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-adrenaline+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Adrenaline") :color-func #'(lambda (effect actor) (declare (ignore actor)) (cond ((> (param1 effect) 10) sdl:*red*) ((> (param1 effect) 5) sdl:*yellow*) (t sdl:*green*))) :on-tick #'(lambda (effect actor) (when (>= (param1 effect) 15) (setf (param1 effect) 15)) (decf (param1 effect)) (when (zerop (random 4)) (decf (param1 effect))) (when (<= (param1 effect) 0) (rem-mob-effect actor (effect-type effect)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-metabolic-boost+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Metabolic boost") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-speed actor) (adjust-dodge actor)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-metabolic-boost+) (adjust-dodge actor) (adjust-speed actor) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "The metabolism of ~A returns to the norm. " (prepend-article +article-the+ (visible-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-spines+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Spines") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-spines+) (adjust-armor actor) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A retracts its spines. " (prepend-article +article-the+ (visible-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-mortality+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Dies in") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (rem-mob-effect-simple actor +mob-effect-mortality+) (when (> (cur-hp actor) 0) (setf (cur-hp actor) 0) (when (check-dead actor) (make-dead actor :splatter nil :msg t :killer nil :corpse t :aux-params ()) (when (mob-effect-p actor +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id actor))) 0) (setf (x (get-mob-by-id (slave-mob-id actor))) (x actor) (y (get-mob-by-id (slave-mob-id actor))) (y actor) (z (get-mob-by-id (slave-mob-id actor))) (z actor)) (make-dead (get-mob-by-id (slave-mob-id actor)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ())))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-laying-eggs+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Laying eggs") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) (sdl:color :r 60 :g 179 :b 113)) :on-remove #'(lambda (effect actor) (declare (ignore actor)) (when (eq (cd effect) 0) (funcall (param1 effect)) ) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-regenerate+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Regenerate") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-tick #'(lambda (effect actor) (declare (ignore effect)) (incf (cur-hp actor)) (when (> (cur-hp actor) (max-hp actor)) (setf (cur-hp actor) (max-hp actor)))))) (set-effect-type (make-instance 'effect-type :id +mob-effect-corroded+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Corroded") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*red*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-primordial-transfer+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Primdordial transfer") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-polymorph-tree+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Polymorhped") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*) :on-add #'(lambda (effect actor) (when (mob-effect-p actor +mob-effect-avatar-of-brilliance+) (rem-mob-effect actor +mob-effect-avatar-of-brilliance+)) (when (mob-effect-p actor +mob-effect-empowered-undead+) (rem-mob-effect actor +mob-effect-empowered-undead+)) (when (mob-effect-p actor +mob-effect-polymorph-sheep+) (rem-mob-effect actor +mob-effect-polymorph-sheep+)) (when (mob-effect-p actor +mob-effect-demonic-power+) (rem-mob-effect actor +mob-effect-demonic-power+)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms into a tree. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-tree+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) ;; polymorph block mutations (loop for ability-type-id in (get-mob-all-abilities actor) with mutation-list = () when (and (mob-is-ability-mutation actor ability-type-id) (on-remove-mutation (get-ability-type-by-id ability-type-id))) do (mob-remove-mutation actor ability-type-id) (pushnew ability-type-id mutation-list) finally (setf (param1 effect) (append (param1 effect) (list mutation-list)))) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (increase-piety-for-god +god-entity-malseraph+ actor 50)) :on-remove #'(lambda (effect actor) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A.~%" str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms back into a ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (name (get-mob-type-by-id (first (param1 effect))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) (first (param1 effect))) (setf (max-hp actor) (second (param1 effect))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) ;; polymorph returns mutations (loop for ability-type-id in (third (param1 effect)) when (on-add-mutation (get-ability-type-by-id ability-type-id)) do (mob-set-mutation actor ability-type-id)) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (increase-piety-for-god +god-entity-malseraph+ actor 50)) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-rest-in-peace+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Rest in peace") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*white*))) (set-effect-type (make-instance 'effect-type :id +mob-effect-life-guard+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Meat shield") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (setf (mob-type actor) (mob-type (get-mob-by-id (slave-mob-id actor)))) (setf (max-hp actor) (max-hp (get-mob-by-id (slave-mob-id actor)))) (setf (cur-hp actor) (cur-hp (get-mob-by-id (slave-mob-id actor)))) (setf (weapon actor) (weapon (get-mob-by-id (slave-mob-id actor)))) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) (mob-set-ability actor +mob-abil-ghost-possess+ t) (mob-set-ability actor +mob-abil-ghost-release+ t) (mob-set-ability actor +mob-abil-detect-unnatural+ t) (mob-remove-ability actor +mob-abil-possessable+) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) ) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (setf (mob-type actor) +mob-type-ghost+) (setf (cur-hp (get-mob-by-id (slave-mob-id actor))) (cur-hp actor)) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-invisibility+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Invisibility") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-soul-sickness+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Soul sickness") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*cyan*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A gets infected with soul sickness. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-tick #'(lambda (effect actor) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (when (and (get-mob-* (level *world*) dx dy (z actor)) (mob-ability-p (get-mob-* (level *world*) dx dy (z actor)) +mob-abil-soul+) (not (mob-effect-p (get-mob-* (level *world*) dx dy (z actor)) +mob-effect-soul-sickness+))) (set-mob-effect (get-mob-* (level *world*) dx dy (z actor)) :effect-type-id +mob-effect-soul-sickness+ :actor-id (id actor) :cd 30)))) (when (and (zerop (random 4)) (> (cur-hp actor) 1) (mob-ability-p actor +mob-abil-soul+)) (inflict-damage actor :min-dmg 1 :max-dmg 1 :dmg-type +weapon-dmg-mind+ :att-spd nil :weapon-aux () :acc 100 :actor (get-mob-by-id (actor-id effect)) :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from soul sickness. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from soul sickness. " (capitalize-name (prepend-article +article-the+ (visible-name actor))))))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-demonic-power+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Demonic power") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*magenta*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-satanist-empowered+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) (incf (total-demons (level *world*))) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A gains demonic power. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (let ((old-max-hp (max-hp actor)) (null-hp (if (<= (cur-hp actor) 0) t nil))) (setf (mob-type actor) +mob-type-satanist+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (when (and (zerop (cur-hp actor)) (null null-hp)) (setf (cur-hp actor) 1))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) (decf (total-demons (level *world*))) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A.~%" str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A transforms back into a human being. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-demonic-sigil+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Demonic sigil") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (push (id actor) (demonic-sigils (level *world*))) (setf (param1 effect) 0)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (setf (demonic-sigils (level *world*)) (remove (id actor) (demonic-sigils (level *world*)))) ) :on-tick #'(lambda (effect actor) (declare (ignore actor)) (multiple-value-bind (sigils-num max-turns) (values-list (win-condition/win-formula (get-win-condition-by-id :win-cond-demonic-conquest))) (declare (ignore sigils-num)) (when (< (param1 effect) max-turns) (incf (param1 effect)))) ))) (set-effect-type (make-instance 'effect-type :id +mob-effect-demonic-machine+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Demonic machine") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (push (id actor) (demonic-machines (level *world*)))) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (setf (demonic-machines (level *world*)) (remove (id actor) (demonic-machines (level *world*)))) ) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-bomb-ticking+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Bomb ticking") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*) :on-add #'(lambda (effect actor) (declare (ignore actor)) (unless (param1 effect) (setf (param1 effect) 0)) ) :on-remove #'(lambda (effect actor) (declare (ignore actor effect)) ) :on-tick #'(lambda (effect actor) (with-slots (param1) effect (incf param1) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "The bomb ticks... ~A! " param1) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 20 #'(lambda (str) (format nil "You hear a clock ticking~A. " str))) (when (= param1 2) (remove-mob-from-level-list (level *world*) actor) (let ((bomb-mob)) (setf bomb-mob (make-instance 'mob :mob-type +mob-type-military-bomb-2+ :x (x actor) :y (y actor) :z (z actor))) (add-mob-to-level-list (level *world*) bomb-mob) (set-mob-effect bomb-mob :effect-type-id +mob-effect-bomb-ticking+ :actor-id (actor-id effect) :cd t :param1 param1) (set-mob-location bomb-mob (x bomb-mob) (y bomb-mob) (z bomb-mob) :apply-gravity t) (setf (cur-hp bomb-mob) (cur-hp actor)) (update-visible-mobs bomb-mob) ;; a hack to stop the new bomb from ticking on the same turn (setf (cur-ap bomb-mob) 0))) (when (= param1 4) (remove-mob-from-level-list (level *world*) actor) (let ((bomb-mob)) (setf bomb-mob (make-instance 'mob :mob-type +mob-type-military-bomb-3+ :x (x actor) :y (y actor) :z (z actor))) (add-mob-to-level-list (level *world*) bomb-mob) (set-mob-effect bomb-mob :effect-type-id +mob-effect-bomb-ticking+ :actor-id (actor-id effect) :cd t :param1 param1) (set-mob-location bomb-mob (x bomb-mob) (y bomb-mob) (z bomb-mob) :apply-gravity t) (update-visible-mobs bomb-mob) (setf (cur-hp bomb-mob) (cur-hp actor)) ;; a hack to stop the new bomb from ticking on the same turn (setf (cur-ap bomb-mob) 0))) (when (> param1 5) (remove-mob-from-level-list (level *world*) actor) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "KABOOM! ") :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 150 #'(lambda (str) (format nil "You hear a huge explosion~A. " str))) (let ((bomb-plant-target-feature (get-feature-by-id (find +feature-bomb-plant-target+ (get-features-* (level *world*) (x actor) (y actor) (z actor)) :key #'(lambda (a) (feature-type (get-feature-by-id a))))))) (loop for (x y z) in (param1 bomb-plant-target-feature) do (set-terrain-* (level *world*) x y z +terrain-floor-air+)) (remove-feature-from-level-list (level *world*) bomb-plant-target-feature) (remove-feature-from-world bomb-plant-target-feature) (setf (bomb-plant-locations (level *world*)) (remove (id bomb-plant-target-feature) (bomb-plant-locations (level *world*))))) (make-explosion-at-xyz (level *world*) (x actor) (y actor) (z actor) 3 (get-mob-by-id (actor-id effect)) :dmg-list `((:min-dmg 6 :max-dmg 10 :dmg-type ,+weapon-dmg-fire+ :weapon-aux (:is-fire)) (:min-dmg 6 :max-dmg 10 :dmg-type ,+weapon-dmg-iron+ :weapon-aux (:is-fire)))) ))) )) (set-effect-type (make-instance 'effect-type :id +mob-effect-reduce-resitances+ :name-func #'(lambda (effect actor) (declare (ignore effect actor)) "Reduce resistances") :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*yellow*) :on-add #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)) :on-remove #'(lambda (effect actor) (declare (ignore effect)) (adjust-armor actor)))) (set-effect-type (make-instance 'effect-type :id +mob-effect-strength-in-numbers+ :name-func #'(lambda (effect actor) (declare (ignore actor)) (format nil "Strength in numbers (~A%)" (param1 effect))) :color-func #'(lambda (effect actor) (declare (ignore effect actor)) sdl:*green*)))
140,634
Common Lisp
.lisp
1,387
37.665465
219
0.280876
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
b3800f688e216077b26426902fb4e395c827caab7c275441540110974b6f6384
2,860
[ -1 ]
2,861
terrain.lisp
gwathlobal_CotD/src/terrain.lisp
(in-package :cotd) ;;---------------------- ;; TERRAIN-TYPE ;;---------------------- (defclass terrain-type () ((id :initarg :id :accessor id :type fixnum) (glyph-idx :initform 0 :initarg :glyph-idx :accessor glyph-idx :type fixnum) (glyph-color :initform sdl:*white* :initarg :glyph-color :accessor glyph-color :type sdl:color) (back-color :initform sdl:*black* :initarg :back-color :accessor back-color :type sdl:color) (name :initform "No name terrain" :initarg :name :accessor name) (on-step :initform nil :initarg :on-step :accessor on-step) ;; a function that takes (mob x y z) (on-use :initform nil :initarg :on-use :accessor on-use) ;; a function that takes (mob x y z) (on-bump-terrain :initform nil :initarg :on-bump-terrain :accessor on-bump-terrain) ;; a function that takes (mob x y z) (trait :initform (make-hash-table) :initarg :trait :accessor trait) ;; :trait-blocks-move - +terrain-trait-blocks-move+ ;; :trait-blocks-move-floor - +terrain-trait-blocks-move-floor+ ;; :trait-blocks-vision - +terrain-trait-blocks-vision+ ;; :trait-blocks-vision-floor - +terrain-trait-blocks-vision-floor+ ;; :trait-blocks-projectiles - +terrain-trait-blocks-projectiles+ ;; :trait-blocks-projectiles-floor - +terrain-trait-blocks-projectiles-floor+ ;; :trait-slope-up - +terrain-trait-slope-up+ ;; :trait-slope-down - +terrain-trait-slope-down+ ;; :trait-not-climable - +terrain-trait-not-climable+ ;; :trait-light-source - +terrain-trait-light-source+ ;; :trait-can-switch-light - +terrain-trait-can-switch-light+ ;; :trait-blocks-sound - +terrain-trait-blocks-sound+ ;; :trait-blocks-sound-floor - +terrain-trait-blocks-sound-floor+ ;; :trait-water - +terrain-trait-water+ ;; :trait-move-cost-factor - +terrain-trait-move-cost-factor+ ;; :trait-openable-door - +terrain-trait-openable-door+ ;; :trait-openable-window - +terrain-trait-openable-window+ ;; :trait-flammable - +terrain-trait-flammable+ ;; :trait-can-jump-over - +terrain-trait-can-jump-over+ ;; :trait-can-have-rune - +terrain-trait-can-have-rune+ )) (defun set-terrain-type (terrain-type) (when (>= (id terrain-type) (length *terrain-types*)) (adjust-array *terrain-types* (list (1+ (id terrain-type))))) (setf (aref *terrain-types* (id terrain-type)) terrain-type)) (defun get-terrain-type-by-id (terrain-type-id) (aref *terrain-types* terrain-type-id)) (defmethod initialize-instance :after ((terrain-type terrain-type) &key trait-blocks-move trait-blocks-move-floor trait-blocks-vision trait-blocks-vision-floor trait-blocks-projectiles trait-blocks-projectiles-floor trait-slope-up trait-slope-down trait-not-climable trait-light-source trait-blocks-sound trait-blocks-sound-floor trait-water (trait-move-cost-factor 1) trait-openable-door trait-openable-window trait-flammable trait-can-jump-over trait-can-have-rune trait-can-switch-light) (when trait-blocks-move (setf (gethash +terrain-trait-blocks-move+ (trait terrain-type)) t)) (when trait-blocks-move-floor (setf (gethash +terrain-trait-blocks-move-floor+ (trait terrain-type)) trait-blocks-move-floor)) (when trait-blocks-vision (setf (gethash +terrain-trait-blocks-vision+ (trait terrain-type)) trait-blocks-vision)) (when trait-blocks-vision-floor (setf (gethash +terrain-trait-blocks-vision-floor+ (trait terrain-type)) trait-blocks-vision-floor)) (when trait-blocks-projectiles (setf (gethash +terrain-trait-blocks-projectiles+ (trait terrain-type)) t)) (when trait-blocks-projectiles-floor (setf (gethash +terrain-trait-blocks-projectiles-floor+ (trait terrain-type)) t)) (when trait-slope-up (setf (gethash +terrain-trait-slope-up+ (trait terrain-type)) t)) (when trait-slope-down (setf (gethash +terrain-trait-slope-down+ (trait terrain-type)) t)) (when trait-not-climable (setf (gethash +terrain-trait-not-climable+ (trait terrain-type)) t)) (when trait-light-source (setf (gethash +terrain-trait-light-source+ (trait terrain-type)) trait-light-source)) (when trait-blocks-sound (setf (gethash +terrain-trait-blocks-sound+ (trait terrain-type)) trait-blocks-sound)) (when trait-blocks-sound-floor (setf (gethash +terrain-trait-blocks-sound-floor+ (trait terrain-type)) trait-blocks-sound-floor)) (when trait-water (setf (gethash +terrain-trait-water+ (trait terrain-type)) trait-water)) (when trait-move-cost-factor (setf (gethash +terrain-trait-move-cost-factor+ (trait terrain-type)) trait-move-cost-factor)) (when trait-openable-door (setf (gethash +terrain-trait-openable-door+ (trait terrain-type)) trait-openable-door)) (when trait-openable-window (setf (gethash +terrain-trait-openable-window+ (trait terrain-type)) trait-openable-window)) (when trait-flammable (setf (gethash +terrain-trait-flammable+ (trait terrain-type)) trait-flammable)) (when trait-can-jump-over (setf (gethash +terrain-trait-can-jump-over+ (trait terrain-type)) trait-can-jump-over)) (when trait-can-have-rune (setf (gethash +terrain-trait-can-have-rune+ (trait terrain-type)) trait-can-have-rune)) (when trait-can-switch-light (setf (gethash +terrain-trait-can-switch-light+ (trait terrain-type)) trait-can-switch-light)) ) (defun get-terrain-type-trait (terrain-type-id key) (gethash key (trait (get-terrain-type-by-id terrain-type-id)))) (defun get-terrain-name (terrain-type-id) (name (get-terrain-type-by-id terrain-type-id))) (defun get-terrain-on-step (terrain-type-id) (on-step (get-terrain-type-by-id terrain-type-id))) (defun get-terrain-on-use (terrain-type-id) (on-use (get-terrain-type-by-id terrain-type-id))) (defun get-terrain-on-bump (terrain-type-id) (on-bump-terrain (get-terrain-type-by-id terrain-type-id)))
6,047
Common Lisp
.lisp
95
57.410526
225
0.696826
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
03b3f9558d838461b399f934ee8a76db7cbb6bf7567a0fcdff12ad109e0261a6
2,861
[ -1 ]
2,862
world-globals.lisp
gwathlobal_CotD/src/world-globals.lisp
(in-package :cotd) (defenum:defenum world-sector-type-enum (:world-sector-test :world-sector-normal-residential :world-sector-normal-sea :world-sector-normal-island :world-sector-normal-port :world-sector-normal-lake :world-sector-normal-forest :world-sector-abandoned-residential :world-sector-abandoned-island :world-sector-abandoned-port :world-sector-abandoned-lake :world-sector-abandoned-forest :world-sector-corrupted-residential :world-sector-corrupted-island :world-sector-corrupted-port :world-sector-corrupted-lake :world-sector-corrupted-forest :world-sector-hell-jungle )) (defenum:defenum mission-type-enum (:mission-type-none :mission-type-test :mission-type-demonic-attack :mission-type-demonic-raid :mission-type-demonic-conquest :mission-type-demonic-thievery :mission-type-military-raid :mission-type-military-conquest :mission-type-celestial-purge :mission-type-celestial-retrieval :mission-type-eliminate-satanists :mission-type-celestial-sabotage :mission-type-military-sabotage)) (defenum:defenum mission-faction-presence-enum (:mission-faction-absent :mission-faction-present :mission-faction-delayed)) (defenum:defenum world-sector-general-type (:world-sector-sea :world-sector-normal :world-sector-abandoned :world-sector-corrupted :world-sector-hell)) (defparameter *mission-types* (make-hash-table)) (defparameter *campaign-effect-types* (make-hash-table))
2,832
Common Lisp
.lisp
43
31.209302
76
0.405891
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
81fddc7072ef8d4a4cfed3ffeae5c10cf6e7b16dbbab6c0467734f820037a6c9
2,862
[ -1 ]
2,863
cards.lisp
gwathlobal_CotD/src/cards.lisp
(in-package :cotd) (defconstant +item-card-blink+ 0) (defconstant +item-card-teleport+ 1) (defconstant +item-card-disguise+ 2) (defconstant +item-card-sprint+ 3) (defconstant +item-card-flying+ 4) (defconstant +item-card-curse-other+ 5) (defconstant +item-card-blindness-other+ 6) (defconstant +item-card-fear-other+ 7) (defconstant +item-card-slow-other+ 8) (defconstant +item-card-silence-other+ 9) (defconstant +item-card-confuse-other+ 10) (defconstant +item-card-polymorph-other+ 11) (defconstant +item-card-polymorph-self+ 12) (defconstant +item-card-irradiate-other+ 13) (defconstant +item-card-irradiate-self+ 14) (defconstant +item-card-confuse-self+ 15) (defconstant +item-card-silence-self+ 16) (defconstant +item-card-slow-self+ 17) (defconstant +item-card-fear-self+ 18) (defconstant +item-card-blindness-self+ 19) (defconstant +item-card-curse-self+ 20) (defconstant +item-card-give-deck+ 21) (defconstant +item-card-glowing-all+ 22) (defconstant +item-card-cure-mutation+ 23) (defconstant +item-card-lignify-other+ 24) (defconstant +item-card-lignify-self+ 25) (defclass card-type () ((id :initarg :id :accessor id) (name :initform "Unnamed card" :initarg :name :accessor name) (on-use :initform #'(lambda (card-type actor) (declare (ignore card-type actor)) nil) :initarg :on-use :accessor on-use) )) (defun get-card-type-by-id (card-type-id) (aref *card-types* card-type-id)) (defun set-card-type (card-type) (when (>= (id card-type) (length *card-types*)) (adjust-array *card-types* (list (1+ (id card-type))))) (setf (aref *card-types* (id card-type)) card-type))
1,669
Common Lisp
.lisp
41
37.609756
64
0.714286
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
48fb6bf346611ab3b0e679734059b44895cd7238a29271518e25e7bc45c12613
2,863
[ -1 ]
2,864
glyph-globals.lisp
gwathlobal_CotD/src/glyph-globals.lisp
(in-package :cotd) (defconstant +glyph-id-exclamation-mark+ 1) (defconstant +glyph-id-hash+ 3) (defconstant +glyph-id-percent+ 5) (defconstant +glyph-id-large-a+ 33) (defconstant +glyph-id-large-d+ 36) (defconstant +glyph-id-large-m+ 45) (defconstant +glyph-id-large-t+ 52) (defconstant +glyph-id-tilda+ 94) (defconstant +glyph-id-wall+ 96) (defconstant +glyph-id-double-tilda+ 98) (defconstant +glyph-id-solid-floor+ 99) (defconstant +glyph-id-sacrificial-circle+ 124) (defconstant +glyph-id-book+ 125) (defconstant +glyph-id-portal+ 126) (defconstant +glyph-id-christ-cross+ 127) (defconstant +glyph-id-horizontal-river+ 131) (defconstant +glyph-id-vertical-river+ 132) (defconstant +glyph-id-three-dots+ 133) (defconstant +glyph-id-crossed-swords+ 134) (defconstant +glyph-id-church+ 135) (defconstant +glyph-id-machine+ 136) (defconstant +glyph-id-leaf-tree+ 137) (defconstant +glyph-id-pine-tree+ 138) (defconstant +glyph-id-normal-tree+ 139) (defconstant +glyph-id-abandoned-tree+ 140) (defconstant +glyph-id-corrupted-tree+ 141) (defconstant +glyph-id-campaign-house-1+ 142) (defconstant +glyph-id-campaign-house-2+ 143) (defconstant +glyph-id-normal-house+ 144) (defconstant +glyph-id-abandoned-house+ 145) (defconstant +glyph-id-corrupted-house+ 146) (defconstant +glyph-id-factory-icon+ 147) (defconstant +glyph-id-target-icon+ 148) (defconstant +glyph-id-bomb+ 149)
1,378
Common Lisp
.lisp
35
38.342857
47
0.773472
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
a1c504d37dd3d3ededc87c2e421cefb16e0cb22db29bc399e76fb304620db464
2,864
[ -1 ]
2,865
init-mob-types.lisp
gwathlobal_CotD/src/init-mob-types.lisp
(in-package :cotd) ;;-------------------- ;; MOB-TEMPLATE Declarations ;;-------------------- ;;-------------------- ;; CITIZENS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-player+ :glyph-idx 32 :glyph-color sdl:*white* :back-color sdl:*black* :max-hp 20 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 1 3 +normal-ap+ 100 ()) nil) :base-dodge 25 :abil-see-all t :abil-open-close-door t :abil-nameless t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-human+ :name "human" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-follow-leader t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-man+ :name "man" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 4 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :init-items (list (list +item-type-coin+ #'(lambda () (+ 5 (random 10)))) (list +item-type-clothing+ #'(lambda () (random 2)))) :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-follow-leader t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-woman+ :name "woman" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 4 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :init-items (list (list +item-type-coin+ #'(lambda () (+ 5 (random 10)))) (list +item-type-clothing+ #'(lambda () (random 2)))) :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-follow-leader t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-child+ :name "child" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 5 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 0 0 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 3 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-follow-leader t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-clerk+ :name "clerk" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Fists" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 4 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :init-items (list (list +item-type-coin+ #'(lambda () (+ 10 (random 10)))) (list +item-type-clothing+ #'(lambda () (random 2)))) :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-follow-leader t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-criminal+ :name "criminal" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-criminals+ :weapon (list "Knife" (list +weapon-dmg-iron+ 0 2 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 4 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :init-items (list (list +item-type-clothing+ #'(lambda () (random 2)))) :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-follow-leader t :ai-avoid-possession t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-policeman+ :name "police officer" :glyph-idx 32 :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-civilians+ :weapon (list "Police baton" (list +weapon-dmg-iron+ 0 2 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 4 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-civilian t :init-items (list (list +item-type-coin+ #'(lambda () (+ 5 (random 10)))) (list +item-type-clothing+ #'(lambda () (random 2)))) :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-follow-leader t :ai-avoid-possession t :ai-swim-up t )) ;;-------------------- ;; CHURCH ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-priest+ :name "priest" :glyph-idx 32 :glyph-color sdl:*white* :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-church+ :weapon (list "Cross" (list +weapon-dmg-iron+ 0 0 +normal-ap+ 100 ()) nil) :base-dodge 20 :strength 1 :base-light-radius 6 :abil-can-be-blessed t :abil-detect-evil t :abil-human t :abil-independent t :abil-soul t :abil-toggle-light t :abil-prayer-bless t :abil-open-close-door t :abil-smite t :abil-slow t :abil-prayer-wrath t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-swim-up t )) ;;-------------------- ;; SATANISTS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-satanist+ :name "satanist" :glyph-idx 32 :glyph-color sdl:*magenta* :back-color sdl:*black* :max-hp 7 :max-fp 0 :faction +faction-type-satanists+ :weapon (list "Vorpal touch" (list +weapon-dmg-vorpal+ 2 3 +normal-ap+ 100 ()) nil) :base-dodge 20 :armor (list (list +weapon-dmg-vorpal+ 3 0)) :strength 1 :base-light-radius 4 :abil-detect-good t :abil-human t :abil-unholy t :abil-soul t :abil-free-call t :abil-curse t :abil-toggle-light t :abil-open-close-door t :abil-reanimate-corpse t :abil-empower-undead t :abil-decipher-rune t :abil-demon-word-flesh t :abil-demon-word-plague t :abil-demon-word-power t :abil-demon-word-darkness t :abil-demon-word-invasion t :abil-demon-word-knockback t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-satanist-empowered+ :name "empowered satanist" :glyph-idx 36 :glyph-color sdl:*magenta* :back-color sdl:*black* :max-hp 30 :max-fp 0 :faction +faction-type-satanists+ :weapon (list "Vorpal claws" (list +weapon-dmg-vorpal+ 4 8 +normal-ap+ 100 ()) nil) :base-dodge 20 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 4 :base-light-radius 0 :abil-detect-good t :abil-human t :abil-unholy t :abil-soul t :abil-unholy t :abil-loves-infighting t :abil-demon t :abil-lifesteal t :abil-no-breathe t :abil-free-call t :abil-toggle-light t :abil-open-close-door t :abil-charge t :abil-answer-the-call t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) ;;-------------------- ;; CRIMINALS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-thief+ :name "thief" :glyph-idx 32 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-criminals+ :weapon (list "Knife" (list +weapon-dmg-iron+ 2 3 +normal-ap+ 100 ()) nil) :base-dodge 30 :strength 1 :base-light-radius 0 :base-stealth 10 :abil-human t :abil-death-from-above t :abil-climbing t :abil-possessable t :abil-can-be-blessed t :abil-independent t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :abil-open-close-window t :abil-sprint t :abil-jump t :abil-make-disguise t :abil-remove-disguise t :init-items (list (list +item-type-smoke-bomb+ #'(lambda () 3))) :ai-kleptomaniac t :ai-takes-valuable-items t :ai-cautious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-avoid-possession t :ai-swim-up t )) ;;-------------------- ;; MILITARY ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-soldier+ :name "soldier" :glyph-idx 32 :glyph-color sdl:*green* :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "Rifle" (list +weapon-dmg-iron+ 1 2 +normal-ap+ 100 ()) (list +weapon-dmg-iron+ 2 4 +normal-ap+ 1 1 1 100 "shoots" ())) :base-dodge 25 :strength 1 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-keen-senses t :abil-horseback-riding t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :init-items (list (list +item-type-medkit+ #'(lambda () 3))) :ai-curious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-reload-ranged-weapon t :ai-shoot-enemy t :ai-follow-leader t :ai-avoid-possession t :ai-avoid-melee t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-sergeant+ :name "sergeant" :glyph-idx 32 :glyph-color (sdl:color :r 0 :g 100 :b 0) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "Revolver" (list +weapon-dmg-iron+ 1 2 +normal-ap+ 100 ()) (list +weapon-dmg-iron+ 2 3 +normal-ap+ 6 6 1 100 "shoots" ())) :base-dodge 25 :strength 1 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-soul t :abil-nameless t :abil-keen-senses t :abil-horseback-riding t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :init-items (list (list +item-type-medkit+ #'(lambda () 3))) :ai-curious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-reload-ranged-weapon t :ai-shoot-enemy t :ai-follow-leader t :ai-avoid-possession t :ai-avoid-melee t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-chaplain+ :name "chaplain" :glyph-idx 32 :glyph-color (sdl:color :r 85 :g 107 :b 47) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "Revolver" (list +weapon-dmg-iron+ 1 2 +normal-ap+ 100 ()) (list +weapon-dmg-iron+ 2 3 +normal-ap+ 6 6 1 100 "shoots" ())) :base-dodge 25 :strength 1 :abil-can-be-blessed t :abil-human t :abil-keen-senses t :abil-soul t :abil-detect-good t :abil-detect-evil t :abil-nameless t :abil-prayer-reveal t :abil-prayer-shield t :abil-military-follow-me t :abil-horseback-riding t :abil-dismount t :abil-independent t :abil-toggle-light t :abil-open-close-door t :init-items (list (list +item-type-medkit+ #'(lambda () 3))) :ai-curious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-reload-ranged-weapon t :ai-shoot-enemy t :ai-avoid-melee t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-gunner+ :name "machine-gunner" :glyph-idx 32 :glyph-color (sdl:color :r 50 :g 150 :b 50) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "Light machine gun" (list +weapon-dmg-iron+ 1 2 +normal-ap+ 100 ()) (list +weapon-dmg-iron+ 2 3 +normal-ap+ 6 6 6 70 "shoots" ())) :base-dodge 25 :strength 1 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-keen-senses t :abil-soul t :abil-nameless t :abil-toggle-light t :abil-open-close-door t :init-items (list (list +item-type-medkit+ #'(lambda () 3))) :ai-curious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-reload-ranged-weapon t :ai-shoot-enemy t :ai-follow-leader t :ai-avoid-possession t :ai-avoid-melee t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-scout+ :name "scout" :glyph-idx 32 :glyph-color (sdl:color :r 60 :g 179 :b 113) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "Rifle" (list +weapon-dmg-iron+ 1 2 +normal-ap+ 100 ()) (list +weapon-dmg-iron+ 4 6 +normal-ap+ 1 1 1 120 "shoots" ())) :base-dodge 25 :strength 1 :abil-possessable t :abil-can-be-blessed t :abil-human t :abil-keen-senses t :abil-soul t :abil-independent t :abil-starts-with-horse t :abil-detect-good t :abil-detect-evil t :abil-nameless t :abil-horseback-riding t :abil-dismount t :abil-eagle-eye t :abil-open-close-door t :init-items (list (list +item-type-medkit+ #'(lambda () 3)) (list +item-type-signal-flare+ #'(lambda () 2))) :ai-curious t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-reload-ranged-weapon t :ai-shoot-enemy t :ai-avoid-possession t :ai-avoid-melee t :ai-swim-up t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-military-bomb-1+ :name "bomb" :glyph-idx +glyph-id-bomb+ :glyph-color sdl:*yellow* :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "None" nil nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 1 50) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-mind+ 0 100)) :strength 0 :base-light-radius 0 :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-no-corpse t :abil-nameless t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-military-bomb-2+ :name "bomb" :glyph-idx +glyph-id-bomb+ :glyph-color (sdl:color :r 255 :g 69 :b 0) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "None" nil nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 1 50) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-mind+ 0 100)) :strength 0 :base-light-radius 0 :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-no-corpse t :abil-nameless t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-military-bomb-3+ :name "bomb" :glyph-idx +glyph-id-bomb+ :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-military+ :weapon (list "None" nil nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 1 50) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-mind+ 0 100)) :strength 0 :base-light-radius 0 :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-no-corpse t :abil-nameless t )) ;;-------------------- ;; ANGELS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-angel+ :name "chrome angel" :glyph-idx 65 :glyph-color sdl:*cyan* :back-color sdl:*black* :max-hp 18 :max-fp 32 :faction +faction-type-angels+ :weapon (list "Holy fists" (list +weapon-dmg-fire+ 3 6 +normal-ap+ 100 (list :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-heal-self 1 :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-purge-rune t :abil-open-close-door t :abil-ignite-the-fire t :abil-avatar-of-brilliance t :abil-split-soul t :abil-resurrection t :ai-wants-bless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-archangel+ :name "Avatar of Brilliance" :glyph-idx +glyph-id-large-a+ :glyph-color sdl:*cyan* :back-color sdl:*black* :max-hp 36 :max-fp 32 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 6 9 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0) (list +weapon-dmg-fire+ 3 50)) :strength 4 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-heal-self 2 :abil-detect-evil t :abil-blindness t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-split-soul t :abil-resurrection t :abil-remove-disguise t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-singer+ :name "star singer" :glyph-idx 65 :glyph-color (sdl:color :r 0 :g 128 :b 128) :back-color sdl:*black* :max-hp 14 :max-fp 12 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-righteous-fury t :abil-pain-link t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-gazer+ :name "star gazer" :glyph-idx 65 :glyph-color (sdl:color :r 32 :g 170 :b 170) :back-color sdl:*black* :max-hp 14 :max-fp 12 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-silence t :abil-confuse t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-mender+ :name "star mender" :glyph-idx 65 :glyph-color (sdl:color :r 127 :g 255 :b 200) :back-color sdl:*black* :max-hp 14 :max-fp 12 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-heal-other 1 :abil-soul-reinforcement t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-singer-mender+ :name "amalgamated angel" :glyph-idx +glyph-id-large-a+ :glyph-color (sdl:color :r 127 :g 255 :b 200) :back-color sdl:*black* :max-hp 14 :max-fp 24 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-heal-other 1 :abil-righteous-fury t :abil-pain-link t :abil-soul-reinforcement t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-singer-gazer+ :name "amalgamated angel" :glyph-idx +glyph-id-large-a+ :glyph-color (sdl:color :r 127 :g 255 :b 200) :back-color sdl:*black* :max-hp 14 :max-fp 24 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-righteous-fury t :abil-pain-link t :abil-silence t :abil-confuse t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-gazer-mender+ :name "amalgamated angel" :glyph-idx +glyph-id-large-a+ :glyph-color (sdl:color :r 127 :g 255 :b 200) :back-color sdl:*black* :max-hp 14 :max-fp 24 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-heal-other 1 :abil-soul-reinforcement t :abil-silence t :abil-confuse t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-star-singer-gazer-mender+ :name "amalgamated angel" :glyph-idx +glyph-id-large-a+ :glyph-color (sdl:color :r 0 :g 128 :b 128) :back-color sdl:*black* :max-hp 14 :max-fp 36 :faction +faction-type-angels+ :weapon (list "Flaming sword" (list +weapon-dmg-fire+ 3 5 +normal-ap+ 100 (list :chops-body-parts :is-fire)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 0) (list +weapon-dmg-fire+ 3 50)) :strength 2 :abil-purging-touch t :abil-blessing-touch t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-soul t :abil-conceal-divine t :abil-reveal-divine t :abil-detect-evil t :abil-dismount t :abil-dominate-gargantaur t :abil-gargantaurs-mind-burn t :abil-toggle-light t :abil-open-close-door t :abil-ignite-the-fire t :abil-trinity-mimic t :abil-merge t :abil-unmerge t :abil-heal-other 1 :abil-righteous-fury t :abil-pain-link t :abil-soul-reinforcement t :abil-silence t :abil-confuse t :abil-resurrection t :abil-purge-rune t :ai-wants-bless t :ai-curious t :ai-trinity-mimic t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-angel-image+ :name "stellar image" :glyph-idx 65 :glyph-color sdl:*white* :back-color sdl:*black* :max-hp 1 :max-fp 0 :faction +faction-type-angels+ :weapon (list "Illusory fire" nil nil) :base-dodge 35 :armor (list (list +weapon-dmg-flesh+ 0 100) (list +weapon-dmg-fire+ 0 100)) :strength 0 :abil-angel t :abil-soul t :abil-no-breathe t :abil-restore-soul t :abil-no-corpse t :abil-nameless t :ai-split-soul t :ai-use-ability t)) ;;-------------------- ;; DEMONS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-imp+ :name "crimson imp" :glyph-idx 73 :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 12 :max-fp 5 :faction +faction-type-demons+ :evolve-mob-id +mob-type-demon+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 3 5 +normal-ap+ 100 ()) nil) :base-dodge 35 :move-spd (truncate (* +normal-ap+ 0.8)) :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :abil-can-possess 1 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-nameless t :abil-strength-in-numbers t :abil-coward t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-no-breathe t :abil-dominate-fiend t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :abil-can-possess-toggle t :abil-sacrifice-host t :abil-bend-space t :ai-horde t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-demon+ :name "crimson demon" :glyph-idx 68 :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 20 :max-fp 12 :faction +faction-type-demons+ :evolve-mob-id +mob-type-archdemon+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 4 7 +normal-ap+ 100 ()) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 3 :base-light-radius 0 :abil-can-possess 2 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-strength-in-numbers t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-instill-fear 3 :abil-no-breathe t :abil-toggle-light t :abil-dominate-fiend t :abil-dismount t :abil-open-close-door t :abil-can-possess-toggle t :abil-sacrifice-host t :abil-bend-space t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-archdemon+ :name "archdemon" :glyph-idx +glyph-id-large-d+ :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 40 :max-fp 16 :faction +faction-type-demons+ :weapon (list "Chains of Shattering" (list +weapon-dmg-vorpal+ 5 10 +normal-ap+ 100 ()) nil) :base-dodge 20 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 5 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-strength-in-numbers t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-instill-fear 4 :abil-charge t :abil-no-breathe t :abil-dominate-fiend t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :abil-gravity-chains t :abil-bend-space t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-shadow-imp+ :name "shadow imp" :glyph-idx 73 :glyph-color (sdl:color :r 100 :g 100 :b 100) :back-color sdl:*black* :max-hp 14 :max-fp 5 :faction +faction-type-demons+ :evolve-mob-id +mob-type-shadow-demon+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 3 5 +normal-ap+ 100 ()) nil) :base-dodge 35 :move-spd (truncate (* +normal-ap+ 0.9)) :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :base-stealth 10 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-nameless t :abil-strength-in-numbers t :abil-coward t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-no-breathe t :abil-dominate-fiend t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :abil-shadow-step t :abil-cast-shadow t :ai-horde t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-shadow-demon+ :name "shadow demon" :glyph-idx 68 :glyph-color (sdl:color :r 100 :g 100 :b 100) :back-color sdl:*black* :max-hp 22 :max-fp 12 :faction +faction-type-demons+ :evolve-mob-id +mob-type-shadow-devil+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 4 7 +normal-ap+ 100 ()) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 3 :base-light-radius 0 :base-stealth 10 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-strength-in-numbers t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-no-breathe t :abil-toggle-light t :abil-dominate-fiend t :abil-dismount t :abil-open-close-door t :abil-shadow-step t :abil-extinguish-light t :abil-cast-shadow t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-shadow-devil+ :name "shadow devil" :glyph-idx +glyph-id-large-d+ :glyph-color (sdl:color :r 100 :g 100 :b 100) :back-color sdl:*black* :max-hp 32 :max-fp 16 :faction +faction-type-demons+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 5 8 +normal-ap+ 100 ()) nil) :base-dodge 20 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 5 :base-light-radius -4 :base-stealth 10 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-strength-in-numbers t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-charge t :abil-no-breathe t :abil-dominate-fiend t :abil-dismount t :abil-toggle-light t :abil-open-close-door t :abil-shadow-step t :abil-extinguish-light t :abil-umbral-aura t :abil-cast-shadow t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-malseraph-puppet+ :name "Malseraph's puppet" :glyph-idx 68 :glyph-color sdl:*magenta* :back-color sdl:*black* :max-hp 22 :max-fp 12 :faction +faction-type-demons+ :weapon (list "Falchion" (list +weapon-dmg-vorpal+ 4 7 +normal-ap+ 100 (list :chops-body-parts)) nil) :base-dodge 25 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 3 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-loves-infighting t :abil-no-breathe t :abil-strength-in-numbers t :abil-coward t :abil-detect-good t :abil-lifesteal t :abil-call-for-help t :abil-answer-the-call t :abil-toggle-light t :abil-dominate-fiend t :abil-dismount t :abil-open-close-door t :abil-remove-disguise t :abil-irradiate t :abil-fission t :abil-deep-breath t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-demon-sigil+ :name "demonic sigil" :glyph-idx 128 :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 25 :max-fp 12 :faction +faction-type-demons+ :weapon (list "None" nil nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 1 50) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 100) (list +weapon-dmg-mind+ 0 100)) :strength 0 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-no-corpse t :abil-nameless t :abil-free-call t :ai-use-ability t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-demon-machine+ :name "demonic machine" :glyph-idx +glyph-id-machine+ :glyph-color sdl:*white* :back-color sdl:*black* :max-hp 25 :max-fp 0 :faction +faction-type-demons+ :weapon (list "None" nil nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 1 50) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 0 100) (list +weapon-dmg-mind+ 0 100)) :strength 0 :base-light-radius 0 :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-no-corpse t :abil-nameless t )) ;;-------------------- ;; UNDEAD ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-reanimated-pwr-1+ :name "reanimated body" :glyph-idx 90 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-demons+ :weapon (list "Claws & fangs" (list +weapon-dmg-flesh+ 1 3 +normal-ap+ 100 ()) nil) :base-dodge 0 :move-spd (truncate (* +normal-ap+ 1.2)) :armor (list (list +weapon-dmg-flesh+ 3 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-detect-good t :abil-no-breathe t :abil-answer-the-call t :abil-undead t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-reanimated-pwr-2+ :name "reanimated body" :glyph-idx 90 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 7 :max-fp 0 :faction +faction-type-demons+ :weapon (list "Claws & fangs" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 ()) nil) :base-dodge 0 :move-spd (truncate (* +normal-ap+ 1.2)) :armor (list (list +weapon-dmg-flesh+ 3 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-detect-good t :abil-no-breathe t :abil-answer-the-call t :abil-undead t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-reanimated-pwr-3+ :name "reanimated body" :glyph-idx 90 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-demons+ :weapon (list "Claws & fangs" (list +weapon-dmg-flesh+ 2 4 +normal-ap+ 100 ()) nil) :base-dodge 0 :move-spd (truncate (* +normal-ap+ 1.2)) :armor (list (list +weapon-dmg-flesh+ 3 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-detect-good t :abil-no-breathe t :abil-answer-the-call t :abil-undead t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-reanimated-pwr-4+ :name "reanimated body" :glyph-idx 90 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 9 :max-fp 0 :faction +faction-type-demons+ :weapon (list "Claws & fangs" (list +weapon-dmg-flesh+ 3 4 +normal-ap+ 100 ()) nil) :base-dodge 0 :move-spd (truncate (* +normal-ap+ 1.2)) :armor (list (list +weapon-dmg-flesh+ 3 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 1 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-detect-good t :abil-no-breathe t :abil-answer-the-call t :abil-undead t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-reanimated-empowered+ :name "empowered corpse" :glyph-idx 58 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 15 :max-fp 0 :faction +faction-type-demons+ :weapon (list "Claws & fangs" (list +weapon-dmg-flesh+ 4 6 +normal-ap+ 100 ()) nil) :base-dodge 0 :move-spd +normal-ap+ :armor (list (list +weapon-dmg-flesh+ 3 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 2 :base-light-radius 0 :abil-unholy t :abil-demon t :abil-detect-good t :abil-no-breathe t :abil-answer-the-call t :abil-undead t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-follow-leader t )) ;;-------------------- ;; EATER OF THE DEAD ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-eater-of-the-dead+ :name "eater of the dead" :glyph-idx 37 :glyph-color (sdl:color :r 255 :g 165 :b 0) :back-color sdl:*black* :max-hp 12 :max-fp 24 :faction +faction-type-eater+ :weapon (list "Tentacles" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) nil) :base-dodge 15 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0)) :strength 2 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-constriction t :abil-nameless t :abil-open-close-door t :abil-cannibalize t :abil-sprint t :abil-create-parasites t :abil-mutate-acid-spit t :abil-adrenal-gland t :abil-mutate-corrosive-bile t :abil-mutate-clawed-tentacle t :abil-mutate-chitinous-plating t :abil-mutate-metabolic-boost t :abil-mutate-retracting-spines t :abil-mutate-spawn-locusts t :abil-mutate-ovipositor t :abil-mutate-acid-locusts t :abil-mutate-fast-scarabs t :abil-mutate-oviposit-more-eggs t :abil-mutate-tougher-locusts t :abil-cure-mutation t :abil-mutate-thick-carapace t :abil-mutate-acidic-tips t :abil-mutate-jump t :abil-mutate-piercing-needles t :abil-mutate-accurate-bile t :abil-mutate-corroding-secretion t :abil-mutate-hooks-and-suckers t :abil-mutate-disguise-as-human t :abil-mutate-spawn-scarabs t :abil-mutate-spawn-larva t :abil-mutate-spore-colony t :ai-curious t :ai-search-corpses t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-shoot-enemy t :ai-avoid-melee t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-locust+ :name "locust" :glyph-idx 69 :glyph-color (sdl:color :r 255 :g 165 :b 0) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-eater+ :weapon (list "Claws" (list +weapon-dmg-flesh+ 3 4 +normal-ap+ 100 ()) nil) :base-dodge 15 :armor () :strength 1 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-acid-locust+ :name "acid locust" :glyph-idx 69 :glyph-color (sdl:color :r 150 :g 165 :b 0) :back-color sdl:*black* :max-hp 8 :max-fp 0 :faction +faction-type-eater+ :weapon (list "Claws" (list +weapon-dmg-acid+ 3 4 +normal-ap+ 100 ()) nil) :base-dodge 15 :armor () :strength 1 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-scarab+ :name "scarab" :glyph-idx 69 :glyph-color (sdl:color :r 0 :g 255 :b 0) :back-color sdl:*black* :max-hp 8 :max-fp 0 :move-spd (truncate (* +normal-ap+ 1.2)) :faction +faction-type-eater+ :weapon () :base-dodge 15 :armor () :strength 1 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-acid-explosion t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-approach-target t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-fast-scarab+ :name "fast scarab" :glyph-idx 69 :glyph-color (sdl:color :r 0 :g 255 :b 100) :back-color sdl:*black* :max-hp 8 :max-fp 0 :move-spd (truncate (* +normal-ap+ 0.8)) :faction +faction-type-eater+ :weapon () :base-dodge 15 :armor () :strength 1 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-acid-explosion t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-approach-target t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-seeker-larva+ :name "seeker larva" :glyph-idx 69 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :max-hp 6 :max-fp 0 :faction +faction-type-eater+ :weapon () :base-dodge 15 :armor () :strength 0 :base-light-radius 0 :base-stealth 10 :abil-no-breathe t :abil-primordial t :abil-cannibalize t :abil-nameless t :ai-coward t :ai-search-corpses t :ai-use-ability t :ai-find-random-location t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-spore-colony+ :name "spore colony" :glyph-idx 37 :glyph-color (sdl:color :r 150 :g 165 :b 0) :back-color sdl:*black* :max-hp 18 :max-fp 0 :faction +faction-type-eater+ :weapon (list "Tentacles & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) (list +weapon-dmg-acid+ 1 4 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges :corrodes))) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 2 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-mind+ 0 100) (list +weapon-dmg-acid+ 1 0)) :strength 2 :base-light-radius 3 :abil-no-breathe t :abil-primordial t :abil-constriction t :abil-immobile t :abil-immovable t :abil-piercing-needles t :abil-nameless t :ai-shoot-enemy t )) ;;-------------------- ;; SKINCHANGER ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-skinchanger-melee+ :name "butcher" :glyph-idx 51 :glyph-color (sdl:color :r 255 :g 165 :b 0) :back-color sdl:*black* :max-hp 12 :max-fp 24 :faction +faction-type-eater+ :weapon (list "Claws" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100) nil) :base-dodge 15 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0)) :strength 2 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-nameless t :abil-open-close-door t :abil-cannibalize t :abil-sprint t :abil-skinchange-to-flyer t :abil-skinchange-to-ranged t :abil-mutate-charge t :ai-curious t :ai-search-corpses t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-skinchanger-ranged+ :name "ravager" :glyph-idx 51 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :max-hp 12 :max-fp 24 :faction +faction-type-eater+ :weapon (list "Acid spit" (list +weapon-dmg-acid+ 1 3 +normal-ap+ 100 (list :corrodes)) (list +weapon-dmg-acid+ 1 3 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges :corrodes))) :base-dodge 15 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0)) :strength 2 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-primordial t :abil-nameless t :abil-open-close-door t :abil-cannibalize t :abil-sprint t :abil-skinchange-to-melee t :abil-skinchange-to-flyer t :abil-mutate-skin-ranged-to-turret t :ai-curious t :ai-search-corpses t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t :ai-shoot-enemy t :ai-avoid-melee t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-skinchanger-flyer+ :name "corruptor" :glyph-idx 51 :glyph-color (sdl:color :r 128 :g 0 :b 0) :back-color sdl:*black* :max-hp 12 :max-fp 24 :faction +faction-type-eater+ :weapon (list "Spines" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 nil) nil) :base-dodge 15 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0)) :strength 2 :base-light-radius 0 :base-stealth 10 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-nameless t :abil-open-close-door t :abil-cannibalize t :abil-sprint t :abil-flying t :abil-skinchange-to-melee t :abil-skinchange-to-ranged t :abil-mutate-explosive-glands t :abil-mutate-poisoning-glands t :ai-curious t :ai-search-corpses t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-skinchanger-turret+ :name "spore colony" :glyph-idx 51 :glyph-color (sdl:color :r 150 :g 165 :b 0) :back-color sdl:*black* :max-hp 18 :max-fp 24 :faction +faction-type-eater+ :weapon (list "Claws & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 ()) (list +weapon-dmg-acid+ 1 5 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges :corrodes))) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 2 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-acid+ 1 0)) :strength 3 :base-light-radius 0 :abil-detect-good t :abil-detect-evil t :abil-no-breathe t :abil-nameless t :abil-no-breathe t :abil-primordial t :abil-immobile t :abil-immovable t :abil-skinchange-to-melee t :abil-skinchange-to-ranged t :abil-skinchange-to-flyer t :ai-shoot-enemy t )) ;;-------------------- ;; GHOST ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-ghost+ :name "lost soul" :glyph-idx 71 :glyph-color (sdl:color :r 153 :g 204 :b 255) :back-color sdl:*black* :max-hp 1 :max-fp 0 :faction +faction-type-ghost+ :weapon (list "Ghostly touch" (list +weapon-dmg-vorpal+ 1 2 +normal-ap+ 100 ()) ()) :base-dodge 15 :armor (list (list +weapon-dmg-flesh+ 0 100) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0) (list +weapon-dmg-radiation+ 0 100) (list +weapon-dmg-acid+ 1 0)) :strength 1 :base-stealth 10 :base-light-radius 0 :abil-no-breathe t :abil-undead t :abil-float t :abil-soul t :abil-ghost-possess t :abil-no-corpse t :abil-invisibility t :abil-passwall t :abil-ghost-release t :abil-detect-unnatural t :abil-nameless t :ai-use-ability t :ai-use-item t :ai-find-random-location t :ai-attack-nearest-enemy t )) ;;-------------------- ;; BEASTS ;;-------------------- (set-mob-type (make-instance 'mob-type :mob-type +mob-type-horse+ :name "horse" :glyph-idx 72 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :max-hp 12 :max-fp 0 :faction +faction-type-animals+ :weapon (list "Hooves" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 0 :abil-animal t :abil-momentum 2 :abil-horse-can-be-ridden t :abil-soul t :abil-nameless t :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-sheep+ :name "sheep" :glyph-idx 72 :glyph-color sdl:*white* :back-color sdl:*black* :max-hp 12 :max-fp 0 :faction +faction-type-animals+ :weapon (list "Hooves" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 25 :strength 0 :base-light-radius 0 :abil-animal t :abil-soul t :abil-nameless t :ai-coward t :ai-use-ability t :ai-find-random-location t :ai-swim-up t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-tree+ :name "tree" :glyph-idx 52 :glyph-color sdl:*magenta* :back-color sdl:*black* :max-hp 30 :max-fp 0 :faction +faction-type-animals+ :weapon (list "Branches" (list +weapon-dmg-flesh+ 0 1 +normal-ap+ 100 ()) nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 0 100) (list +weapon-dmg-fire+ -1 0) (list +weapon-dmg-iron+ 0 50) (list +weapon-dmg-mind+ 0 100) (list +weapon-dmg-radiation+ 0 100)) :strength 0 :base-light-radius 0 :abil-no-breathe t :abil-immobile t :abil-immovable t :abil-nameless t )) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-fiend+ :name "fiend" :glyph-idx 70 :glyph-color sdl:*red* :back-color sdl:*black* :max-hp 12 :max-fp 0 :faction +faction-type-outsider-beasts+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 3 4 +normal-ap+ 100 ()) nil) :base-dodge 35 :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 2 0)) :strength 2 :base-light-radius 0 :abil-animal t :abil-demon t :abil-unholy t :abil-detect-good t :abil-lifesteal t :abil-momentum 2 :abil-fiend-can-be-ridden t :abil-loves-infighting t :abil-no-breathe t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-gargantaur+ :name "gargantaur" :glyph-idx 39 :glyph-color sdl:*cyan* :back-color sdl:*black* :max-hp 25 :max-fp 2 :faction +faction-type-outsider-beasts+ :weapon (list "Claws" (list +weapon-dmg-vorpal+ 6 10 +normal-ap+ 100 ()) nil) :base-dodge 0 :armor (list (list +weapon-dmg-flesh+ 4 0) (list +weapon-dmg-iron+ 2 0) (list +weapon-dmg-vorpal+ 4 0) (list +weapon-dmg-fire+ 4 0)) :strength 8 :base-sight 7 :map-size 3 :abil-animal t :abil-angel t :abil-facing t :abil-immovable t :abil-loves-infighting t :abil-soul t :abil-nameless t :abil-mind-burn t :abil-heal-self 1 :abil-gargantaur-teleport t :abil-detect-evil t :abil-no-breathe t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t)) (set-mob-type (make-instance 'mob-type :mob-type +mob-type-wisp+ :name "wisp" :glyph-idx 87 :glyph-color sdl:*cyan* :back-color sdl:*black* :max-hp 12 :max-fp 5 :faction +faction-type-outsider-wisps+ :weapon (list "Stellar touch" (list +weapon-dmg-fire+ 2 3 +normal-ap+ 100 ()) nil) :base-dodge 40 :move-spd +normal-ap+ :armor (list (list +weapon-dmg-flesh+ 1 0) (list +weapon-dmg-iron+ 1 0) (list +weapon-dmg-vorpal+ 1 0) (list +weapon-dmg-fire+ 1 0)) :strength 1 :base-light-radius 6 :base-sight 0 :abil-animal t :abil-angel t :abil-no-breathe t :abil-shared-minds t :abil-detect-evil t :abil-flying t :abil-no-corpse t :abil-soul t :abil-nameless t :ai-curious t :ai-use-ability t :ai-find-random-location t :ai-attack-nearest-enemy t))
75,468
Common Lisp
.lisp
741
66.287449
237
0.474246
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e7223b5b752c5642635329c501dd553314e811d11085cc06ee460399dca09f6d
2,865
[ -1 ]
2,866
campaign-command.lisp
gwathlobal_CotD/src/campaign-command.lisp
(in-package :cotd) (defparameter *campaign-commands* (make-hash-table)) (defenum:defenum campaign-command-enum (:campaign-command-angel-wait :campaign-command-demon-wait :campaign-command-military-wait :campaign-command-church-wait :campaign-command-satanist-sacrifice :campaign-command-satanist-hide-lair :campaign-command-satanist-reform-lair :campaign-command-demon-rebuild-engine :campaign-command-demon-add-army :campaign-command-demon-protect-dimension :campaign-command-demon-corrupt-portals :campaign-command-military-reveal-lair :campaign-command-military-reform-army :campaign-command-military-add-army :campaign-command-priest-delay-demons :campaign-command-priest-hasten-angels :campaign-command-eater-wait :campaign-command-eater-agitated :campaign-command-angel-reveal-lair :campaign-command-angel-divine-crusade )) (defclass campaign-command () ((id :initarg :id :accessor campaign-command/id :type campaign-command-enum) (name-func :initarg :name-func :accessor campaign-command/name-func) ;; a lambda with world param (descr-func :initarg :descr-func :accessor campaign-command/descr-func) ;; a lambda with world param (faction-type :initarg :faction-type :accessor campaign-command/faction-type) (disabled :initform nil :initarg :disabled :accessor campaign-command/disabled) (cd :initform 0 :initarg :cd :accessor campaign-command/cd) (priority :initform 0 :initarg :priority :accessor campaign-command/priority :type fixnum) ;; from 0 to 10, 0 - lowest, 10 - highest (on-check-func :initarg :on-check-func :accessor campaign-command/on-check-func) (on-trigger-start-func :initarg :on-trigger-start-func :accessor campaign-command/on-trigger-start-func) (on-trigger-end-func :initarg :on-trigger-end-func :accessor campaign-command/on-trigger-end-func))) (defun set-campaign-command (&key id name-func descr-func faction-type disabled cd (priority 0) on-check-func on-trigger-start-func on-trigger-end-func) (unless id (error ":ID is an obligatory parameter!")) (unless name-func (error ":NAME-FUNC is an obligatory parameter!")) (unless descr-func (error ":DESCR-FUNC is an obligatory parameter!")) (unless faction-type (error ":FACTION-TYPE is an obligatory parameter!")) (setf (gethash id *campaign-commands*) (make-instance 'campaign-command :id id :name-func name-func :descr-func descr-func :faction-type faction-type :disabled disabled :cd cd :priority priority :on-check-func on-check-func :on-trigger-start-func on-trigger-start-func :on-trigger-end-func on-trigger-end-func))) (defun get-campaign-command-by-id (campaign-command-id) (gethash campaign-command-id *campaign-commands*))
3,608
Common Lisp
.lisp
44
58.386364
162
0.579539
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
2f1a465177c27b0ea835959c1179c5d772c71116d44dc1b39ca6ed467a8ee8c9
2,866
[ -1 ]
2,867
level-test.lisp
gwathlobal_CotD/src/level-test.lisp
(in-package :cotd) (defun create-template-test-city (max-x max-y max-z) (log:info (format nil "CREATE-TEMPLATE-TEST-CITY~%")) ;(setf max-x *max-x-level*) ;(setf max-y *max-y-level*) ;(setf max-z *max-z-level*) (setf max-x 90) (setf max-y 30) (setf max-z 10) (let ((template-level (make-array (list max-x max-y max-z) :element-type 'fixnum :initial-element +terrain-border-floor+)) (feature-list) (level-template-z-0 (list "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################" "##############################################################################")) (level-template-z-1 (list ".............................................................................." ".............................................................................." "...#######..#######.############..........................######.....######..." "...#.....#..#.....#.#....#..#..#..........................#....#.....#....#..." "...#.....#..#.....#.#.......u..#..........................#..........#....#..." "...#.....#..#.....#.#....#.....#..........................#....#.....#....#..." "...###.###..###.###.########.###..........................######.....######..." ".............................................................................." "..........................................................######.....######..." "..........................................................#....#..........#..." "...###.###................................................#...............#..." "...#.....#................................................#....#..........#..." "...#.....#................................................######.....######..." "...#.....#............#####.......#####,,,,..................................." "...#######............#...+...........-.,,,....|.............................." "......................#...#...........#u,,,..................................." "...#######...........u######-#+#########..................######.....######..." "...#.....#............#....-.....#_____#..................#...............#..." "...#..................#....#....###____#..................#...............#..." "...#.....#............#....+....###____#..................#...............#..." "...#######............##################..................#################..." ".............................................................................." "..............................................................................")) (level-template-z-2 (list " " " " " ....... ....... ############ ...... ...... " " ....... ....... #..........# ...... ...... " " ....... ....... #.......d..# ...... ...... " " ....... ....... #..........# ...... ...... " " ....... ....... ##########-# ...... ...... " " | " " ...... ...... " " ...... ...... " " ....... ...... ...... " " ....... ...... ...... " " ....... | ...... ...... " " ....... ..... ..... " " ....... ..... .bb.. " " ..... ......d " " ....... d............######| ................. " " ....... ....u......u#____# ................. " " ....... ..#####...###____# ................. " " ....... ..#.......#_#____# ................. " " ....... ..################ ................. " " " " ")) (level-template-z-3 (list " " " " " ............ " " ............ " " ............ " " ............ " " ............ " " " " " " " " " " " " " " " " " " " " ...... " " d d. . " " ........... | . " " ......... . . " " ................ " " " " ")) ) (loop for y from 0 below max-y do (loop for x from 0 below max-x do (loop for z from 1 below max-z do (setf (aref template-level x y z) +terrain-border-air+)))) (loop for y from 1 below (1- max-y) do (loop for x from 1 below (1- max-x) do (loop for z from 1 below max-z do (setf (aref template-level x y z) +terrain-floor-air+)))) (loop for y from 1 below (1- max-y) do (loop for x from 1 below (1- max-x) do (setf (aref template-level x y 0) +terrain-floor-stone+))) (loop for level in (list level-template-z-0 level-template-z-1 level-template-z-2 level-template-z-3) for z from 0 to 3 do (loop for y from 0 below (length level) do (loop for c across (nth y level) for x from 0 for tt = (case c (#\. +terrain-floor-stone+) (#\, +terrain-floor-grass+) (#\# +terrain-wall-stone+) (#\- +terrain-wall-window+) (#\+ +terrain-door-closed+) (#\b +terrain-floor-bed+) (#\' +terrain-door-open+) (#\Space +terrain-floor-air+) (#\u +terrain-slope-stone-up+) (#\d +terrain-slope-stone-down+) (#\T +terrain-tree-birch+) (#\| +terrain-wall-lantern+) (#\_ +terrain-water-liquid+)) when tt do (setf (aref template-level (1+ x) (1+ y) z) tt) ))) (values template-level feature-list nil nil) )) (defun test-level-place-mobs (world) (push +game-event-lose-game-died+ (game-events (level world))) (set-terrain-* (level world) 47 19 1 +terrain-floor-creep-irradiated+) (set-terrain-* (level world) 48 19 1 +terrain-floor-creep+) (set-terrain-* (level world) 49 19 1 +terrain-floor-creep-bright+) (setf *player* (make-instance 'player :mob-type +mob-type-imp+ :x 47 :y 18 :z 1)) (add-mob-to-level-list (level world) *player*) (let (;(soldier (make-instance 'mob :mob-type +mob-type-satanist+ :x 49 :y 20 :z 1)) (demon (make-instance 'mob :mob-type +mob-type-imp+ :x 45 :y 15 :z 1)) ;(angel (make-instance 'mob :mob-type +mob-type-man+ :x 46 :y 16 :z 1)) ) (setf (cur-fp *player*) 15) ;(setf (max-hp *player*) 50) ;(setf (cur-hp *player*) 50) ;(setf (cur-fp soldier) 10) ;(setf (cur-hp soldier) 1) ; (setf (cur-fp demon) 2) ;(setf (objectives soldier) +objective-demon-attack-defender+) ;(mob-set-mutation *player* +mob-abil-clawed-tentacle+) ;(mob-set-mutation *player* +mob-abil-piercing-needles+) ;(mob-remove-ability *player* +mob-abil-possessable+) ;(mob-set-mutation angel +mob-abil-poisoning-glands+) ;(mob-remove-ability angel +mob-abil-skinchange-to-melee+) ;(mob-remove-ability angel +mob-abil-skinchange-to-ranged+) ;(setf (aref (terrain (level world)) (x *player*) (y *player*) (z *player*)) +terrain-water-ice+) ;(set-mob-effect *player* +mob-effect-divine-shield+ 100) ;(set-mob-effect *player* +mob-effect-called-for-help+ 10) ;(set-mob-effect demon +mob-effect-calling-for-help+ 100) ;(setf (cur-fp soldier) 20) ;(set-mob-effect soldier :effect-type-id +mob-effect-blessed+ :actor-id (id soldier)) ;(add-mob-to-level-list (level world) soldier) (add-mob-to-level-list (level world) demon) ;(add-mob-to-level-list (level world) angel) ;(setf (mimic-id-list *player*) (list (id angel) (id soldier) (id demon))) ;(setf (mimic-id-list soldier) (list (id angel) (id soldier) (id demon))) ;(setf (mimic-id-list demon) (list (id angel) (id soldier) (id demon))) ;(add-mob-to-level-list (level world) (make-instance 'mob :mob-type +mob-type-demon+ :x 35 :y 13 :z 1)) ;(mob-pick-item *player* (make-instance 'item :item-type +item-type-body-part+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0)) ; :spd nil) ;(mob-pick-item *player* (make-instance 'item :item-type +item-type-body-part+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0)) ; :spd nil) ;(mob-pick-item demon (make-instance 'item :item-type +item-type-coin+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 5) :spd nil :silent t) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-coin+ :x (+ (x *player*) 1) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 105)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-bomb+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-bomb+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-flesh+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-invite+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-decay+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-transform+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-all+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-barrier+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-scroll-demonic-rune-away+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) (add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-body-part-full+ :x (+ (x *player*) 1) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-body-part-full+ :x (+ (x angel) 1) :y (+ (y angel) 0) :z (+ (z angel) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-body-part-half+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-clothing+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-disguise+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-disguise+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-deck-of-war+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-deck-of-escape+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-eater-parasite+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-signal-flare+ :x (+ (x *player*) 0) :y (+ (y *player*) 0) :z (+ (z *player*) 0) :qty 3)) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-fire+ :x (+ (x *player*) 1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-smoke-thin+ :x (+ (x *player*) -1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-smoke-thin+ :x (+ (x *player*) -1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-smoke-thin+ :x (+ (x *player*) -1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-smoke-thin+ :x (+ (x *player*) -1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) ;(add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-smoke-thin+ :x (+ (x *player*) -1) :y (+ (y *player*) 0) :z (+ (z *player*) 0))) (add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-demonic-portal+ :x (+ (x *player*) 3) :y (+ (y *player*) 2) :z (+ (z *player*) 0))) (add-feature-to-level-list (level world) (make-instance 'feature :feature-type +feature-bomb-plant-target+ :x 41 :y 19 :z 1)) ;(add-item-to-level-list (level world) (make-instance 'item :item-type +item-type-coin+ :x (+ (x *player*) 0) :y (+ (y *player*) 1) :z (+ (z *player*) 0) :qty 75)) ;(add-mob-to-level-list (level world) (make-instance 'mob :mob-type +mob-type-imp+ :x 41 :y 18 :z 0)) ;(add-mob-to-level-list (level world) (make-instance 'mob :mob-type +mob-type-reanimated-pwr-1+ :x 41 :y 19 :z 0)) ;(add-mob-to-level-list (level world) (make-instance 'mob :mob-type +mob-type-demon+ :x 35 :y 19 :z 2)) ;(add-mob-to-level-list (level world) (make-instance 'mob :mob-type +mob-type-demon+ :x 40 :y 17 :z 2)) ))
21,448
Common Lisp
.lisp
216
78.199074
191
0.290974
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ba662da14464bf25d9cbeb29869018f1b96568499c2262ad0d2fd47df2b79c5e
2,867
[ -1 ]
2,868
world.lisp
gwathlobal_CotD/src/world.lisp
(in-package :cotd) ;;---------------------- ;; LEVEL ;;---------------------- (defclass level () ((player-game-time :initform 0 :accessor player-game-time) (terrain :initform nil :accessor terrain :type (or simple-array null)) ; of type int, which is a idx of terrain-type (memo :initform nil :accessor memo :type (or simple-array null)) ; of type list containing (idx of glyph, color of glyph, color of background, visibility flag, revealed flag) (mobs :initform nil :accessor mobs :type (or simple-array null)) ; of type fixnum, which is the id of a mob (items :initform nil :accessor items :type (or simple-array null)) ; of type (<item id> ...) (features :initform nil :accessor features :type (or simple-array null)) ; of type (<feature id> ...) (mob-id-list :initarg :mob-id-list :initform (make-list 0) :accessor mob-id-list) (item-id-list :initarg :item-id-list :initform (make-list 0) :accessor item-id-list) (feature-id-list :initarg :feature-id-list :initform (make-list 0) :accessor feature-id-list) (connect-map :initform (make-array '(6) :initial-element nil) :accessor connect-map :type simple-array) ; an array that holds connection maps (which are arrays themselves) for all sizes of mobs, ; note that sizes can only be odd numbers, so some indices of the array will hold nil (aux-connect-map :initform (make-array '(6) :initial-element nil) :accessor aux-connect-map :type simple-array) ; an array that holds hash maps for all sizes of mobs (same as connect-map) ; hash-maps hold connections between different rooms ; (so that opening/closing of doors does not require flood fills) (animation-queue :initform () :accessor animation-queue) (light-map :accessor light-map) (outdoor-light :initform 0 :accessor outdoor-light) (light-sources :initform (make-array '(0) :adjustable t) :accessor light-sources) (wind-dir :initform 5 :initarg :wind-dir :accessor wind-dir) (level-layout :initform 0 :initarg :level-layout :accessor level-layout) (mission-scenario :initform nil :initarg :mission-scenario :accessor mission-scenario) (delayed-arrival-points :initform () :initarg :delayed-arrival-points :accessor delayed-arrival-points) ;; is of type ((x y z) (...) ...) (delayed-demons-arrival-points :initform () :initarg :delayed-demons-arrival-points :accessor delayed-demons-arrival-points) ;; is of type ((x y z) (...) ...) (delayed-angels-arrival-points :initform () :initarg :delayed-angels-arrival-points :accessor delayed-angels-arrival-points) ;; is of type ((x y z) (...) ...) (delayed-military-arrival-points :initform () :initarg :delayed-military-arrival-points :accessor delayed-military-arrival-points) ;; is of type ((x y z) (...) ...) (game-events :initform () :accessor game-events) (demonic-portals :initform () :initarg :demonic-portals :accessor demonic-portals) (relic-id :initform nil :initarg :relic-id :accessor level/relic-id) (book-id :initform nil :initarg :book-id :accessor level/book-id) (demonic-sigils :initform () :initarg :demonic-sigils :accessor demonic-sigils) (demonic-machines :initform () :initarg :demonic-sigils :accessor demonic-machines) (bomb-plant-locations :initform () :initarg :bomb-plant-locations :accessor bomb-plant-locations) (mob-quadrant-map :initform nil :initarg :mob-quadrant-map :accessor mob-quadrant-map) (item-quadrant-map :initform nil :initarg :item-quadrant-map :accessor item-quadrant-map) (light-quadrant-map :initform nil :initarg :light-quadrant-map :accessor light-quadrant-map) (world-sector :initform nil :accessor world-sector) (mission :initform nil :accessor mission) (mission-result :initform nil :accessor level/mission-result :type list) (lost-civilians :initform 0 :accessor lost-civilians) (initial-civilians :initform 0 :accessor initial-civilians) (initial-humans :initform 0 :accessor initial-humans) (initial-demons :initform 0 :accessor initial-demons) (initial-angels :initform 0 :accessor initial-angels) (initial-undead :initform 0 :accessor initial-undead) (total-humans :initform 0 :accessor total-humans) (total-demons :initform 0 :accessor total-demons) (total-angels :initform 0 :accessor total-angels) (total-blessed :initform 0 :accessor total-blessed) (total-undead :initform 0 :accessor total-undead) (total-faction-list :initform (loop for faction across *faction-types* collect 0) :accessor total-faction-list) (turns-for-delayed-angels :initform 220 :accessor turns-for-delayed-angels) (turns-for-delayed-demons :initform 220 :accessor turns-for-delayed-demons) (turns-for-delayed-military :initform 220 :accessor turns-for-delayed-military) (full-message-box :initform (make-message-box) :accessor level/full-message-box :type message-box) (small-message-box :initform (make-message-box) :accessor level/small-message-box :type message-box) (scenario-ended :initform nil :accessor level/scenario-ended :type boolean) )) (defun add-mob-to-level-list (level mob &optional (apply-gravity t)) (when (riding-mob-id mob) (let ((mount (get-mob-by-id (riding-mob-id mob)))) (setf (x mount) (x mob) (y mount) (y mob) (z mount) (z mob)) (add-mob-to-level-list level (get-mob-by-id (riding-mob-id mob)) nil))) (unless (initial-added mob) (setf (initial-added mob) t) (when (mob-ability-p mob +mob-abil-human+) (incf (initial-humans (level *world*)))) (when (mob-ability-p mob +mob-abil-civilian+) (incf (initial-civilians (level *world*)))) (when (mob-ability-p mob +mob-abil-demon+) (incf (initial-demons (level *world*)))) (when (mob-ability-p mob +mob-abil-undead+) (incf (initial-undead (level *world*)))) (when (and (mob-ability-p mob +mob-abil-angel+) (not (mob-ability-p mob +mob-abil-animal+))) (incf (initial-angels (level *world*)))) ) (when (not (find (id mob) (mob-id-list level))) ;; make the player be always the first in the list (if (eq mob *player*) (push (id mob) (mob-id-list level)) (if (mob-id-list level) (push (id mob) (cdr (nthcdr 0 (mob-id-list level)))) (push (id mob) (mob-id-list level))) ) (when (mob-ability-p mob +mob-abil-human+) (incf (total-humans (level *world*)))) (when (mob-ability-p mob +mob-abil-demon+) (incf (total-demons (level *world*)))) (when (mob-ability-p mob +mob-abil-undead+) (incf (total-undead (level *world*)))) (when (and (mob-ability-p mob +mob-abil-angel+) (not (mob-ability-p mob +mob-abil-animal+))) (incf (total-angels (level *world*)))) (incf (nth (loyal-faction mob) (total-faction-list (level *world*))))) (let ((sx) (sy)) (setf sx (- (x mob) (truncate (1- (map-size mob)) 2))) (setf sy (- (y mob) (truncate (1- (map-size mob)) 2))) (loop for nx from sx below (+ sx (map-size mob)) do (loop for ny from sy below (+ sy (map-size mob)) do (setf (aref (mobs level) nx ny (z mob)) (id mob))))) (pushnew (id mob) (aref (mob-quadrant-map level) (truncate (x mob) 10) (truncate (y mob) 10))) (when apply-gravity (let ((final-z (z mob))) (when (setf final-z (apply-gravity mob)) (set-mob-location mob (x mob) (y mob) final-z :apply-gravity t)))) ) (defun remove-mob-from-level-list (level mob) (when (find (id mob) (mob-id-list level)) (when (mob-ability-p mob +mob-abil-human+) (decf (total-humans (level *world*)))) (when (mob-ability-p mob +mob-abil-demon+) (decf (total-demons (level *world*)))) (when (mob-ability-p mob +mob-abil-undead+) (decf (total-undead (level *world*)))) (when (and (mob-ability-p mob +mob-abil-angel+) (not (mob-ability-p mob +mob-abil-animal+))) (decf (total-angels (level *world*)))) (when (mob-ability-p mob +mob-abil-civilian+) (incf (lost-civilians (level *world*)))) (decf (nth (loyal-faction mob) (total-faction-list (level *world*)))) (setf (mob-id-list level) (remove (id mob) (mob-id-list level)))) (let ((sx) (sy)) (setf sx (- (x mob) (truncate (1- (map-size mob)) 2))) (setf sy (- (y mob) (truncate (1- (map-size mob)) 2))) (loop for nx from sx below (+ sx (map-size mob)) do (loop for ny from sy below (+ sy (map-size mob)) do (setf (aref (mobs level) nx ny (z mob)) nil)))) (setf (aref (mob-quadrant-map level) (truncate (x mob) 10) (truncate (y mob) 10)) (remove (id mob) (aref (mob-quadrant-map level) (truncate (x mob) 10) (truncate (y mob) 10)))) (log:info (format nil "REMOVE-MOB-FROM-LEVEL-LIST: ~A [~A] (~A ~A ~A) = ~A~%" (name mob) (id mob) (x mob) (y mob) (z mob) (get-mob-* level (x mob) (y mob) (z mob))))) (defun add-feature-to-level-list (level feature) (if (and (can-merge-func feature) (funcall (can-merge-func feature) level feature) (merge-func feature)) (progn ;;(format t "MERGE: ~A [~A] (~A ~A ~A)~%" (name feature) (id featur e) (x feature) (y feature) (z feature)) (funcall (merge-func feature) level feature)) (progn ;;(format t "~A [~A] (~A ~A ~A)~%" (name feature) (id feature) (x feature) (y feature) (z feature)) (pushnew (id feature) (feature-id-list level)) (push (id feature) (aref (features level) (x feature) (y feature) (z feature))) (when (and (not (get-feature-type-trait feature +feature-trait-no-gravity+)) (apply-gravity feature)) (remove-feature-from-level-list level feature) (setf (z feature) (apply-gravity feature)) (add-feature-to-level-list level feature)))) ) (defun remove-feature-from-level-list (level feature) (setf (feature-id-list level) (remove (id feature) (feature-id-list level))) (setf (aref (features level) (x feature) (y feature) (z feature)) (remove (id feature) (aref (features level) (x feature) (y feature) (z feature))))) (defun add-item-to-level-list (level item) (if (apply-gravity item) (progn (setf (z item) (apply-gravity item)) (setf (aref (items level) (x item) (y item) (z item)) (add-to-inv item (aref (items level) (x item) (y item) (z item)) nil))) (progn (setf (aref (items level) (x item) (y item) (z item)) (add-to-inv item (aref (items level) (x item) (y item) (z item)) nil)))) (when (get-item-by-id (id item)) (pushnew (id item) (item-id-list level)) (push (id item) (aref (item-quadrant-map level) (truncate (x item) 10) (truncate (y item) 10))))) (defun remove-item-from-level-list (level item) (setf (item-id-list level) (remove (id item) (item-id-list level))) (setf (aref (item-quadrant-map level) (truncate (x item) 10) (truncate (y item) 10)) (remove (id item) (aref (item-quadrant-map level) (truncate (x item) 10) (truncate (y item) 10)))) (setf (aref (items level) (x item) (y item) (z item)) (remove-from-inv item (aref (items level) (x item) (y item) (z item)))) item) (defun get-terrain-* (level x y z) (when (or (< x 0) (>= x (array-dimension (terrain level) 0)) (< y 0) (>= y (array-dimension (terrain level) 1)) (< z 0) (>= z (array-dimension (terrain level) 2))) (return-from get-terrain-* nil)) (aref (terrain level) x y z)) (defun set-terrain-* (level x y z terrain-type-id) (setf (aref (terrain level) x y z) terrain-type-id)) (defun get-features-* (level x y z) (when (or (< x 0) (>= x (array-dimension (items level) 0)) (< y 0) (>= y (array-dimension (items level) 1)) (< z 0) (>= z (array-dimension (items level) 2))) (return-from get-features-* nil)) (aref (features level) x y z)) (defun get-mob-* (level x y z) (when (or (< x 0) (>= x (array-dimension (mobs level) 0)) (< y 0) (>= y (array-dimension (mobs level) 1)) (< z 0) (>= z (array-dimension (mobs level) 2))) (return-from get-mob-* nil)) (if (aref (mobs level) x y z) (get-mob-by-id (aref (mobs level) x y z)) nil)) (defun get-items-* (level x y z) (when (or (< x 0) (>= x (array-dimension (items level) 0)) (< y 0) (>= y (array-dimension (items level) 1)) (< z 0) (>= z (array-dimension (items level) 2))) (return-from get-items-* nil)) (aref (items level) x y z)) (defun get-memo-* (level x y z) (aref (memo level) x y z)) (defun set-memo-* (level x y z single-memo) (setf (aref (memo level) x y z) single-memo)) (defun create-single-memo (glyph-idx glyph-color back-color visibility revealed light player) (make-array (list 7) :initial-contents (list glyph-idx glyph-color back-color visibility revealed light player)) ;(list glyph-idx glyph-color back-color visibility revealed light) ) (defun get-single-memo-glyph-idx (single-memo) ;(nth 0 single-memo) (aref single-memo 0)) (defun get-single-memo-glyph-color (single-memo) ;(nth 1 single-memo) (aref single-memo 1)) (defun get-single-memo-back-color (single-memo) ;(nth 2 single-memo) (aref single-memo 2)) (defun get-single-memo-visibility (single-memo) ;(nth 3 single-memo) (aref single-memo 3)) (defun get-single-memo-revealed (single-memo) ;(nth 4 single-memo) (aref single-memo 4)) (defun get-single-memo-light (single-memo) ;(nth 5 single-memo) (aref single-memo 5)) (defun get-single-memo-player (single-memo) ;(nth 5 single-memo) (aref single-memo 6)) (defun set-single-memo-* (level x y z &key (glyph-idx (get-single-memo-glyph-idx (get-memo-* level x y z))) (glyph-color (get-single-memo-glyph-color (get-memo-* level x y z))) (back-color (get-single-memo-back-color (get-memo-* level x y z))) (visibility (get-single-memo-visibility (get-memo-* level x y z))) (revealed (get-single-memo-revealed (get-memo-* level x y z))) (light (get-single-memo-light (get-memo-* level x y z))) (player (get-single-memo-player (get-memo-* level x y z)))) ;(set-memo-* level x y z (create-single-memo glyph-idx glyph-color back-color visibility revealed light)) (let ((single-memo (get-memo-* level x y z))) (setf (aref single-memo 0) glyph-idx) (setf (aref single-memo 1) glyph-color) (setf (aref single-memo 2) back-color) (setf (aref single-memo 3) visibility) (setf (aref single-memo 4) revealed) (setf (aref single-memo 5) light) (setf (aref single-memo 6) player))) (defun get-connect-map-value (connect-map x y z move-mode) (let ((move-mode-array (aref connect-map x y z))) ;(format t "GET ~A, MOVE-MODE ~A, LENGTH ~A~%" move-mode-array move-mode (length move-mode-array)) (unless move-mode-array (return-from get-connect-map-value -1)) (when (>= move-mode (length move-mode-array)) (return-from get-connect-map-value -1)) (unless (aref move-mode-array move-mode) (return-from get-connect-map-value -1)) (aref move-mode-array move-mode) )) (defun get-level-connect-map-value (level x y z map-size move-mode) (when (or (zerop map-size) (evenp map-size)) (error "GET-CONNECT-MAP-SIZE: Map size should be an odd number")) (let ((move-mode-array (aref (aref (connect-map level) map-size) x y z))) (unless move-mode-array (return-from get-level-connect-map-value -1)) (when (>= move-mode (length move-mode-array)) (return-from get-level-connect-map-value -1)) (unless (aref move-mode-array move-mode) (return-from get-level-connect-map-value -1)) (aref move-mode-array move-mode) )) (defun set-connect-map-value (connect-map x y z move-mode value) ;; we assume that the connect map arrays have been created (unless (aref connect-map x y z) (setf (aref connect-map x y z) (make-array (list (1+ move-mode)) :initial-element -1 :adjustable t))) (let ((move-mode-array (aref connect-map x y z))) (when (>= move-mode (length move-mode-array)) (adjust-array move-mode-array (list (1+ move-mode)))) ;(format t "SET ~A, MOVE-MODE ~A, LENGTH ~A~%" move-mode-array move-mode (length move-mode-array)) (setf (aref move-mode-array move-mode) value) ) ) (defun level-cells-connected-p (level sx sy sz tx ty tz map-size move-mode &key (can-open-doors t)) (when (or (< sx 0) (< sy 0) (< sz 0) (>= sx (array-dimension (terrain level) 0)) (>= sy (array-dimension (terrain level) 1)) (>= sz (array-dimension (terrain level) 2)) (< tx 0) (< ty 0) (< tz 0) (>= tx (array-dimension (terrain level) 0)) (>= ty (array-dimension (terrain level) 1)) (>= tz (array-dimension (terrain level) 2))) (return-from level-cells-connected-p nil)) (let ((connect-map-value-start (get-level-connect-map-value level sx sy sz map-size move-mode)) (connect-map-value-end (get-level-connect-map-value level tx ty tz map-size move-mode))) (if (or (= connect-map-value-start connect-map-value-end) (level-aux-map-connect-p level connect-map-value-start connect-map-value-end map-size move-mode :can-open-doors can-open-doors)) t nil)) ) (defun level-aux-map-connect-p (level room-id-start room-id-end map-size move-mode &key (can-open-doors t)) (unless (aref (aux-connect-map level) map-size) (return-from level-aux-map-connect-p nil)) (unless (aref (aref (aux-connect-map level) map-size) move-mode) (return-from level-aux-map-connect-p nil)) (let ((connect-list (aref (aref (aux-connect-map level) map-size) move-mode)) (connection nil)) (setf connection (find-if #'(lambda (a) (if (or (and (= (first a) room-id-start) (= (second a) room-id-end)) (and (= (first a) room-id-end) (= (second a) room-id-start))) t nil)) connect-list)) (when (and connection (or can-open-doors (and (not can-open-doors) (plusp (get-aux-map-connection-actual connection))))) (return-from level-aux-map-connect-p t)) ;; if no direct connection found - try to find connected rooms through intermediate connections (if (and (find-if #'(lambda (a) (if (or (= (first a) room-id-start) (= (second a) room-id-start)) t nil)) connect-list) (find-if #'(lambda (a) (if (or (= (first a) room-id-end) (= (second a) room-id-end)) t nil)) connect-list)) (progn (let ((open-nodes ()) (closed-nodes ())) (push room-id-start open-nodes) (loop for node = (first open-nodes) while (and node (/= node room-id-end)) do (pop open-nodes) (loop for (start end potential actual) in connect-list for is-closed = (or (find start closed-nodes) (find end closed-nodes)) when (and (= start node) (not is-closed) (or can-open-doors (and (not can-open-doors) (plusp actual)))) do (push end open-nodes) when (and (= end node) (not is-closed) (or can-open-doors (and (not can-open-doors) (plusp actual)))) do (push start open-nodes)) (push node closed-nodes) ) (if open-nodes t nil))) nil))) (defun get-aux-map-connection-potential (connection) (third connection)) (defun get-aux-map-connection-actual (connection) (fourth connection)) (defun set-aux-map-connection (level room-id-start room-id-end map-size move-mode &key (delta-potential 1) (delta-actual 1)) (unless (aref (aux-connect-map level) map-size) (setf (aref (aux-connect-map level) map-size) (make-array (list (1+ move-mode)) :initial-element nil :adjustable t))) (when (>= move-mode (length (aref (aux-connect-map level) map-size))) (adjust-array (aref (aux-connect-map level) map-size) (list (1+ move-mode)) :initial-element nil)) (let* ((connect-list (aref (aref (aux-connect-map level) map-size) move-mode)) (connection (find-if #'(lambda (a) (if (or (and (= (first a) room-id-start) (= (second a) room-id-end)) (and (= (first a) room-id-end) (= (second a) room-id-start))) t nil)) connect-list))) ;; connection is (<room-id-start> <room-id-end> <number of potential links between rooms> <number of actual links between rooms>) (if connection (progn (incf (third connection) delta-potential) (incf (fourth connection) delta-actual) (when (minusp (third connection)) (setf (third connection) 0)) (when (minusp (fourth connection)) (setf (fourth connection) 0)) (when (zerop (third connection)) (setf (aref (aref (aux-connect-map level) map-size) move-mode) (remove connection connect-list)))) (progn (when (and (plusp delta-potential) (or (plusp delta-actual) (zerop delta-actual))) (push (list room-id-start room-id-end delta-potential delta-actual) (aref (aref (aux-connect-map level) map-size) move-mode))))) )) (defun get-outdoor-light-* (level x y z) ;(format t "GET-OUTDOOR-LIGHT: ~A ~A ~A ~A" level x y z) (truncate (* (outdoor-light level) (aref (light-map level) x y z)) 100)) (defun make-light-source (x y z light-radius) (list x y z light-radius)) (defun add-light-source (level light-source) (adjust-array (light-sources level) (list (1+ (length (light-sources level))))) (setf (aref (light-sources level) (1- (length (light-sources level)))) light-source) (push light-source (aref (light-quadrant-map level) (truncate (first light-source) 10) (truncate (second light-source) 10)))) (defun return-weather-type-str (level) (let ((str (create-string))) (format str "~A" (cond ((find +game-event-snow-falls+ (game-events level)) "Snow") ((find +game-event-rain-falls+ (game-events level)) "Rain") (t "Clear"))) (when (find +game-event-unnatural-darkness+ (game-events level)) (format str ", Darkness")) str)) ;;---------------------- ;; WORLD ;;---------------------- (defclass world () ((world-game-time :initform 0 :accessor world-game-time) (turn-finished :initform nil :accessor turn-finished) (level :initform nil :accessor level :type (or level null)) (game-events :initform () :accessor game-events) (cur-mob-path :initform 0 :accessor cur-mob-path) (path-lock :initform (bt:make-lock) :accessor path-lock) (path-cv :initform (bt:make-condition-variable) :accessor path-cv) (world-map :initform nil :accessor world-map) (player-specific-faction :initform nil :accessor world/player-specific-faction) (present-missions :initform () :accessor world/present-missions) (mission-message-box :initform (make-message-box) :accessor world/mission-message-box :type message-box) (event-message-box :initform (make-message-box) :accessor world/event-message-box :type message-box) (effect-message-box :initform (make-message-box) :accessor world/effect-message-box :type message-box) (flesh-points :initform 0 :accessor world/flesh-points :type fixnum) (machine-destroyed :initform 0 :accessor world/machine-destroyed :type fixnum) (cur-military-num :initform 0 :accessor world/cur-military-num :type fixnum) (cur-demons-num :initform 0 :accessor world/cur-demons-num :type fixnum) (post-mission-results :initform () :accessor world/post-mission-results :type list) (demons-mission-limit :initform 0 :accessor world/demons-mission-limit :type fixnum) (military-mission-limit :initform 0 :accessor world/military-mission-limit :type fixnum) (angels-mission-limit :initform 0 :accessor world/angels-mission-limit :type fixnum) (missions-by-slot-type :initform () :accessor world/missions-by-slot-type :type plist) ;; mission-ids arranged into a plist by the mission-slot-type (campaign-effects :initform () :accessor world/campaign-effects :type list) (commands :initform (make-hash-table) :accessor world/commands) ;; keys are faction-type, value is (:command <command id> :cd <cd>) (random-number :initform (random 100) :accessor world/random-number) )) (defmethod initialize-instance :after ((world world) &key) (with-slots (demon-missions-city military-missions-city angel-missions-city military-missions-offworld angel-missions-offworld) world (loop for mission-type being the hash-values in *mission-types* when (enabled mission-type) do (unless (getf (world/missions-by-slot-type world) (mission-slot-type mission-type)) (setf (getf (world/missions-by-slot-type world) (mission-slot-type mission-type)) ())) (push (id mission-type) (getf (world/missions-by-slot-type world) (mission-slot-type mission-type)))) )) ;;---------------------- ;; DATE ;;---------------------- (defun get-current-date-time (date-time) (let ((year 0) (month 0) (day 0) (hour 0) (min 0) (sec 0)) (multiple-value-setq (year month) (truncate (* date-time 6) (* 12 30 24 60 60))) (multiple-value-setq (month day) (truncate month (* 30 24 60 60))) (multiple-value-setq (day hour) (truncate day (* 24 60 60))) (multiple-value-setq (hour min) (truncate hour (* 60 60))) (multiple-value-setq (min sec) (truncate min 60)) (values year month day hour min sec))) (defun set-current-date-time (year month day hour min sec) (let ((date-time 0)) (incf date-time (truncate (* year 12 30 24 60 60) 6)) (incf date-time (truncate (* month 30 24 60 60) 6)) (incf date-time (truncate (* day 24 60 60) 6)) (incf date-time (truncate (* hour 60 60) 6)) (incf date-time (truncate (* min 60) 6)) (incf date-time (truncate sec 6)) date-time)) (defun show-date-time-short (date-time) (multiple-value-bind (year month day hour min sec) (get-current-date-time date-time) (format nil "~2,'0d ~A ~4,'0d ~2,'0d:~2,'0d:~2,'0d" (1+ day) (cond ((= month 0) "Jan") ((= month 1) "Feb") ((= month 2) "Mar") ((= month 3) "Apr") ((= month 4) "May") ((= month 5) "Jun") ((= month 6) "Jul") ((= month 7) "Aug") ((= month 8) "Sep") ((= month 9) "Oct") ((= month 10) "Nov") ((= month 11) "Dec") ) year hour min sec))) (defun show-date-time-YMD (date-time) (multiple-value-bind (year month day hour min sec) (get-current-date-time date-time) (declare (ignore hour min sec)) (format nil "~2,'0d ~A ~4,'0d" (1+ day) (cond ((= month 0) "Jan") ((= month 1) "Feb") ((= month 2) "Mar") ((= month 3) "Apr") ((= month 4) "May") ((= month 5) "Jun") ((= month 6) "Jul") ((= month 7) "Aug") ((= month 8) "Sep") ((= month 9) "Oct") ((= month 10) "Nov") ((= month 11) "Dec") ) year)))
29,140
Common Lisp
.lisp
501
47.714571
198
0.599732
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
fb696f50e3304e9ec90faf0757f0e3ba7ab69e40ce48fd3c599cd7304c244f0c
2,868
[ -1 ]
2,869
init-win-conditions.lisp
gwathlobal_CotD/src/init-win-conditions.lisp
(in-package :cotd) (set-win-condition :id :win-cond-demonic-attack :win-formula 60 :win-func #'(lambda (world win-condition) (- (truncate (* (initial-civilians (level world)) (/ (win-condition/win-formula win-condition) 100))) (lost-civilians (level world)))) ) (set-win-condition :id :win-cond-demonic-raid :win-formula 300 :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-thief :win-formula 1500 :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-demonic-conquest :win-formula (list 4 100) :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-military-conquest :win-formula 4 :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-celestial-sabotage :win-formula 4 :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-military-sabotage :win-formula 0 :win-func #'(lambda (world win-condition) (declare (ignore world win-condition)) ;; do not do anything nil) ) (set-win-condition :id :win-cond-demon-campaign :win-formula 2000 :win-func #'(lambda (world win-condition) (declare (ignore win-condition)) (let ((cells (cells (world-map world))) (world-sector nil) (normal-sum 0)) (loop for x from 0 below (array-dimension cells 0) do (loop for y from 0 below (array-dimension cells 1) do (setf world-sector (aref cells x y)) (when (world-sector-normal-p world-sector) (incf normal-sum)))) normal-sum) ) ) (set-win-condition :id :win-cond-military-campaign :win-formula 0 :win-func #'(lambda (world win-condition) (declare (ignore win-condition)) (let ((cells (cells (world-map world))) (world-sector nil) (corrupted-sum 0) (satanists-num 0)) (loop for x from 0 below (array-dimension cells 0) do (loop for y from 0 below (array-dimension cells 1) do (setf world-sector (aref cells x y)) (when (world-sector-corrupted-p world-sector) (incf corrupted-sum)) (when (find +lm-feat-lair+ (feats world-sector) :key #'(lambda (a) (first a))) (incf satanists-num)))) (values corrupted-sum satanists-num)) ) ) (set-win-condition :id :win-cond-angels-campaign :win-formula 4 :win-func #'(lambda (world win-condition) (- (win-condition/win-formula win-condition) (world/machine-destroyed world))) ) (set-win-condition :id :win-cond-eater-cosnume :win-formula 0 :win-func #'(lambda (world win-condition) (declare (ignore win-condition)) (truncate (+ (initial-angels (level world)) (initial-humans (level world)) (initial-demons (level world))) 3)))
5,230
Common Lisp
.lisp
95
28.357895
134
0.393833
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e8df8d08479538b54f14d8d8ed6a07ae03613d207b6893c968a11a58f36b45c5
2,869
[ -1 ]
2,870
hearing.lisp
gwathlobal_CotD/src/hearing.lisp
(in-package :cotd) (defstruct sound (x -1) (y -1) (z -1)) (defun general-direction-dir (sx sy tx ty) (let ((a (round (* (atan (- sy ty) (- sx tx)) (/ 180 pi)))) (result 0)) (when (and (= sx tx) (= sy ty)) (return-from general-direction-dir 0)) (cond ((and (> a 22.5) (<= a 67.5)) (setf result 7)) ((and (> a 67.5) (<= a 112.5)) (setf result 8)) ((and (> a 112.5) (<= a 157.5)) (setf result 9)) ((and (< a -22.5) (>= a -67.5)) (setf result 1)) ((and (< a -67.5) (>= a -112.5)) (setf result 2)) ((and (< a -112.5) (>= a -157.5)) (setf result 3)) ((or (> a 157.5) (< a -157.5)) (setf result 6)) ((or (> a -22.5) (<= a 22.5)) (setf result 4))) result)) (defun propagate-sound-from-location (target sx sy sz sound-power sound-str-func &key (force-sound nil) (source nil)) (log:info "ENTERING PROPAGATE ~A [~A]" (name target) (id target)) (let ((sound-pwr sound-power)) (line-of-sight sx sy sz (x target) (y target) (z target) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t)) (block nil (let ((pwr-decrease 0) (trait) (x) (y) (z)) (cond ((null prev-cell) (progn (setf trait +terrain-trait-blocks-sound+) (setf x dx y dy z dz))) ((> (- dz (third prev-cell)) 0) (progn (setf trait +terrain-trait-blocks-sound-floor+) (setf x dx y dy z dz))) ((< (- dz (third prev-cell)) 0) (progn (setf trait +terrain-trait-blocks-sound-floor+) (setf x (first prev-cell) y (second prev-cell) z (third prev-cell)))) (t (progn (setf trait +terrain-trait-blocks-sound+) (setf x dx y dy z dz)))) (cond ((eq (get-terrain-type-trait (get-terrain-* (level *world*) x y z) trait) t) (progn (setf pwr-decrease 100) (decf sound-pwr (truncate (* sound-power pwr-decrease) 100)))) ((eq (get-terrain-type-trait (get-terrain-* (level *world*) x y z) trait) nil) (progn (decf sound-pwr *sound-power-falloff*))) (t (progn (setf pwr-decrease (get-terrain-type-trait (get-terrain-* (level *world*) x y z) trait)) (decf sound-pwr (truncate (* sound-power pwr-decrease) 100))))) ;(format t "TRAIT ~A, (~A ~A ~A) ~A, PWR-DECREASE ~A, SOUND-PWR ~A~%" trait x y z prev-cell pwr-decrease sound-pwr) ) (when (<= sound-pwr 0) (setf sound-pwr 0) (setf exit-result 'exit) (return)) ) exit-result))) (log:info "Initial sound power ~A, final sound power ~A, Source ~A [~A] (~A ~A ~A), Target ~A [~A] (~A ~A ~A), Sound string ~A" sound-power sound-pwr (if source (name source) nil) (if source (id source) nil) sx sy sz (name target) (id target) (x target) (y target) (z target) (funcall sound-str-func "")) (when (not (zerop sound-pwr)) (let ((sound-z (cond ((> sz (z target)) 1) ((< sz (z target)) -1) (t 0))) (sound-dir) (nx sx) (ny sy) (nz sz) (dir-str)) (when (and (> sound-pwr 10) (or force-sound (null source) (and source (or (and (not (eq target *player*)) (not (check-mob-visible source :observer target :complete-check t))) (and (eq target *player*) (not (get-single-memo-visibility (get-memo-* (level *world*) sx sy sz)))) (and (eq target *player*) (get-single-memo-visibility (get-memo-* (level *world*) sx sy sz)) (not (check-mob-visible source :observer target :complete-check nil))))))) (when (< sound-pwr 30) (setf nx (+ sx 2 (* -1 (random 5)))) (when (< nx 0) (setf nx 0)) (when (>= nx (array-dimension (terrain (level *world*)) 0)) (setf nx (1- (array-dimension (terrain (level *world*)) 0)))) (setf ny (+ sy 2 (* -1 (random 5)))) (when (< ny 0) (setf ny 0)) (when (>= ny (array-dimension (terrain (level *world*)) 1)) (setf ny (1- (array-dimension (terrain (level *world*)) 1))))) (push (make-sound :x nx :y ny :z nz) (heard-sounds target)) (setf sound-dir (general-direction-dir (x target) (y target) nx ny)) (when (eq target *player*) (setf dir-str (format nil "~A~A~A" (cond ((< (get-distance-3d sx sy sz (x target) (y target) (z target)) 3) " nearby") ((> (get-distance-3d sx sy sz (x target) (y target) (z target)) 8) " in the distance") (t "")) (cond ((= sound-dir 1) " to the southwest") ((= sound-dir 2) " to the south") ((= sound-dir 3) " to the southeast") ((= sound-dir 4) " to the west") ((= sound-dir 6) " to the east") ((= sound-dir 7) " to the northwest") ((= sound-dir 8) " to the north") ((= sound-dir 9) " to the northeast") (t "")) (cond ((= sound-z 1) " above") ((= sound-z -1) " below") (t "")))) (print-visible-message (x target) (y target) (z target) (level *world*) (funcall sound-str-func dir-str) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ))))) (log:info "LEAVING PROPAGATE"))
7,276
Common Lisp
.lisp
120
36.191667
177
0.394322
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
7ac985945d0b1e7606e51bb043212853b896b757c2a6bcde887b5c4d219da6e7
2,870
[ -1 ]
2,871
init-campaign-effect-types.lisp
gwathlobal_CotD/src/init-campaign-effect-types.lisp
(in-package :cotd) (set-campaign-effect-type :id :campaign-effect-satanist-lair-visible :name "Satanits' lair revealed" :descr "The satanist lair is infiltrated and vulnerable to attack." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The agents of the powers that be have ") sdl:*white* message-box-list) (add-message (format nil "inflitrated the satanists") sdl:*yellow* message-box-list) (add-message (format nil " and made their lair vulnerable for attack.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The satanists managed to ") sdl:*white* message-box-list) (add-message (format nil "expose the agents") sdl:*yellow* message-box-list) (add-message (format nil " who have infiltrated them and are now able lay low.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-satanist-sacrifice :name "Citizen sacrificed" :descr "The satanists have sacrificed a citizen of the City and opened the gates of Hell giving demons more opportunities to invade Earth." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The satanists have made a ") sdl:*white* message-box-list) (add-message (format nil "blood sacrifice") sdl:*yellow* message-box-list) (add-message (format nil " and opened the gates of Hell wider giving demons more opportunities to invade Earth.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The ") sdl:*white* message-box-list) (add-message (format nil "crack of between worlds has closed") sdl:*yellow* message-box-list) (add-message (format nil " and the forces of Hell now have less opportunities to invade Earth.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-satanist-lair-hidden :name "Satanits' lair hidden" :descr "The satanists have taken great precautions to make the lair hidden and secure." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The satanists ") sdl:*white* message-box-list) (add-message (format nil "have hidden their lair") sdl:*yellow* message-box-list) (add-message (format nil " to make it impossible to find them.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The satanists ") sdl:*white* message-box-list) (add-message (format nil "have relaxed their security") sdl:*yellow* message-box-list) (add-message (format nil " and it is now possible to infiltrate it.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-protect-dimension :name "Protect Prison Dimension" :descr "The demons have invoked obscure rites from the Book of Rituals to prevent anybody from entering their dimension. The enchantment lasts as long as the demons control the Book of Rituals." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The demons ") sdl:*white* message-box-list) (add-message (format nil "have protected their dimension") sdl:*yellow* message-box-list) (add-message (format nil " against entrance.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The ") sdl:*white* message-box-list) (add-message (format nil "Prison Dimension") sdl:*yellow* message-box-list) (add-message (format nil " is now available for ") sdl:*white* message-box-list) (add-message (format nil "entry") sdl:*yellow* message-box-list) (add-message (format nil " again.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-corrupt-portals :name "Divine portals corrupted" :descr "The demons have invoked obscure rites on the Holy Relic to corrupt the divine portals. Whenever angels are not initiating a mission, they arrive delayed. The enchantment lasts as long as the demons control the Holy Relic." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The demons have ") sdl:*white* message-box-list) (add-message (format nil "corrupted divine portals") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "Divine portals") sdl:*yellow* message-box-list) (add-message (format nil " are ") sdl:*white* message-box-list) (add-message (format nil "no longer corrupted") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-turmoil :name "Turmoil in Hell" :descr "A recent successful strike inside the demonic realm has caused turmoil in Hell. The demons are not able to raise armies until order is restored." :merge-func #'(lambda (world new-effect old-effect) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect))) :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The demonic hierarchy ") sdl:*white* message-box-list) (add-message (format nil "has been disrupted") sdl:*yellow* message-box-list) (add-message (format nil ". Demons shall ") sdl:*white* message-box-list) (add-message (format nil "not be able to raise armies") sdl:*yellow* message-box-list) (add-message (format nil " for a while.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The demonic hierarchy ") sdl:*white* message-box-list) (add-message (format nil "has been restored") sdl:*yellow* message-box-list) (add-message (format nil ". Demons are ") sdl:*white* message-box-list) (add-message (format nil "able to raise armies") sdl:*yellow* message-box-list) (add-message (format nil " once again.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-delayed :name "The Barrier thickens" :descr "The Barrier between the Prison Dimension and human world thickens. When the demons arrive delayed, it takes them additional 30 turns to arrive." :merge-func #'(lambda (world new-effect old-effect) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect))) :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The priests have prayed ") sdl:*white* message-box-list) (add-message (format nil "to thicken the Barrier") sdl:*yellow* message-box-list) (add-message (format nil " between the worlds.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The effects of the prayer are over. The ") sdl:*white* message-box-list) (add-message (format nil "Barrier") sdl:*yellow* message-box-list) (add-message (format nil " can be ") sdl:*white* message-box-list) (add-message (format nil "pierced") sdl:*yellow* message-box-list) (add-message (format nil " normally again.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-malseraph-blessing :name "Malseraph's blessing" :descr "Malseraph has focused its attention on the events at the city. From time to time it will give demons on the battlefield a modicum of power." :merge-func #'(lambda (world new-effect old-effect) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect))) :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "Malseraph") sdl:*magenta* message-box-list) (add-message (format nil " turned its gaze to the city and ") sdl:*white* message-box-list) (add-message (format nil "granted its blessing") sdl:*white* message-box-list) (add-message (format nil " to the invading demons.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (add-campaign-effect world :id :campaign-effect-demon-malseraph-bored :cd (+ 2 (random 2))) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "Malseraph") sdl:*magenta* message-box-list) (add-message (format nil " has diverted its gaze from the city. Demons fighting there ") sdl:*white* message-box-list) (add-message (format nil "shall no longer have its blessing") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-demon-malseraph-bored :name "Malseraph bored" :descr "Malseraph is bored for a while." :displayed nil :merge-func #'(lambda (world new-effect old-effect) (declare (ignore world)) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)))) (set-campaign-effect-type :id :campaign-effect-angel-hastened :name "Prayer for intervention" :descr "When the angels arrive delayed, it takes them 30 turns less to arrive." :merge-func #'(lambda (world new-effect old-effect) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect))) :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The priests have prayed ") sdl:*white* message-box-list) (add-message (format nil "for divine intervention") sdl:*yellow* message-box-list) (add-message (format nil " and their prayers were answered.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The effects of the prayer are over. The ") sdl:*white* message-box-list) (add-message (format nil "angels") sdl:*yellow* message-box-list) (add-message (format nil " shall ") sdl:*white* message-box-list) (add-message (format nil "arrive as usual") sdl:*yellow* message-box-list) (add-message (format nil " from this time on.~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-eater-agitated :name "Primordials agitated" :descr "The Primordials are awakening from their slumber. Whenever eaters of the dead are present in a mission, they are present en mass." :merge-func #'(lambda (world new-effect old-effect) (setf (campaign-effect/cd old-effect) (campaign-effect/cd new-effect)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect))) :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The ") sdl:*white* message-box-list) (add-message (format nil "primordials") sdl:*yellow* message-box-list) (add-message (format nil " are ") sdl:*white* message-box-list) (add-message (format nil "awakening") sdl:*yellow* message-box-list) (add-message (format nil " from their slumber.~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The ") sdl:*white* message-box-list) (add-message (format nil "primordials") sdl:*yellow* message-box-list) (add-message (format nil " are falling into ") sdl:*white* message-box-list) (add-message (format nil "a sleep") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list)))) (set-campaign-effect-type :id :campaign-effect-angel-crusade :name "Divine crusade" :descr "The angels have declared a divine crusade and are able to initiate 1 more mission for the duration of this effect." :merge-func nil :on-add-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "The angels have ") sdl:*white* message-box-list) (add-message (format nil "declared divine crusade") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))) :on-remove-func #'(lambda (world campaign-effect) (declare (ignore campaign-effect)) (let ((message-box-list `(,(world/effect-message-box world)))) (add-message (format nil "Divine crusade") sdl:*yellow* message-box-list) (add-message (format nil " has ") sdl:*white* message-box-list) (add-message (format nil "ended") sdl:*yellow* message-box-list) (add-message (format nil ".~%") sdl:*white* message-box-list))))
22,387
Common Lisp
.lisp
218
64.114679
256
0.472131
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
54e92d5248776618da296c5b4ebdd13a2a5242c8c6ba43abe760d66d10392de7
2,871
[ -1 ]
2,872
animations.lisp
gwathlobal_CotD/src/animations.lisp
(in-package :cotd) (defconstant +anim-type-fire-dot+ 0) (defconstant +anim-type-severed-body-part+ 1) (defconstant +anim-type-rain-dot+ 2) (defconstant +anim-type-acid-dot+ 3) (defparameter *animation-types* (make-array (list 0) :adjustable t)) (defstruct (animation-type (:conc-name anim-type-)) (id) (func)) (defun set-anim-type (animation-type) (when (>= (anim-type-id animation-type) (length *animation-types*)) (adjust-array *animation-types* (list (1+ (anim-type-id animation-type))))) (setf (aref *animation-types* (anim-type-id animation-type)) animation-type)) (defun get-anim-type (animation-type-id) (aref *animation-types* animation-type-id)) (defstruct (animation (:conc-name anim-)) (id) (x) (y) (z) (params)) (defun play-animation (animation) (funcall (anim-type-func (get-anim-type (anim-id animation))) animation))
867
Common Lisp
.lisp
23
35.173913
79
0.71497
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
42449bfa5eb9a8fefc9583943474c03241b628927a4d1d7b9e7356612025383e
2,872
[ -1 ]
2,873
world-map.lisp
gwathlobal_CotD/src/world-map.lisp
(in-package :cotd) (defparameter *max-x-world-map* 5) (defparameter *max-y-world-map* 5) (defclass world-map () ((cells :initform nil :accessor cells :type (or simple-array null)) ;; array of world-sector (random-state :initform (make-random-state t) :accessor world-map/random-state) )) (defun generate-empty-world-map (world-map) (setf (cells world-map) (make-array (list *max-x-world-map* *max-y-world-map*) :element-type '(or world-sector null) :initial-element nil)) (loop for x from 0 below *max-x-world-map* do (loop for y from 0 below *max-y-world-map* do (setf (aref (cells world-map) x y) (make-instance 'world-sector :wtype :world-sector-normal-residential :x x :y y)))) world-map) (defun place-satanist-lair-on-map (world-map lair-num) (loop repeat lair-num do (loop for x = (random (array-dimension (cells world-map) 0)) for y = (random (array-dimension (cells world-map) 1)) for world-sector = (aref (cells world-map) x y) while (or (eq (wtype world-sector) :world-sector-normal-sea) (find +lm-feat-lair+ (feats world-sector) :key #'(lambda (a) (first a)))) finally (push (list +lm-feat-lair+ nil) (feats world-sector))))) (defun generate-normal-world-map (world) (with-slots (world-map) world (setf world-map (make-instance 'world-map)) (setf (cells world-map) (make-array (list *max-x-world-map* *max-y-world-map*) :element-type '(or world-sector null) :initial-element nil)) ;; create a template map of world sector types (let ((template-map (make-array (list *max-x-world-map* *max-y-world-map*) :initial-element :world-sector-normal-residential))) ;; determine if sea should be placed (when (zerop (random 2)) ;; determine which side should have the sea (let* ((sides '(:n :s :w :e)) (chosen-side (nth (random (length sides)) sides))) (case chosen-side (:n (loop with y = 0 with y1 = 1 for x from 0 below (array-dimension template-map 0) do (setf (aref template-map x y) :world-sector-normal-sea) (setf (aref template-map x y1) :world-sector-normal-port))) (:s (loop with y = (1- (array-dimension template-map 1)) with y1 = (- (array-dimension template-map 1) 2) for x from 0 below (array-dimension template-map 0) do (setf (aref template-map x y) :world-sector-normal-sea) (setf (aref template-map x y1) :world-sector-normal-port))) (:w (loop with x = 0 with x1 = 1 for y from 0 below (array-dimension template-map 1) do (setf (aref template-map x y) :world-sector-normal-sea) (setf (aref template-map x1 y) :world-sector-normal-port))) (:e (loop with x = (1- (array-dimension template-map 0)) with x1 = (- (array-dimension template-map 0) 2) for y from 0 below (array-dimension template-map 1) do (setf (aref template-map x y) :world-sector-normal-sea) (setf (aref template-map x1 y) :world-sector-normal-port))))) ;; place up to 2 islands on the sea tiles (loop with islands-num = (random 3) repeat islands-num do (loop for x = (random (array-dimension template-map 0)) for y = (random (array-dimension template-map 1)) while (not (eq (aref template-map x y) :world-sector-normal-sea)) finally (setf (aref template-map x y) :world-sector-normal-island))) ) ;; place outskirts on some of the borders (let* ((sides '(:n :s :w :e)) (chosen-sides (loop for side in sides when (zerop (random 3)) collect side))) (loop for side in chosen-sides do (case side (:n (loop with y = 0 for x from 0 below (array-dimension template-map 0) when (and (eq (aref template-map x y) :world-sector-normal-residential) (not (zerop (random 4)))) do (setf (aref template-map x y) :world-sector-normal-forest))) (:s (loop with y = (1- (array-dimension template-map 1)) for x from 0 below (array-dimension template-map 0) when (and (eq (aref template-map x y) :world-sector-normal-residential) (not (zerop (random 4)))) do (setf (aref template-map x y) :world-sector-normal-forest))) (:w (loop with x = 0 for y from 0 below (array-dimension template-map 1) when (and (eq (aref template-map x y) :world-sector-normal-residential) (not (zerop (random 4)))) do (setf (aref template-map x y) :world-sector-normal-forest))) (:e (loop with x = (1- (array-dimension template-map 0)) for y from 0 below (array-dimension template-map 1) when (and (eq (aref template-map x y) :world-sector-normal-residential) (not (zerop (random 4)))) do (setf (aref template-map x y) :world-sector-normal-forest)))))) ;; place up to 3 lakes (loop with lakes-num = (random 3) repeat lakes-num do (loop for x = (random (array-dimension template-map 0)) for y = (random (array-dimension template-map 1)) while (not (or (eq (aref template-map x y) :world-sector-normal-residential) (eq (aref template-map x y) :world-sector-normal-forest))) finally (setf (aref template-map x y) :world-sector-normal-lake))) ;; translate the template map into the real world-map (loop for x from 0 below (array-dimension (cells world-map) 0) do (loop for y from 0 below (array-dimension (cells world-map) 1) do (setf (aref (cells world-map) x y) (make-instance 'world-sector :wtype (aref template-map x y) :x x :y y)))) ) ;; place rivers (let ((river-origin-list ())) ;; find all river origins (loop for x from 0 below (array-dimension (cells world-map) 0) do (loop for y from 0 below (array-dimension (cells world-map) 1) do (when (or (eq (wtype (aref (cells world-map) x y)) :world-sector-normal-port) (eq (wtype (aref (cells world-map) x y)) :world-sector-normal-lake)) (push (list x y) river-origin-list)))) ;; choose 1-3 of them (loop with max-origins = (1+ (random 3)) while (> (length river-origin-list) max-origins) do (setf river-origin-list (remove (nth (random (length river-origin-list)) river-origin-list) river-origin-list))) (labels ((make-river (sx sy) (let ((dirs) (r (random 5))) (when (not (find +lm-feat-river+ (feats (aref (cells world-map) sx sy)) :key #'(lambda (a) (first a)))) (push (list +lm-feat-river+ nil) (feats (aref (cells world-map) sx sy)))) (setf dirs (loop for (dx dy) in '((1 0) (-1 0) (0 1) (0 -1)) when (and (> (+ sx dx) 0) (> (+ sy dy) 0) (< (+ sx dx) (array-dimension (cells world-map) 0)) (< (+ sy dy) (array-dimension (cells world-map) 1)) (or (eq (wtype (aref (cells world-map) (+ sx dx) (+ sy dy))) :world-sector-normal-residential) (eq (wtype (aref (cells world-map) (+ sx dx) (+ sy dy))) :world-sector-normal-forest) (eq (wtype (aref (cells world-map) (+ sx dx) (+ sy dy))) :world-sector-normal-lake)) (not (find +lm-feat-river+ (feats (aref (cells world-map) (+ sx dx) (+ sy dy))) :key #'(lambda (a) (first a))))) collect (list dx dy))) (when (zerop r) (when dirs (let* ((dir (nth (random (length dirs)) dirs)) (dx (first dir)) (dy (second dir))) (setf dirs (remove dir dirs)) (make-river (+ sx dx) (+ sy dy))))) (when (or (= r 1) (= r 2)) (when dirs (let* ((dir (nth (random (length dirs)) dirs)) (dx (first dir)) (dy (second dir))) (setf dirs (remove dir dirs)) (make-river (+ sx dx) (+ sy dy))))) ))) (loop for (ox oy) in river-origin-list do (make-river ox oy))) ) ;; place up to 1-2 churches & 1 relic in one of them (loop with church-num = (1+ (random 2)) with church-sectors = () repeat church-num do (loop for x = (random (array-dimension (cells world-map) 0)) for y = (random (array-dimension (cells world-map) 1)) for world-sector = (aref (cells world-map) x y) while (or (eq (wtype world-sector) :world-sector-normal-sea) (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a)))) finally (push (list +lm-feat-church+ nil) (feats world-sector)) (push world-sector church-sectors)) finally (push +lm-item-holy-relic+ (items (nth (random (length church-sectors)) church-sectors)))) ;; place 1 lair (place-satanist-lair-on-map world-map 1) ;; place 1 library & 1 book in it (loop with library-num = 1 with library-sectors = () repeat library-num do (loop for x = (random (array-dimension (cells world-map) 0)) for y = (random (array-dimension (cells world-map) 1)) for world-sector = (aref (cells world-map) x y) while (or (eq (wtype world-sector) :world-sector-normal-sea) (find +lm-feat-library+ (feats world-sector) :key #'(lambda (a) (first a)))) finally (push (list +lm-feat-library+ nil) (feats world-sector)) (push world-sector library-sectors)) finally (push +lm-item-book-of-rituals+ (items (nth (random (length library-sectors)) library-sectors)))) ;; place 1 military (loop with military-num = 1 repeat military-num do (loop for x = (random (array-dimension (cells world-map) 0)) for y = (random (array-dimension (cells world-map) 1)) for world-sector = (aref (cells world-map) x y) while (or (eq (wtype world-sector) :world-sector-normal-sea) (/= (controlled-by world-sector) +lm-controlled-by-none+)) finally (setf (controlled-by world-sector) +lm-controlled-by-military+))) (generate-feats-on-world-map world-map) world-map)) (defun generate-test-world-map (world) (with-slots (world-map) world (setf world-map (make-instance 'world-map)) (setf (cells world-map) (make-array (list *max-x-world-map* *max-y-world-map*) :element-type '(or world-sector null) :initial-element nil)) (setf (aref (cells world-map) 0 0) (make-instance 'world-sector :wtype :world-sector-normal-sea :x 0 :y 0)) (setf (aref (cells world-map) 1 0) (make-instance 'world-sector :wtype :world-sector-normal-sea :x 1 :y 0)) (setf (aref (cells world-map) 2 0) (make-instance 'world-sector :wtype :world-sector-normal-island :x 2 :y 0)) (setf (aref (cells world-map) 3 0) (make-instance 'world-sector :wtype :world-sector-normal-sea :x 3 :y 0)) (setf (aref (cells world-map) 4 0) (make-instance 'world-sector :wtype :world-sector-normal-sea :x 4 :y 0)) (setf (aref (cells world-map) 0 1) (make-instance 'world-sector :wtype :world-sector-abandoned-port :x 0 :y 1)) (setf (aref (cells world-map) 1 1) (make-instance 'world-sector :wtype :world-sector-abandoned-port :x 1 :y 1)) (setf (aref (cells world-map) 2 1) (make-instance 'world-sector :wtype :world-sector-abandoned-port :x 2 :y 1 :feats (list (list +lm-feat-river+ nil)))) (setf (aref (cells world-map) 3 1) (make-instance 'world-sector :wtype :world-sector-normal-port :x 3 :y 1)) (setf (aref (cells world-map) 4 1) (make-instance 'world-sector :wtype :world-sector-normal-port :x 4 :y 1)) (setf (aref (cells world-map) 0 2) (make-instance 'world-sector :wtype :world-sector-abandoned-forest :x 0 :y 2)) (setf (aref (cells world-map) 1 2) (make-instance 'world-sector :wtype :world-sector-corrupted-residential :x 1 :y 2 :feats (list (list +lm-feat-library+)) :items (list +lm-item-holy-relic+))) (setf (aref (cells world-map) 2 2) (make-instance 'world-sector :wtype :world-sector-corrupted-residential :x 2 :y 2 :feats (list (list +lm-feat-river+ nil)) :controlled-by +lm-controlled-by-demons+)) (setf (aref (cells world-map) 3 2) (make-instance 'world-sector :wtype :world-sector-normal-lake :x 3 :y 2 :feats (list (list +lm-feat-river+ nil)) :controlled-by +lm-controlled-by-military+)) (setf (aref (cells world-map) 4 2) (make-instance 'world-sector :wtype :world-sector-normal-forest :x 4 :y 2 :feats (list (list +lm-feat-lair+)))) (setf (aref (cells world-map) 0 3) (make-instance 'world-sector :wtype :world-sector-corrupted-forest :x 0 :y 3)) (setf (aref (cells world-map) 1 3) (make-instance 'world-sector :wtype :world-sector-corrupted-residential :x 1 :y 3 :controlled-by +lm-controlled-by-demons+)) (setf (aref (cells world-map) 2 3) (make-instance 'world-sector :wtype :world-sector-normal-residential :x 2 :y 3 :feats (list (list +lm-feat-river+ nil) (list +lm-feat-lair+) (list +lm-feat-church+)) :items (list +lm-item-holy-relic+) :controlled-by +lm-controlled-by-military+)) (setf (aref (cells world-map) 3 3) (make-instance 'world-sector :wtype :world-sector-corrupted-residential :x 3 :y 3 :controlled-by +lm-controlled-by-demons+)) (setf (aref (cells world-map) 4 3) (make-instance 'world-sector :wtype :world-sector-normal-forest :x 4 :y 3)) (setf (aref (cells world-map) 0 4) (make-instance 'world-sector :wtype :world-sector-normal-lake :x 0 :y 4 :feats (list (list +lm-feat-library+)) :items (list +lm-item-book-of-rituals+))) (setf (aref (cells world-map) 1 4) (make-instance 'world-sector :wtype :world-sector-normal-forest :x 1 :y 4)) (setf (aref (cells world-map) 2 4) (make-instance 'world-sector :wtype :world-sector-corrupted-forest :x 2 :y 4 :feats (list (list +lm-feat-river+ nil)) :controlled-by +lm-controlled-by-demons+)) (setf (aref (cells world-map) 3 4) (make-instance 'world-sector :wtype :world-sector-normal-forest :x 3 :y 4)) (setf (aref (cells world-map) 4 4) (make-instance 'world-sector :wtype :world-sector-normal-forest :x 4 :y 4)) (generate-feats-on-world-map world-map) ;;(generate-missions-on-world-map world) world-map)) (defun regenerate-transient-feats-for-world-sector (world-sector world-map) (let* ((x (x world-sector)) (y (y world-sector)) (barricade-func #'(lambda () (find +lm-feat-barricade+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))))) (can-barricade-func #'(lambda (sx sy tx ty) (if (and (or (and (world-sector-normal-p (aref (cells world-map) sx sy)) (not (eq (wtype (aref (cells world-map) sx sy)) :world-sector-normal-island))) (= (controlled-by (aref (cells world-map) sx sy)) +lm-controlled-by-military+)) (or (= (controlled-by (aref (cells world-map) tx ty)) +lm-controlled-by-demons+) (and (world-sector-corrupted-p (aref (cells world-map) sx sy)) (not (eq (wtype (aref (cells world-map) sx sy)) :world-sector-corrupted-island))))) t nil)))) ;; reset barricades (setf (feats world-sector) (remove +lm-feat-barricade+ (feats world-sector) :key #'(lambda (a) (first a)))) ;; add barricade features (when (and (>= (1- x) 0) (funcall can-barricade-func x y (1- x) y)) (if (funcall barricade-func) (push :w (second (funcall barricade-func))) (push (list +lm-feat-barricade+ (list :w)) (feats (aref (cells world-map) x y))))) (when (and (>= (1- y) 0) (funcall can-barricade-func x y x (1- y))) (if (funcall barricade-func) (push :n (second (funcall barricade-func))) (push (list +lm-feat-barricade+ (list :n)) (feats (aref (cells world-map) x y))))) (when (and (< (1+ x) *max-x-world-map*) (funcall can-barricade-func x y (1+ x) y)) (if (funcall barricade-func) (push :e (second (funcall barricade-func))) (push (list +lm-feat-barricade+ (list :e)) (feats (aref (cells world-map) x y))))) (when (and (< (1+ y) *max-y-world-map*) (funcall can-barricade-func x y x (1+ y))) (if (funcall barricade-func) (push :s (second (funcall barricade-func))) (push (list +lm-feat-barricade+ (list :s)) (feats (aref (cells world-map) x y)))))) world-sector) (defun generate-feats-for-world-sector (world-sector world-map) (let* ((x (x world-sector)) (y (y world-sector)) (river-feat (find +lm-feat-river+ (feats world-sector) :key #'(lambda (a) (first a)))) (sea-feat (find +lm-feat-sea+ (feats world-sector) :key #'(lambda (a) (first a))))) ;; add river features (when river-feat (when (and (>= (1- x) 0) (or (find +lm-feat-river+ (feats (aref (cells world-map) (1- x) y)) :key #'(lambda (a) (first a))) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-island) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-corrupted-island))) (setf (second river-feat) (append (second river-feat) '(:w)))) (when (and (>= (1- y) 0) (or (find +lm-feat-river+ (feats (aref (cells world-map) x (1- y))) :key #'(lambda (a) (first a))) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-island) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-corrupted-island))) (setf (second river-feat) (append (second river-feat) '(:n)))) (when (and (< (1+ x) *max-x-world-map*) (or (find +lm-feat-river+ (feats (aref (cells world-map) (1+ x) y)) :key #'(lambda (a) (first a))) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-island) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-corrupted-island))) (setf (second river-feat) (append (second river-feat) '(:e)))) (when (and (< (1+ y) *max-y-world-map*) (or (find +lm-feat-river+ (feats (aref (cells world-map) x (1+ y))) :key #'(lambda (a) (first a))) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-island) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-corrupted-island))) (setf (second river-feat) (append (second river-feat) '(:s)))) ) ;; add sea features (when (and (>= (1- x) 0) (or (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-normal-island) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) (1- x) y)) :world-sector-corrupted-island))) (if sea-feat (push :w (second sea-feat)) (progn (push (list +lm-feat-sea+ (list :w)) (feats (aref (cells world-map) x y))) (setf sea-feat (find +lm-feat-sea+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))))))) (when (and (>= (1- y) 0) (or (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-normal-island) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) x (1- y))) :world-sector-corrupted-island))) (if sea-feat (push :n (second sea-feat)) (progn (push (list +lm-feat-sea+ (list :n)) (feats (aref (cells world-map) x y))) (setf sea-feat (find +lm-feat-sea+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))))))) (when (and (< (1+ x) *max-x-world-map*) (or (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-normal-island) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) (1+ x) y)) :world-sector-corrupted-island))) (if sea-feat (push :e (second sea-feat)) (progn (push (list +lm-feat-sea+ (list :e)) (feats (aref (cells world-map) x y))) (setf sea-feat (find +lm-feat-sea+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))))))) (when (and (< (1+ y) *max-y-world-map*) (or (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-sea) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-normal-island) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-abandoned-island) (eq (wtype (aref (cells world-map) x (1+ y))) :world-sector-corrupted-island))) (if sea-feat (push :s (second sea-feat)) (progn (push (list +lm-feat-sea+ (list :s)) (feats (aref (cells world-map) x y))) (setf sea-feat (find +lm-feat-sea+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))))))) (regenerate-transient-feats-for-world-sector world-sector world-map) world-sector)) (defun generate-feats-on-world-map (world-map) (loop for y from 0 below *max-y-world-map* do (loop for x from 0 below *max-x-world-map* do (generate-feats-for-world-sector (aref (cells world-map) x y) world-map))) ) (defun recalculate-present-forces (world) (setf (world/cur-military-num world) 0) (setf (world/cur-demons-num world) 0) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (= (controlled-by world-sector) +lm-controlled-by-demons+) (incf (world/cur-demons-num world))) (when (= (controlled-by world-sector) +lm-controlled-by-military+) (incf (world/cur-military-num world)))) ))) (defun recalculate-mission-limits (world) (with-slots (demons-mission-limit military-mission-limit angels-mission-limit) world ;; demon limits (setf demons-mission-limit 0) ;; if the sacrifice was made - add # of dimensional engines for demons for each sacrifice (let* ((angels-win-cond (get-win-condition-by-id :win-cond-angels-campaign)) (machines-left (funcall (win-condition/win-func angels-win-cond) world angels-win-cond))) (incf demons-mission-limit (* machines-left (length (find-campaign-effects-by-id world :campaign-effect-satanist-sacrifice))))) ;; if satanists are present - add 1 to demons (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (find +lm-feat-lair+ (feats world-sector) :key #'(lambda (a) (first a))) (incf demons-mission-limit))))) ;; add the number of demonic forces present in the city (incf demons-mission-limit (world/cur-demons-num world)) ;; military limits (setf military-mission-limit 0) ;; add the number of military forces present in the city (incf military-mission-limit (world/cur-military-num world)) ;; angel limits (setf angels-mission-limit 1) ;; if the relic is in the residential church - add 1 to angels, if the relic is in the corrupted district - add 1 to demons (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) (when (and (find +lm-feat-church+ (feats world-sector) :key #'(lambda (a) (first a))) (find +lm-item-holy-relic+ (items world-sector)) (world-sector-normal-p world-sector)) (incf angels-mission-limit)) (when (and (find +lm-item-holy-relic+ (items world-sector)) (world-sector-corrupted-p world-sector)) (incf demons-mission-limit))))) )) (defun generate-missions-on-world-map (world) (recalculate-present-forces world) (recalculate-mission-limits world) ;; check what kind of missions are available on the map (let ((avail-mission-slots ()) (demons-mission-limit (world/demons-mission-limit world)) (military-mission-limit (world/military-mission-limit world)) (angels-mission-limit (world/angels-mission-limit world))) (flet ((calc-avail-mission-slots () (setf avail-mission-slots ()) (loop for mission-slot-type in (list :mission-slot-demons-city :mission-slot-angels-city :mission-slot-military-city :mission-slot-angels-offworld :mission-slot-military-offworld) do (setf (getf avail-mission-slots mission-slot-type) 0)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (let ((world-sector (aref (cells (world-map world)) x y))) ;; calculate how many mission-slots can missions fill for city missions (loop for mission-slot-type in (list :mission-slot-demons-city :mission-slot-angels-city :mission-slot-military-city) do (loop for mission-type-id in (getf (world/missions-by-slot-type world) mission-slot-type) for mission-type = (get-mission-type-by-id mission-type-id) when (and (null (mission world-sector)) (is-available-func mission-type) (funcall (is-available-func mission-type) world-sector world)) do (incf (getf avail-mission-slots (mission-slot-type mission-type))) (loop-finish))) ;; calculate available number of mission slots for offworld mission (loop for mission-slot-type in (list :mission-slot-angels-offworld :mission-slot-military-offworld) do (loop for mission-type-id in (getf (world/missions-by-slot-type world) mission-slot-type) for mission-type = (get-mission-type-by-id mission-type-id) when (and (null (mission world-sector)) (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-corrupted-p world-sector)) do (incf (getf avail-mission-slots (mission-slot-type mission-type))) (loop-finish))))))) (create-city-mission (mission-slot-type) (loop for rx = (random *max-x-world-map*) for ry = (random *max-y-world-map*) for world-sector = (aref (cells (world-map world)) rx ry) for avail-missions = (loop for mission-type-id in (getf (world/missions-by-slot-type world) mission-slot-type) for mission-type = (get-mission-type-by-id mission-type-id) when (and (is-available-func mission-type) (funcall (is-available-func mission-type) world-sector world)) collect (id mission-type)) until (and (null (mission world-sector)) avail-missions) finally (let ((mission-type-id (nth (random (length avail-missions)) avail-missions))) (setf (mission world-sector) (generate-mission-on-world-map world rx ry mission-type-id :off-map nil)) (push (mission world-sector) (world/present-missions world))) (case mission-slot-type (:mission-slot-demons-city (decf demons-mission-limit)) (:mission-slot-military-city (decf military-mission-limit)) (:mission-slot-angels-city (decf angels-mission-limit)) (t (error "Wrong mission-slot-type supplied: only :MISSION-SLOT-DEMONS-CITY, :MISSION-SLOT-MILITARY-CITY or :MISSION-SLOT-ANGELS-CITY are allowed!"))))) (create-offworld-mission (mission-slot-type) (loop with avail-missions = (loop for mission-type-id in (getf (world/missions-by-slot-type world) mission-slot-type) for mission-type = (get-mission-type-by-id mission-type-id) for off-sector = (make-instance 'world-sector :wtype (first (world-sector-for-custom-scenario mission-type)) :x 0 :y 0) when (and (is-available-func mission-type) (funcall (is-available-func mission-type) off-sector world)) collect (id mission-type)) for rx = (random *max-x-world-map*) for ry = (random *max-y-world-map*) for world-sector = (aref (cells (world-map world)) rx ry) until (and (null (mission world-sector)) (eq (controlled-by world-sector) +lm-controlled-by-none+) (world-sector-corrupted-p world-sector)) finally (when avail-missions (let ((mission-type-id (nth (random (length avail-missions)) avail-missions))) (setf (mission world-sector) (generate-mission-on-world-map world rx ry mission-type-id :off-map t)) (push (mission world-sector) (world/present-missions world))) (case mission-slot-type (:mission-slot-military-offworld (decf military-mission-limit)) (:mission-slot-angels-offworld (decf angels-mission-limit)) (t (error "Wrong mission-slot-type supplied: only :MISSION-SLOT-MILITARY-OFFWORLD or :MISSION-SLOT-ANGELS-OFFWORLD are allowed!")))))) (fill-slot-quota (mission-slot-type mission-limit-num create-mission-func &key do-once) (loop repeat (if (> (getf avail-mission-slots mission-slot-type) mission-limit-num) mission-limit-num (getf avail-mission-slots mission-slot-type)) do (funcall create-mission-func mission-slot-type) (when do-once (loop-finish))))) ;; loop for all mission slot types in the supplied order (order is important) (loop for mission-slot-type in (list :mission-slot-demons-city :mission-slot-military-offworld :mission-slot-military-city :mission-slot-angels-offworld :mission-slot-angels-city) do (calc-avail-mission-slots) (case mission-slot-type (:mission-slot-demons-city (fill-slot-quota mission-slot-type demons-mission-limit #'create-city-mission)) (:mission-slot-military-city (fill-slot-quota mission-slot-type military-mission-limit #'create-city-mission)) (:mission-slot-angels-city (fill-slot-quota mission-slot-type angels-mission-limit #'create-city-mission)) ;; add 1 offworld military mission - 15% chance & dimension not protected (:mission-slot-military-offworld (when (and (< (random 100) 15) (not (find-campaign-effects-by-id world :campaign-effect-demon-protect-dimension))) (fill-slot-quota mission-slot-type military-mission-limit #'create-offworld-mission :do-once t))) ;; add 1 offworld angel mission - 15% chance & dimension not protected (:mission-slot-angels-offworld (when (and (< (random 100) 15) (not (find-campaign-effects-by-id world :campaign-effect-demon-protect-dimension))) (fill-slot-quota mission-slot-type angels-mission-limit #'create-offworld-mission :do-once t))))) ) ) ) (defun generate-mission-on-world-map (world-param x y mission-type-id &key (off-map nil)) (let ((scenario (make-instance 'scenario-gen-class))) (with-slots (world mission world-sector avail-feats-list avail-items-list avail-controlled-list avail-tod-list avail-weather-list avail-world-sector-type-list) scenario (setf world world-param) (scenario-create-mission scenario mission-type-id :x x :y y) (if off-map (progn (scenario-set-avail-world-sector-types scenario) (setf world-sector (make-instance 'world-sector :wtype (wtype (nth (random (length avail-world-sector-type-list)) avail-world-sector-type-list)) :x x :y y))) (progn (setf world-sector (aref (cells (world-map world)) x y)))) ;; make angels delayed if portals are corrupted (when (and (find-campaign-effects-by-id world :campaign-effect-demon-corrupt-portals) (not (eql mission-type-id :mission-type-celestial-purge)) (not (eql mission-type-id :mission-type-celestial-sabotage)) (not (eql mission-type-id :mission-type-celestial-retrieval))) (loop for faction-obj in (faction-list mission) when (and (eql (first faction-obj) +faction-type-angels+) (eql (second faction-obj) :mission-faction-present)) do (setf (second faction-obj) :mission-faction-delayed))) (scenario-set-avail-lvl-mods scenario) (when off-map ;; set a random controlled-by lvl-mod (scenario-add/remove-lvl-mod scenario (nth (random (length avail-controlled-list)) avail-controlled-list) :apply-scenario-func nil) ;; add random feats lvl-mods (loop for lvl-mod in avail-feats-list when (zerop (random 4)) do (scenario-add/remove-lvl-mod scenario lvl-mod :apply-scenario-func nil)) ;; add random items lvl-mods (loop for lvl-mod in avail-items-list when (zerop (random 4)) do (scenario-add/remove-lvl-mod scenario lvl-mod :apply-scenario-func nil)) (scenario-adjust-lvl-mods-after-sector-regeneration scenario) ) ;; a time of day (scenario-add/remove-lvl-mod scenario (nth (random (length avail-tod-list)) avail-tod-list) :apply-scenario-func nil) ;; add a random weather (loop for lvl-mod in avail-weather-list when (or (not (random-available-for-mission lvl-mod)) (funcall (random-available-for-mission lvl-mod))) do (scenario-add/remove-lvl-mod scenario lvl-mod :apply-scenario-func nil)) ;; set up special lvl mods (if (find-campaign-effects-by-id world :campaign-effect-eater-agitated) (progn (scenario-add/remove-lvl-mod scenario (get-level-modifier-by-id +lm-misc-eater-incursion+) :apply-scenario-func nil)) (progn (scenario-add/remove-lvl-mod scenario (get-level-modifier-by-id +lm-misc-eater-incursion+) :apply-scenario-func nil :add-general nil))) (if (find-campaign-effects-by-id world :campaign-effect-demon-malseraph-blessing) (progn (scenario-add/remove-lvl-mod scenario (get-level-modifier-by-id +lm-misc-malseraphs-blessing+) :apply-scenario-func nil)) (progn (scenario-add/remove-lvl-mod scenario (get-level-modifier-by-id +lm-misc-malseraphs-blessing+) :apply-scenario-func nil :add-general nil))) (setf (world-sector mission) world-sector) (setf (mission (world-sector mission)) mission) ;; set up random functions (scenario-adjust-factions scenario) mission))) (defun reset-all-missions-on-world-map (world) (loop for x from 0 below *max-x-world-map* do (loop for y from 0 below *max-y-world-map* do (setf (mission (aref (cells (world-map world)) x y)) nil))) (setf (world/present-missions world) ()) (world-map world)) (defun auto-resolve-mission (world mission) (let ((faction-base-chances (list (list +faction-type-angels+ 100) (list +faction-type-demons+ 100) (list +faction-type-military+ 100) (list +faction-type-church+ 50) (list +faction-type-satanists+ 50) (list +faction-type-eater+ 50))) (faction-multipliers (list (list +faction-type-angels+ 100) (list +faction-type-demons+ 100) (list +faction-type-military+ 100) (list +faction-type-church+ 100) (list +faction-type-satanists+ 100) (list +faction-type-eater+ 100))) (faction-chances ()) (max-n 0) (faction-winner nil) (mission-result nil)) (log:info "Start") ;; base chances depending on faction presence (loop for (faction-id faction-present) in (faction-list mission) for chance = (second (find faction-id faction-base-chances :key #'(lambda (a) (first a)))) when (and (not (eq faction-present :mission-faction-absent)) chance) do (when (eq faction-present :mission-faction-present) (setf chance (* chance 2))) (push (list faction-id chance) faction-chances)) (loop initially (log:info " Init chances") with str-table = (list (list +faction-type-angels+ :game-over-angels-won) (list +faction-type-demons+ :game-over-demons-won) (list +faction-type-military+ :game-over-military-won) (list +faction-type-church+ :game-over-church-won) (list +faction-type-satanists+ :game-over-satanists-won) (list +faction-type-eater+ :game-over-eater-won)) for (faction-id base-chance) in faction-chances do (log:info " ~A: ~A" (second (find faction-id str-table :key (lambda (a) (first a)))) base-chance)) ;; it is harder for non-demons in hell districts -60% (when (and (world-sector mission) (world-sector-hell-p (world-sector mission))) (loop for faction-id in (list +faction-type-angels+ +faction-type-military+ +faction-type-church+) do (log:info " Corrupted district -60% to non-demons") (when (find faction-id faction-chances :key #'(lambda (a) (first a))) (decf (second (find faction-id faction-multipliers :key #'(lambda (a) (first a)))) 60)))) ;; it is harder for non-demons in corrupted districts -30% (when (and (world-sector mission) (world-sector-corrupted-p (world-sector mission))) (loop for faction-id in (list +faction-type-angels+ +faction-type-military+ +faction-type-church+) do (log:info " Corrupted district -30% to non-demons") (when (find faction-id faction-chances :key #'(lambda (a) (first a))) (decf (second (find faction-id faction-multipliers :key #'(lambda (a) (first a)))) 30)))) ;; it is harder for non-demons in abandoned districts -15% (when (and (world-sector mission) (world-sector-abandoned-p (world-sector mission))) (loop for faction-id in (list +faction-type-angels+ +faction-type-military+ +faction-type-church+) do (log:info " Abandonded district -15% to non-demons") (when (find faction-id faction-chances :key #'(lambda (a) (first a))) (decf (second (find faction-id faction-multipliers :key #'(lambda (a) (first a)))) 15)))) ;; primordial incursion makes it easier for primordials +100% (when (find +lm-misc-eater-incursion+ (level-modifier-list mission)) (log:info " Primordial incursion +100% to primordials") (incf (second (find +faction-type-eater+ faction-multipliers :key #'(lambda (a) (first a)))) 100)) ;; :campaign-effect-demon-delayed make it harder for delayed demons -30% (when (and (find-campaign-effects-by-id world :campaign-effect-demon-delayed) (find +faction-type-demons+ (faction-list mission) :key #'(lambda (a) (first a))) (eql (find +faction-type-demons+ (faction-list mission) :key #'(lambda (a) (first a))) :mission-faction-delayed)) (log:info " Demons delayed effect -30% to delayed demons") (decf (second (find +faction-type-demons+ faction-multipliers :key #'(lambda (a) (first a)))) 30)) ;; :campaign-effect-angel-hastened make it easier for delayed angels +30% (when (and (find-campaign-effects-by-id world :campaign-effect-angel-hastened) (find +faction-type-angels+ (faction-list mission) :key #'(lambda (a) (first a))) (eql (find +faction-type-angels+ (faction-list mission) :key #'(lambda (a) (first a))) :mission-faction-delayed)) (log:info " Angels hastened effect +30% to delayed angels") (incf (second (find +faction-type-angels+ faction-multipliers :key #'(lambda (a) (first a)))) 30)) ;; malseraphs blessing makes it easier for demons (when (find +lm-misc-malseraphs-blessing+ (level-modifier-list mission)) (log:info " Malseraph's blessing +10% to demons") (incf (second (find +faction-type-demons+ faction-multipliers :key #'(lambda (a) (first a)))) 10)) ;; apply multipliers (loop with chances-multiplied = () with multiplier = nil for (faction-id base-chance) in faction-chances do (if (find faction-id faction-multipliers :key #'(lambda (a) (first a))) (setf multiplier (second (find faction-id faction-multipliers :key #'(lambda (a) (first a))))) (setf multiplier 100)) (when (minusp multiplier) (setf multiplier 0)) (setf base-chance (truncate (* base-chance (/ multiplier 100)))) (unless (zerop base-chance) (push (list faction-id base-chance) chances-multiplied)) finally (setf faction-chances chances-multiplied)) (loop initially (log:info " Final chances") with str-table = (list (list +faction-type-angels+ :game-over-angels-won) (list +faction-type-demons+ :game-over-demons-won) (list +faction-type-military+ :game-over-military-won) (list +faction-type-church+ :game-over-church-won) (list +faction-type-satanists+ :game-over-satanists-won) (list +faction-type-eater+ :game-over-eater-won)) for (faction-id base-chance) in faction-chances do (log:info " ~A: ~A" (second (find faction-id str-table :key (lambda (a) (first a)))) base-chance)) ;; calculate winner (setf max-n (loop for (faction-id chance) in faction-chances sum chance)) (unless (zerop max-n) (loop with n = (random max-n) with lower-border = 0 with upper-border = 0 for (faction-id chance) in faction-chances do (setf upper-border (+ lower-border chance)) (if (and (>= n lower-border) (< n upper-border)) (progn (setf faction-winner faction-id) (loop-finish)) (progn (setf lower-border upper-border))) finally (log:info " Chance is ~A out of ~A" n max-n))) (when faction-winner (setf (getf mission-result :mission-result) (second (find faction-winner (list (list +faction-type-angels+ :game-over-angels-won) (list +faction-type-demons+ :game-over-demons-won) (list +faction-type-military+ :game-over-military-won) (list +faction-type-church+ :game-over-church-won) (list +faction-type-satanists+ :game-over-satanists-won) (list +faction-type-eater+ :game-over-eater-won)) :key (lambda (a) (first a)))))) mission-result)) (defun message-box-add-transform-message (prev-wtype world-sector &key (message-box-list `(,(world/mission-message-box *world*)))) (when (not (eq prev-wtype (wtype world-sector))) (add-message (format nil " The sector has become ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name world-sector)) sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list))) (defun transform-residential-sector-to-abandoned (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-normal-residential (setf (wtype world-sector) :world-sector-abandoned-residential)) (:world-sector-normal-forest (setf (wtype world-sector) :world-sector-abandoned-forest)) (:world-sector-normal-port (setf (wtype world-sector) :world-sector-abandoned-port)) (:world-sector-normal-island (setf (wtype world-sector) :world-sector-abandoned-island)) (:world-sector-normal-lake (setf (wtype world-sector) :world-sector-abandoned-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun transform-residential-sector-to-corrupted (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-normal-residential (setf (wtype world-sector) :world-sector-corrupted-residential)) (:world-sector-normal-forest (setf (wtype world-sector) :world-sector-corrupted-forest)) (:world-sector-normal-port (setf (wtype world-sector) :world-sector-corrupted-port)) (:world-sector-normal-island (setf (wtype world-sector) :world-sector-corrupted-island)) (:world-sector-normal-lake (setf (wtype world-sector) :world-sector-corrupted-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun transform-abandoned-sector-to-residential (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-abandoned-residential (setf (wtype world-sector) :world-sector-normal-residential)) (:world-sector-abandoned-forest (setf (wtype world-sector) :world-sector-normal-forest)) (:world-sector-abandoned-port (setf (wtype world-sector) :world-sector-normal-port)) (:world-sector-abandoned-island (setf (wtype world-sector) :world-sector-normal-island)) (:world-sector-abandoned-lake (setf (wtype world-sector) :world-sector-normal-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun transform-abandoned-sector-to-corrupted (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-abandoned-residential (setf (wtype world-sector) :world-sector-corrupted-residential)) (:world-sector-abandoned-forest (setf (wtype world-sector) :world-sector-corrupted-forest)) (:world-sector-abandoned-port (setf (wtype world-sector) :world-sector-corrupted-port)) (:world-sector-abandoned-island (setf (wtype world-sector) :world-sector-corrupted-island)) (:world-sector-abandoned-lake (setf (wtype world-sector) :world-sector-corrupted-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun transform-corrupted-sector-to-residential (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-corrupted-residential (setf (wtype world-sector) :world-sector-normal-residential)) (:world-sector-corrupted-forest (setf (wtype world-sector) :world-sector-normal-forest)) (:world-sector-corrupted-port (setf (wtype world-sector) :world-sector-normal-port)) (:world-sector-corrupted-island (setf (wtype world-sector) :world-sector-normal-island)) (:world-sector-corrupted-lake (setf (wtype world-sector) :world-sector-normal-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun transform-corrupted-sector-to-abandoned (world-map x y) (let* ((world-sector (aref (cells world-map) x y)) (prev-wtype (wtype world-sector))) (case (wtype world-sector) (:world-sector-corrupted-residential (setf (wtype world-sector) :world-sector-abandoned-residential)) (:world-sector-corrupted-forest (setf (wtype world-sector) :world-sector-abandoned-forest)) (:world-sector-corrupted-port (setf (wtype world-sector) :world-sector-abandoned-port)) (:world-sector-corrupted-island (setf (wtype world-sector) :world-sector-abandoned-island)) (:world-sector-corrupted-lake (setf (wtype world-sector) :world-sector-abandoned-lake))) (message-box-add-transform-message prev-wtype world-sector))) (defun remove-satanist-lair-from-map (world-map x y) (let ((world-sector (aref (cells world-map) x y)) (message-box-list `(,(world/mission-message-box *world*)))) (setf (feats world-sector) (remove +lm-feat-lair+ (feats world-sector) :key #'(lambda (a) (first a)))) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "satanist lair") sdl:*yellow* message-box-list) (add-message (format nil " has been destroyed.") sdl:*white* message-box-list))) (defun move-relic-to-corrupted-district (world-map x y) (when (not (find +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (return-from move-relic-to-corrupted-district nil)) (let ((corrupted-sector (loop with corrupted-district-list = () for dx from 0 below (array-dimension (cells world-map) 0) do (loop for dy from 0 below (array-dimension (cells world-map) 1) do (when (and (world-sector-corrupted-p (aref (cells world-map) dx dy)) (not (and (= x dx) (= y dy))) (not (find +lm-item-holy-relic+ (items (aref (cells world-map) dx dy))))) (push (aref (cells world-map) dx dy) corrupted-district-list))) finally (when corrupted-district-list (return (nth (random (length corrupted-district-list)) corrupted-district-list))))) (message-box-list `(,(world/mission-message-box *world*)))) (when corrupted-sector (setf (items (aref (cells world-map) x y)) (remove +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (push +lm-item-holy-relic+ (items corrupted-sector)) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "relic") sdl:*yellow* message-box-list) (add-message (format nil " was taken and moved to ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name corrupted-sector)) sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)))) (defun move-relic-to-church (world-map x y) (when (or (not (find +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (and (find +lm-item-holy-relic+ (items (aref (cells world-map) x y))) (find +lm-feat-church+ (feats (aref (cells world-map) x y)) :key #'(lambda (a) (first a))) (world-sector-normal-p (aref (cells world-map) x y)))) (return-from move-relic-to-church nil)) (let ((church-sector (loop with church-sector-list = () for dx from 0 below (array-dimension (cells world-map) 0) do (loop for dy from 0 below (array-dimension (cells world-map) 1) do (when (and (world-sector-normal-p (aref (cells world-map) dx dy)) (not (and (= x dx) (= y dy))) (find +lm-feat-church+ (feats (aref (cells world-map) dx dy)) :key #'(lambda (a) (first a))) (not (find +lm-item-holy-relic+ (items (aref (cells world-map) dx dy))))) (push (aref (cells world-map) dx dy) church-sector-list))) finally (when church-sector-list (return (nth (random (length church-sector-list)) church-sector-list))))) (message-box-list `(,(world/mission-message-box *world*)))) (when church-sector (setf (items (aref (cells world-map) x y)) (remove +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (push +lm-item-holy-relic+ (items church-sector)) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "relic") sdl:*yellow* message-box-list) (add-message (format nil " was moved back into the church in ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name church-sector)) sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)))) (defun move-military-to-free-sector (world-map x y) (when (not (eq (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-military+)) (return-from move-military-to-free-sector nil)) (let ((free-sector (let ((free-sector-list ())) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (cells world-map) 0)) (< dy (array-dimension (cells world-map) 1)) (world-sector-normal-p (aref (cells world-map) dx dy)) (not (and (= x dx) (= y dy))) (eq (controlled-by (aref (cells world-map) dx dy)) +lm-controlled-by-none+)) (push (aref (cells world-map) dx dy) free-sector-list)))) (if free-sector-list (nth (random (length free-sector-list)) free-sector-list) nil))) (message-box-list `(,(world/mission-message-box *world*)))) (if free-sector (progn (setf (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-none+) (setf (controlled-by free-sector) +lm-controlled-by-military+) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "military") sdl:*yellow* message-box-list) (add-message (format nil " were pushed away into ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name free-sector)) sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) (progn (setf (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-none+) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "military army") sdl:*yellow* message-box-list) (add-message (format nil " present there was ") sdl:*white* message-box-list) (add-message (format nil "slaughtered") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list))))) (defun move-demons-to-free-sector (world-map x y) (when (not (eq (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-demons+)) (return-from move-demons-to-free-sector nil)) (let ((corrupted-sector (let ((corrupted-sector-list ())) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (cells world-map) 0)) (< dy (array-dimension (cells world-map) 1)) (world-sector-corrupted-p (aref (cells world-map) dx dy)) (not (and (= x dx) (= y dy))) (eq (controlled-by (aref (cells world-map) dx dy)) +lm-controlled-by-none+)) (push (aref (cells world-map) dx dy) corrupted-sector-list)))) (if corrupted-sector-list (nth (random (length corrupted-sector-list)) corrupted-sector-list) nil))) (message-box-list `(,(world/mission-message-box *world*)))) (if corrupted-sector (progn (setf (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-none+) (setf (controlled-by corrupted-sector) +lm-controlled-by-demons+) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "demons") sdl:*yellow* message-box-list) (add-message (format nil " were pushed away into ") sdl:*white* message-box-list) (add-message (format nil "~(~A~)" (name corrupted-sector)) sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) (progn (setf (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-none+) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "demon army") sdl:*yellow* message-box-list) (add-message (format nil " present there was ") sdl:*white* message-box-list) (add-message (format nil "slaughtered") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list))))) (defun remove-hell-engine (world-map x y) (declare (ignore world-map x y)) (let* ((angels-win-cond (get-win-condition-by-id :win-cond-angels-campaign)) (machines-left (funcall (win-condition/win-func angels-win-cond) *world* angels-win-cond))) (when (<= machines-left 0) (return-from remove-hell-engine nil))) (incf (world/machine-destroyed *world*)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "dimensional engine") sdl:*yellow* message-box-list) (add-message (format nil " was ") sdl:*white* message-box-list) (add-message (format nil "shattered") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) ) (defun throw-hell-in-turmoil (world-map x y) (declare (ignore world-map x y)) (add-campaign-effect *world* :id :campaign-effect-demon-turmoil :cd 3) ) (defun demons-capture-book-of-rituals (world-map x y) (when (not (find +lm-item-book-of-rituals+ (items (aref (cells world-map) x y)))) (return-from demons-capture-book-of-rituals nil)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " Demons have ") sdl:*white* message-box-list) (add-message (format nil "captured") sdl:*yellow* message-box-list) (add-message (format nil " the ") sdl:*white* message-box-list) (add-message (format nil "Book of Rituals") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) ) (defun demons-capture-relic (world-map x y) (when (not (find +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (return-from demons-capture-relic nil)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " Demons have ") sdl:*white* message-box-list) (add-message (format nil "captured") sdl:*yellow* message-box-list) (add-message (format nil " the ") sdl:*white* message-box-list) (add-message (format nil "holy relic") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) ) (defun humans-capture-book-of-rituals (world-map x y) (when (not (find +lm-item-book-of-rituals+ (items (aref (cells world-map) x y)))) (return-from humans-capture-book-of-rituals nil)) (loop for campaign-effect in (find-campaign-effects-by-id *world* :campaign-effect-demon-protect-dimension) do (remove-campaign-effect *world* campaign-effect)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " Humans have ") sdl:*white* message-box-list) (add-message (format nil "captured") sdl:*yellow* message-box-list) (add-message (format nil " the ") sdl:*white* message-box-list) (add-message (format nil "Book of Rituals") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) ) (defun humans-capture-relic (world-map x y) (when (not (find +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (return-from humans-capture-relic nil)) (loop for campaign-effect in (find-campaign-effects-by-id *world* :campaign-effect-demon-corrupt-portals) do (remove-campaign-effect *world* campaign-effect)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " Humans have ") sdl:*white* message-box-list) (add-message (format nil "captured") sdl:*yellow* message-box-list) (add-message (format nil " the ") sdl:*white* message-box-list) (add-message (format nil "holy relic") sdl:*yellow* message-box-list) (add-message (format nil ".") sdl:*white* message-box-list)) ) (defun neutrals-capture-book-of-rituals (world-map x y) (when (not (find +lm-item-book-of-rituals+ (items (aref (cells world-map) x y)))) (return-from neutrals-capture-book-of-rituals nil)) (loop for campaign-effect in (find-campaign-effects-by-id *world* :campaign-effect-demon-protect-dimension) do (remove-campaign-effect *world* campaign-effect)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "Book of Rituals") sdl:*yellow* message-box-list) (add-message (format nil " is ") sdl:*white* message-box-list) (add-message (format nil "not controlled") sdl:*yellow* message-box-list) (add-message (format nil " by any faction.") sdl:*white* message-box-list)) ) (defun neutrals-capture-relic (world-map x y) (when (not (find +lm-item-holy-relic+ (items (aref (cells world-map) x y)))) (return-from neutrals-capture-relic nil)) (loop for campaign-effect in (find-campaign-effects-by-id *world* :campaign-effect-demon-corrupt-portals) do (remove-campaign-effect *world* campaign-effect)) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "holy relic") sdl:*yellow* message-box-list) (add-message (format nil " is ") sdl:*white* message-box-list) (add-message (format nil "not controlled") sdl:*yellow* message-box-list) (add-message (format nil " by any faction.") sdl:*white* message-box-list)) ) (defun remove-raw-flesh-from-demons (world-map x y) (declare (ignore world-map x y)) (when (<= (world/flesh-points *world*) 0) (return-from remove-raw-flesh-from-demons nil)) (let ((pts-to-remove (+ (random 300) 100))) (when (< (- (world/flesh-points *world*) pts-to-remove) 0) (setf pts-to-remove (world/flesh-points *world*))) (decf (world/flesh-points *world*) pts-to-remove) (let ((message-box-list `(,(world/mission-message-box *world*)))) (add-message (format nil " The ") sdl:*white* message-box-list) (add-message (format nil "raw flesh stockpiles") sdl:*yellow* message-box-list) (add-message (format nil " were blown up. ") sdl:*white* message-box-list) (add-message (format nil "~A flesh point~:P" pts-to-remove) sdl:*yellow* message-box-list) (add-message (format nil " were destroyed.") sdl:*white* message-box-list)) )) (defun calc-all-military-on-world-map (world-map) (let ((military-sum 0) (military-sectors ())) (loop for x from 0 below (array-dimension (cells world-map) 0) do (loop for y from 0 below (array-dimension (cells world-map) 1) do (when (eq (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-military+) (push (aref (cells world-map) x y) military-sectors) (incf military-sum)))) (values military-sum military-sectors))) (defun calc-all-demons-on-world-map (world-map) (let ((demons-sum 0) (demons-sectors ())) (loop for x from 0 below (array-dimension (cells world-map) 0) do (loop for y from 0 below (array-dimension (cells world-map) 1) do (when (eq (controlled-by (aref (cells world-map) x y)) +lm-controlled-by-demons+) (push (aref (cells world-map) x y) demons-sectors) (incf demons-sum)))) (values demons-sum demons-sectors))) (defun find-campaign-effects-by-id (world campaign-effect-id) (loop for campaign-effect in (world/campaign-effects world) when (eq (campaign-effect/id campaign-effect) campaign-effect-id) collect campaign-effect)) (defun add-campaign-effect (world &key id cd param) (unless id (error ":ID is an obligatory parameter!")) (let ((new-effect (make-instance 'campaign-effect :id id :cd cd :param param)) (old-effect (find-campaign-effects-by-id world id))) (if (and old-effect (campaign-effect-type/merge-func (get-campaign-effect-type-by-id id))) (funcall (campaign-effect-type/merge-func (get-campaign-effect-type-by-id id)) world new-effect (first old-effect)) (progn (push new-effect (world/campaign-effects world)) (when (campaign-effect/on-add-func new-effect) (funcall (campaign-effect/on-add-func new-effect) world new-effect)))) )) (defun remove-campaign-effect (world campaign-effect) (with-slots (campaign-effects) world (when (campaign-effect/on-remove-func campaign-effect) (funcall (campaign-effect/on-remove-func campaign-effect) world campaign-effect)) (setf campaign-effects (remove campaign-effect campaign-effects)))) (defun find-specific-world-sectors (world &rest args) (let ((cells (cells (world-map world))) (world-sector nil) (result (make-list (length args)))) (loop for x from 0 below (array-dimension cells 0) do (loop for y from 0 below (array-dimension cells 1) do (setf world-sector (aref cells x y)) ;; each argument of the args shall be a function (loop for func in args for i from 0 do (when (funcall func world-sector x y) (push world-sector (nth i result)))))) result))
73,055
Common Lisp
.lisp
1,065
53.053521
195
0.573644
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
79883658efac6ae16287fd292ac2cb3d1a78540de80f9743bf94b9df078f8519
2,873
[ -1 ]
2,874
mission-type.lisp
gwathlobal_CotD/src/mission-type.lisp
(in-package :cotd) (defenum:defenum mission-slot-enum (:mission-slot-demons-city :mission-slot-angels-city :mission-slot-military-city :mission-slot-military-offworld :mission-slot-angels-offworld)) (defclass mission-type () ((id :initform :mission-type-none :initarg :id :accessor id :type mission-type-enum) (name :initform "Mission type name" :initarg :name :accessor name) (enabled :initform t :initarg :enabled :accessor enabled) (mission-slot-type :initform :mission-slot-demons-city :initarg :mission-slot-type :accessor mission-slot-type :type mission-slot-enum) (is-available-func :initform #'(lambda (world-sector world) (declare (ignore world-sector world)) nil) :initarg :is-available-func :accessor is-available-func) (faction-list-func :initform nil :initarg :faction-list-func :accessor faction-list-func) ;; the func that takes world-sector-type-id and returns a list of faction-ids (world-sector-for-custom-scenario :initform () :initarg :world-sector-for-custom-scenario :accessor world-sector-for-custom-scenario) ;; the list of world-sectors available for this mission, specifically for custom scenario (always-lvl-mods-func :initform nil :initarg :always-lvl-mods-func :accessor always-lvl-mods-func) (template-level-gen-func :initform nil :initarg :template-level-gen-func :accessor template-level-gen-func) (overall-post-process-func-list :initform nil :initarg :overall-post-process-func-list :accessor overall-post-process-func-list) (terrain-post-process-func-list :initform nil :initarg :terrain-post-process-func-list :accessor terrain-post-process-func-list) (scenario-faction-list :initform nil :initarg :scenario-faction-list :accessor scenario-faction-list) (ai-package-list :initform nil :initarg :ai-package-list :accessor ai-package-list) (win-condition-list :initform nil :initarg :win-condition-list :accessor win-condition-list) (ability-list :initform () :initarg :ability-list :accessor ability-list) (campaign-result :initform () :initarg :campaign-result :accessor mission-type/campaign-result :type list) )) (defun set-mission-type (&key id name (enabled t) mission-slot-type is-available-func faction-list-func template-level-gen-func overall-post-process-func-list terrain-post-process-func-list scenario-faction-list ai-package-list win-condition-list world-sector-for-custom-scenario ability-list (always-lvl-mods-func #'(lambda (world-sector mission world-time) (declare (ignore world-sector mission world-time)) nil)) campaign-result) (unless id (error ":ID is an obligatory parameter!")) (unless name (error ":NAME is an obligatory parameter!")) (unless mission-slot-type (error ":MISSION-SLOT-TYPE is an obligatory parameter!")) (setf (gethash id *mission-types*) (make-instance 'mission-type :id id :name name :enabled enabled :is-available-func is-available-func :mission-slot-type mission-slot-type :faction-list-func faction-list-func :template-level-gen-func template-level-gen-func :overall-post-process-func-list overall-post-process-func-list :terrain-post-process-func-list terrain-post-process-func-list :faction-list-func faction-list-func :scenario-faction-list scenario-faction-list :ai-package-list ai-package-list :win-condition-list win-condition-list :ability-list ability-list :world-sector-for-custom-scenario world-sector-for-custom-scenario :always-lvl-mods-func always-lvl-mods-func :campaign-result campaign-result ))) (defun get-mission-type-by-id (mission-type-id) (gethash mission-type-id *mission-types*)) (defun get-all-mission-types-list (&key (include-disabled nil)) (loop for mission-type being the hash-values in *mission-types* when (or (and (not include-disabled) (enabled mission-type)) (and include-disabled (not (enabled mission-type)))) collect mission-type)) (defun get-ai-based-on-faction (faction-id mission-type-id) (if (find faction-id (ai-package-list (get-mission-type-by-id mission-type-id)) :key #'(lambda (a) (first a))) (progn (second (find faction-id (ai-package-list (get-mission-type-by-id mission-type-id)) :key #'(lambda (a) (first a))))) nil)) (defun get-abilities-based-on-faction (faction-id mission-type-id) (let ((faction-abilities (find faction-id (ability-list (get-mission-type-by-id mission-type-id)) :key #'(lambda (a) (first a))))) (if faction-abilities (second faction-abilities) nil))) (defun setup-win-conditions (mission level) (loop for (faction-id game-event-id) in (win-condition-list (get-mission-type-by-id (mission-type-id mission))) when (find-if #'(lambda (a) (if (and (= (first a) faction-id) (or (eq (second a) :mission-faction-present) (eq (second a) :mission-faction-delayed))) t nil)) (faction-list mission)) do (pushnew game-event-id (game-events level)))) (defun update-visibility-after-creation (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Update visibility") (loop for mob-id in (mob-id-list level) for mob = (get-mob-by-id mob-id) do (update-visible-mobs mob))) (defun remove-dungeon-gen-functions (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Remove dungeon generation features") (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (get-feature-type-trait lvl-feature +feature-trait-remove-on-dungeon-generation+) do (remove-feature-from-level-list level lvl-feature))) ;;======================= ;; Major Placement funcs ;;======================= (defun place-player-on-level (level world-sector mission world) (log:info "Placing player") (loop for overall-post-process-func in (funcall (overall-post-process-func-list (get-level-modifier-by-id (player-lvl-mod-placement-id mission)))) do (funcall overall-post-process-func level world-sector mission world))) (defun place-ai-demons-on-level (level world-sector mission world) (multiple-value-bind (year month day hour min sec) (get-current-date-time (world-game-time world)) (declare (ignore year month day min sec)) (let ((demon-list (if (and (>= hour 7) (< hour 19)) (list (list +mob-type-archdemon+ 2 nil) (list +mob-type-demon+ 15 nil) (list +mob-type-imp+ (+ (random (- *max-imps-number* *min-imps-number*)) *min-imps-number*) nil)) (list (list +mob-type-archdemon+ 1 nil) (list +mob-type-shadow-devil+ 1 nil) (list +mob-type-demon+ 7 nil) (list +mob-type-shadow-demon+ 8 nil) (list +mob-type-imp+ (truncate (+ (random (- *max-imps-number* *min-imps-number*)) *min-imps-number*) 2) nil) (list +mob-type-shadow-imp+ (truncate (+ (random (- *max-imps-number* *min-imps-number*)) *min-imps-number*) 2) nil))))) (when (/= (player-lvl-mod-placement-id mission) +lm-placement-demon-malseraph+) (push (list +mob-type-malseraph-puppet+ 1 nil) demon-list)) (place-demons-on-level level world-sector mission world demon-list)))) (defun place-ai-angels-on-level (level world-sector mission world) (let ((angel-list (list (list +mob-type-angel+ *min-angels-number* nil)))) (when (/= (player-lvl-mod-placement-id mission) +lm-placement-angel-trinity+) (push (list +mob-type-star-singer+ 1 nil) angel-list)) (place-angels-on-level level world-sector mission world angel-list))) (defun place-ai-military-on-level (level world-sector mission world) (let ((military-list (list (list (list +mob-type-chaplain+ 1 nil) (list +mob-type-sergeant+ 1 nil) (list +mob-type-scout+ 1 nil) (list +mob-type-soldier+ 3 nil) (list +mob-type-gunner+ 1 nil)) (list (list +mob-type-chaplain+ 1 nil) (list +mob-type-sergeant+ 1 nil) (list +mob-type-scout+ 1 nil) (list +mob-type-soldier+ 3 nil) (list +mob-type-gunner+ 1 nil)) (list (list +mob-type-chaplain+ 1 nil) (list +mob-type-sergeant+ 1 nil) (list +mob-type-scout+ 1 nil) (list +mob-type-soldier+ 3 nil) (list +mob-type-gunner+ 1 nil)) (list (list +mob-type-chaplain+ 1 nil) (list +mob-type-sergeant+ 1 nil) (list +mob-type-scout+ 1 nil) (list +mob-type-soldier+ 3 nil) (list +mob-type-gunner+ 1 nil))))) (place-military-on-level level world-sector mission world military-list t)) ) (defun place-ai-ghost-on-level (level world-sector mission world) (declare (ignore world-sector world)) (when (and (/= (player-lvl-mod-placement-id mission) +lm-placement-ghost+) (find-if #'(lambda (a) (if (and (= (first a) +faction-type-ghost+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission))) (populate-level-with-mobs level (list (list +mob-type-ghost+ 1 nil)) #'find-unoccupied-place-inside)) ) (defun place-ai-primordial-on-level (level world-sector mission world) (declare (ignore world world-sector)) (when (and (/= (player-lvl-mod-placement-id mission) +lm-placement-eater+) (/= (player-lvl-mod-placement-id mission) +lm-placement-skinchanger+) (find-if #'(lambda (a) (if (and (= (first a) +faction-type-eater+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission))) (populate-level-with-mobs level (if (zerop (random 2)) (list (list +mob-type-eater-of-the-dead+ 1 nil)) (list (list +mob-type-skinchanger-melee+ 1 nil))) #'find-unoccupied-place-water)) ) (defun place-mass-primordials-on-level (level world-sector mission world) (declare (ignore world world-sector mission)) (loop repeat 20 do (populate-level-with-mobs level (if (zerop (random 2)) (list (list +mob-type-eater-of-the-dead+ 1 nil)) (list (list +mob-type-skinchanger-melee+ 1 nil))) #'find-unoccupied-place-water))) (defun place-ai-thief-on-level (level world-sector mission world) (declare (ignore world-sector world)) (when (and (/= (player-lvl-mod-placement-id mission) +specific-faction-type-thief+) (find-if #'(lambda (a) (if (and (= (first a) +faction-type-criminals+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission))) (populate-level-with-mobs level (list (list +mob-type-thief+ 1 nil)) #'find-unoccupied-place-on-top)) ) (defun place-delayed-arrival-points-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) for x = (x lvl-feature) for y = (y lvl-feature) for z = (z lvl-feature) when (= (feature-type lvl-feature) +feature-delayed-military-arrival-point+) do (when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+))) (push (list x y z) (delayed-military-arrival-points level))) when (= (feature-type lvl-feature) +feature-delayed-angels-arrival-point+) do (when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+))) (push (list x y z) (delayed-angels-arrival-points level))) when (= (feature-type lvl-feature) +feature-delayed-demons-arrival-point+) do (when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+))) (push (list x y z) (delayed-demons-arrival-points level))))) (defun setup-turns-for-delayed-arrival (level world-sector mission world) (declare (ignore mission)) (log:info "Set up turns for delayed arrival") ;; set up delayed arrival for demons (setf (turns-for-delayed-demons level) 90) (when (find-campaign-effects-by-id world :campaign-effect-demon-delayed) (incf (turns-for-delayed-demons level) 30)) ;; set up delayed arrival for angels (setf (turns-for-delayed-angels level) 90) (when (find-campaign-effects-by-id world :campaign-effect-angel-hastened) (decf (turns-for-delayed-angels level) 30)) ;; set up delayed arrival for military depending on the distance from the nearest military-controlled sector (let ((first t) (nearest-military-sector nil)) (loop for x from 0 below (array-dimension (cells (world-map world)) 0) do (loop for y from 0 below (array-dimension (cells (world-map world)) 1) do (when (= (controlled-by (aref (cells (world-map world)) x y)) +lm-controlled-by-military+) (when first (setf nearest-military-sector (aref (cells (world-map world)) x y)) (setf first nil)) (when (< (get-distance x y (x world-sector) (y world-sector)) (get-distance (x nearest-military-sector) (y nearest-military-sector) (x world-sector) (y world-sector))) (setf nearest-military-sector (aref (cells (world-map world)) x y)))))) (if nearest-military-sector (setf (turns-for-delayed-military level) (+ 90 (* (truncate (get-distance (x nearest-military-sector) (y nearest-military-sector) (x world-sector) (y world-sector))) 20))) (setf (turns-for-delayed-military level) 130))) ) (defun place-custom-portals (level portal-feature-id &key (map-margin 30) (distance 6) (max-portals 1) (test-mob-free t) (test-repel-demons nil) (move-type +connect-map-move-walk+)) (let ((portals ())) ;; find place for portals (loop with max-x = (- (array-dimension (terrain level) 0) (* map-margin 2)) with max-y = (- (array-dimension (terrain level) 1) (* map-margin 2)) for free-place = t with z = 2 for x = (+ (random max-x) map-margin) for y = (+ (random max-y) map-margin) while (< (length portals) max-portals) do (check-surroundings x y t #'(lambda (dx dy) (when (or (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move+) (not (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move-floor+)) (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-water+)) (setf free-place nil)))) (when (and free-place (/= (get-level-connect-map-value level x y z 1 move-type) +connect-room-none+) (not (find (list x y 2) portals :test #'(lambda (a b) (if (< (get-distance-3d (first a) (second a) (third a) (first b) (second b) (third b)) distance) t nil) ))) ;; test if the portal dst place has no mob (if (or (null test-mob-free) (not (get-mob-* level x y z))) t nil) ;; test if the portal dst place is far from repel-demons feature (if (or (null test-repel-demons) (loop for feature-id in (feature-id-list level) for feature = (get-feature-by-id feature-id) with result = t when (and (= (feature-type feature) +feature-start-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist*)) do (setf result nil) (loop-finish) when (and (= (feature-type feature) +feature-start-strong-repel-demons+) (< (get-distance x y (x feature) (y feature)) *repel-demons-dist-strong*)) do (setf result nil) (loop-finish) finally (return result))) t nil) ) (push (list x y z) portals))) ;; place portals (loop for (x y z) in portals do ;;(format t "PLACE PORTAL ~A AT (~A ~A ~A)~%" (name (get-feature-type-by-id portal-feature-id)) x y z) (add-feature-to-level-list level (make-instance 'feature :feature-type portal-feature-id :x x :y y :z z))) portals)) (defun place-demonic-portals (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Placing demonic portals") ;; remove standard demon arrival points (loop for feature-id in (feature-id-list level) for lvl-feature = (get-feature-by-id feature-id) when (= (feature-type lvl-feature) +feature-start-place-demons+) do (remove-feature-from-level-list level lvl-feature)) ;; add portals (let ((portals ())) (setf portals (place-custom-portals level +feature-demonic-portal+ :max-portals 6 :distance 10 :test-mob-free t :test-repel-demons t)) (loop for (x y z) in portals do (add-feature-to-level-list level (make-instance 'feature :feature-type +feature-start-place-demons+ :x x :y y :z z))))) ;;======================= ;; Minor Placement funcs ;;======================= (defun place-mobs-on-level-immediate (level &key start-point-list create-player mob-list no-center) (loop for (mob-type mob-number is-player) in mob-list do (loop repeat mob-number do (loop with arrival-point-list = (copy-list start-point-list) with mob = (cond ((and is-player create-player) (make-instance 'player :mob-type mob-type)) ((and is-player (not create-player)) (progn (setf (player-outside-level *player*) nil) *player*)) (t (make-instance 'mob :mob-type mob-type))) while (> (length arrival-point-list) 0) for random-arrival-point = (nth (random (length arrival-point-list)) arrival-point-list) for x = (first random-arrival-point) for y = (second random-arrival-point) for z = (third random-arrival-point) do (setf arrival-point-list (remove random-arrival-point arrival-point-list)) (when is-player (setf *player* mob)) (find-unoccupied-place-around level mob x y z :no-center no-center) (loop-finish))))) (defun place-demons-on-level (level world-sector mission world demon-list) (declare (ignore world world-sector)) (log:info "Place demons function") (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-demons+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission)) (log:info " Place present demons") (place-mobs-on-level-immediate level :start-point-list (loop for lvl-feature-id in (remove-if-not #'(lambda (a) (eql (feature-type (get-feature-by-id a)) +feature-start-place-demons+)) (feature-id-list level)) for lvl-feature = (get-feature-by-id lvl-feature-id) collect (list (x lvl-feature) (y lvl-feature) (z lvl-feature))) :create-player t :mob-list demon-list :no-center t)) (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-demons+) (eq (second a) :mission-faction-delayed)) t nil)) (faction-list mission)) (log:info " Add game event for delayed demons") (pushnew +game-event-delayed-arrival-demons+ (game-events level)) ;; add a player to game but do not add him to the level (when (or (= (player-lvl-mod-placement-id mission) +lm-placement-demon-malseraph+) (= (player-lvl-mod-placement-id mission) +lm-placement-demon-crimson+) (= (player-lvl-mod-placement-id mission) +lm-placement-demon-shadow+)) (loop for (mob-type-id mob-num is-player) in demon-list do (when is-player (log:info " Add delayed player to the game") (setf *player* (make-instance 'player :mob-type mob-type-id)) (setf (player-outside-level *player*) t)))) ) ) (defun place-angels-on-level-immediate (level &key start-point-list create-player angel-list) (loop for (angel-type angel-number is-player) in angel-list do (loop repeat angel-number do (if (or (= angel-type +mob-type-star-singer+) (= angel-type +mob-type-star-gazer+) (= angel-type +mob-type-star-mender+)) (progn (log:info " Place trinity mimics") (loop with is-free = t with mob1 = (cond ((and is-player create-player) (make-instance 'player :mob-type +mob-type-star-singer+)) ((and is-player (not create-player)) (progn (setf (player-outside-level *player*) nil) *player*)) (t (make-instance 'mob :mob-type +mob-type-star-singer+))) with mob2 = (cond ((and is-player create-player) (make-instance 'player :mob-type +mob-type-star-gazer+)) ((and is-player (not create-player)) (get-mob-by-id (second (mimic-id-list *player*)))) (t (make-instance 'mob :mob-type +mob-type-star-gazer+))) with mob3 = (cond ((and is-player create-player) (make-instance 'player :mob-type +mob-type-star-mender+)) ((and is-player (not create-player)) (get-mob-by-id (third (mimic-id-list *player*)))) (t (make-instance 'mob :mob-type +mob-type-star-mender+))) with arrival-point-list = (copy-list start-point-list) while (> (length arrival-point-list) 0) for random-arrival-point = (nth (random (length arrival-point-list)) arrival-point-list) for x = (first random-arrival-point) for y = (second random-arrival-point) for z = (third random-arrival-point) do (setf arrival-point-list (remove random-arrival-point arrival-point-list)) (setf is-free t) (check-surroundings x y t #'(lambda (dx dy) (when (or (not (eq (check-move-on-level mob1 dx dy z) t)) (not (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move-floor+))) (setf is-free nil)))) (when is-free (setf (mimic-id-list mob1) (list (id mob1) (id mob2) (id mob3))) (setf (mimic-id-list mob2) (list (id mob1) (id mob2) (id mob3))) (setf (mimic-id-list mob3) (list (id mob1) (id mob2) (id mob3))) (setf (name mob2) (name mob1) (name mob3) (name mob1)) (setf (alive-name mob2) (alive-name mob1) (alive-name mob3) (alive-name mob1)) (when is-player (setf *player* mob1)) (setf (x mob1) (1- x) (y mob1) (1- y) (z mob1) z) (add-mob-to-level-list level mob1) (setf (x mob2) (1+ x) (y mob2) (1- y) (z mob2) z) (add-mob-to-level-list level mob2) (setf (x mob3) x (y mob3) (1+ y) (z mob3) z) (add-mob-to-level-list level mob3) (loop-finish)))) (progn (log:info " Place chrome angels") (loop with arrival-point-list = (copy-list start-point-list) with angel = (cond ((and is-player create-player) (make-instance 'player :mob-type angel-type)) ((and is-player (not create-player)) (progn (setf (player-outside-level *player*) nil) *player*)) (t (make-instance 'mob :mob-type angel-type))) while (> (length arrival-point-list) 0) for random-arrival-point = (nth (random (length arrival-point-list)) arrival-point-list) for x = (first random-arrival-point) for y = (second random-arrival-point) for z = (third random-arrival-point) do (setf arrival-point-list (remove random-arrival-point arrival-point-list)) (when is-player (setf *player* angel)) (find-unoccupied-place-around level angel x y z :no-center t) (loop-finish)))) ))) (defun place-angels-on-level (level world-sector mission world angel-list) (declare (ignore world-sector world)) (log:info "Place angels function") (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-angels+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission)) (log:info " Place present angels") (place-angels-on-level-immediate level :start-point-list (loop for lvl-feature-id in (remove-if-not #'(lambda (a) (= (feature-type a) +feature-start-place-angels+)) (feature-id-list level) :key #'(lambda (b) (get-feature-by-id b))) for lvl-feature = (get-feature-by-id lvl-feature-id) collect (list (x lvl-feature) (y lvl-feature) (z lvl-feature))) :create-player t :angel-list angel-list)) (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-angels+) (eq (second a) :mission-faction-delayed)) t nil)) (faction-list mission)) (log:info " Add game event for delayed angels") (pushnew +game-event-delayed-arrival-angels+ (game-events level)) ;; add a player to game but do not add him to the level (when (or (= (player-lvl-mod-placement-id mission) +lm-placement-angel-trinity+) (= (player-lvl-mod-placement-id mission) +lm-placement-angel-chrome+)) (loop for (mob-type-id mob-num is-player) in angel-list do (when is-player (if (or (= mob-type-id +mob-type-star-singer+) (= mob-type-id +mob-type-star-gazer+) (= mob-type-id +mob-type-star-mender+)) (progn (let ((mob1 (make-instance 'player :mob-type +mob-type-star-singer+)) (mob2 (make-instance 'player :mob-type +mob-type-star-gazer+)) (mob3 (make-instance 'player :mob-type +mob-type-star-mender+))) (setf (mimic-id-list mob1) (list (id mob1) (id mob2) (id mob3))) (setf (mimic-id-list mob2) (list (id mob1) (id mob2) (id mob3))) (setf (mimic-id-list mob3) (list (id mob1) (id mob2) (id mob3))) (setf (name mob2) (name mob1) (name mob3) (name mob1)) (setf *player* mob1))) (progn (setf *player* (make-instance 'player :mob-type mob-type-id)))) (log:info " Add delayed player to the game") (setf (player-outside-level *player*) t)))) ) ) (defun place-military-on-level (level world-sector mission world military-list remove-arrival-points) (declare (ignore world-sector world)) (log:info "Place military function") ;; if the player is present as a chaplain then we need only three squads (when (and (= (player-lvl-mod-placement-id mission) +lm-placement-military-chaplain+) (> (length military-list) 1)) (setf military-list (remove (first military-list) military-list))) (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-military+) (eq (second a) :mission-faction-present)) t nil)) (faction-list mission)) (log:info " Place present military") (loop for squad-list in military-list do (destructuring-bind (mob-type-id mob-num is-player) (first squad-list) (declare (ignore mob-num)) (let ((leader (if is-player (make-instance 'player :mob-type mob-type-id) (make-instance 'mob :mob-type mob-type-id)))) (loop with arrival-point-list = (remove-if-not #'(lambda (a) (= (feature-type a) +feature-start-place-military+)) (feature-id-list level) :key #'(lambda (b) (get-feature-by-id b))) while (> (length arrival-point-list) 0) for random-arrival-point-id = (nth (random (length arrival-point-list)) arrival-point-list) for lvl-feature = (get-feature-by-id random-arrival-point-id) for x = (x lvl-feature) for y = (y lvl-feature) for z = (z lvl-feature) do (setf arrival-point-list (remove random-arrival-point-id arrival-point-list)) (when is-player (setf *player* leader)) (find-unoccupied-place-around level leader x y z) (when remove-arrival-points (remove-feature-from-level-list level lvl-feature) (remove-feature-from-world lvl-feature)) (loop-finish)) (setf squad-list (remove (first squad-list) squad-list)) (when squad-list (populate-level-with-mobs level squad-list #'(lambda (level mob) (find-unoccupied-place-around level mob (x leader) (y leader) (z leader))))))) ) ) (when (find-if #'(lambda (a) (if (and (= (first a) +faction-type-military+) (eq (second a) :mission-faction-delayed)) t nil)) (faction-list mission)) (log:info " Add game event for delayed military") (pushnew +game-event-delayed-arrival-military+ (game-events level)) ;; add a player to game but do not add him to the level (when (or (= (player-lvl-mod-placement-id mission) +lm-placement-military-chaplain+) (= (player-lvl-mod-placement-id mission) +lm-placement-military-scout+)) (loop for squad-list in military-list do (destructuring-bind (mob-type-id mob-num is-player) (first squad-list) (declare (ignore mob-num)) (when is-player (log:info " Add delayed player to the game") (setf *player* (make-instance 'player :mob-type mob-type-id)) (setf (player-outside-level *player*) t))))) ) ) (defun place-demonic-runes-on-level (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Place demonic runes") (let ((demonic-runes ()) (rune-list (list +feature-demonic-rune-flesh+ +feature-demonic-rune-flesh+ +feature-demonic-rune-invite+ +feature-demonic-rune-invite+ +feature-demonic-rune-away+ +feature-demonic-rune-away+ +feature-demonic-rune-transform+ +feature-demonic-rune-transform+ +feature-demonic-rune-barrier+ +feature-demonic-rune-barrier+ +feature-demonic-rune-all+ +feature-demonic-rune-all+ +feature-demonic-rune-decay+ +feature-demonic-rune-decay+))) (loop with max-x = (array-dimension (terrain level) 0) with max-y = (array-dimension (terrain level) 1) with max-z = (array-dimension (terrain level) 2) with cur-rune = 0 for x = (random max-x) for y = (random max-y) for z = (random max-z) while (< (length demonic-runes) (length rune-list)) do (when (and (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-can-have-rune+) (null (find (list x y z) demonic-runes :test #'(lambda (a b) (if (< (get-distance-3d (first a) (second a) (third a) (first b) (second b) (third b)) 6) t nil) )))) (push (list x y z (nth cur-rune rune-list)) demonic-runes) (incf cur-rune))) (loop for (x y z feature-type-id) in demonic-runes do ;;(format t "PLACE RUNE ~A AT (~A ~A ~A)~%" (name (get-feature-type-by-id feature-type-id)) x y z) (add-feature-to-level-list level (make-instance 'feature :feature-type feature-type-id :x x :y y :z z))))) (defun add-lose-and-win-coditions-to-level (level world-sector mission world) (declare (ignore world-sector world)) ;; make the game continue even after the players dies (push +game-event-player-died+ (game-events level)) (when (/= (player-lvl-mod-placement-id mission) +specific-faction-type-player+) (setup-win-conditions mission level))) (defun set-up-inital-power (level world-sector mission world) (declare (ignore mission)) (log:info "Set up power for demons and angels") (let ((demon-power 0) (angel-power 0)) ;; in hell, demon always start with at least 2 (when (world-sector-hell-p world-sector) (incf demon-power 2)) ;; if the relic is captured, add 1 to demons ;; if the relic is in church, add 1 to angels (loop for dx from 0 below (array-dimension (cells (world-map world)) 0) do (loop for dy from 0 below (array-dimension (cells (world-map world)) 1) do (when (and (world-sector-normal-p (aref (cells (world-map world)) dx dy)) (find +lm-feat-church+ (feats (aref (cells (world-map world)) dx dy)) :key #'(lambda (a) (first a))) (find +lm-item-holy-relic+ (items (aref (cells (world-map world)) dx dy)))) (incf angel-power 1)) (when (and (world-sector-corrupted-p (aref (cells (world-map world)) dx dy)) (find +lm-item-holy-relic+ (items (aref (cells (world-map world)) dx dy)))) (incf demon-power 1)))) (loop for mob-id in (mob-id-list level) for mob = (get-mob-by-id mob-id) when (and (mob-ability-p mob +mob-abil-demon+) (eql (faction mob) +faction-type-demons+)) do (setf (cur-fp mob) demon-power) (when (> (cur-fp mob) (max-fp mob)) (setf (cur-fp mob) (max-fp mob))) when (and (mob-ability-p mob +mob-abil-angel+) (eql (faction mob) +faction-type-angels+)) do (setf (cur-fp mob) angel-power) (when (> (cur-fp mob) (max-fp mob)) (setf (cur-fp mob) (max-fp mob)))))) (defun remove-signal-flares-from-military (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Remove flares") (loop for mob-id in (mob-id-list level) for mob = (get-mob-by-id mob-id) when (eq (faction mob) +faction-type-military+) do (loop for item in (get-inv-items-by-type (inv mob) +item-type-signal-flare+) do (setf (inv mob) (remove-from-inv item (inv mob)))) ) ) (defun add-bombs-to-military (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Add bombs") (loop for mob-id in (mob-id-list level) for mob = (get-mob-by-id mob-id) when (eq (faction mob) +faction-type-military+) do (mob-pick-item mob (make-instance 'item :item-type +item-type-bomb+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) (mob-pick-item mob (make-instance 'item :item-type +item-type-bomb+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) (mob-pick-item mob (make-instance 'item :item-type +item-type-bomb+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) ) ) (defun add-disguises-to-satanists (level world-sector mission world) (declare (ignore world-sector mission world)) (log:info "Add disguises to satanists") (loop for mob-id in (mob-id-list level) for mob = (get-mob-by-id mob-id) when (eq (faction mob) +faction-type-satanists+) do (mob-pick-item mob (make-instance 'item :item-type +item-type-disguise+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) (mob-pick-item mob (make-instance 'item :item-type +item-type-disguise+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) (mob-pick-item mob (make-instance 'item :item-type +item-type-disguise+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t) (mob-pick-item mob (make-instance 'item :item-type +item-type-medkit+ :x (x mob) :y (y mob) :z (z mob) :qty 1) :spd nil :silent t)))
42,901
Common Lisp
.lisp
662
45.649547
226
0.530031
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
104f9693b6d9bb318a6c0a3d084b191b566e74b3bbf3f724105ab5acf913427d
2,874
[ -1 ]
2,875
save-load-game.lisp
gwathlobal_CotD/src/save-load-game.lisp
(in-package :cotd) (defparameter *save-version* 1) (defenum:defenum save-game-type-enum (:save-game-campaign :save-game-scenario)) (defenum:defenum save-type-enum (:save-campaign :save-scenario)) (defclass serialized-game () ((save-type :initform :save-scenario :initarg :save-type :accessor serialized-game/save-type :type save-type-enum) (world :initform *world* :initarg :world :accessor serialized-game/world :type world) (mobs :initform *mobs* :initarg :mobs :accessor serialized-game/mobs :type array) (items :initform *items* :initarg :items :accessor serialized-game/items :type array) (lvl-features :initform *lvl-features* :initarg :lvl-features :accessor serialized-game/lvl-features :type array) (effects :initform *effects* :initarg :effects :accessor serialized-game/effects :type array) (player-name :initform *player-name* :initarg :player-name :accessor serialized-game/player-name :type string) (player-title :initform *player-title* :initarg :player-title :accessor serialized-game/player-title :type string))) (defclass serialized-save-descr () ((id :initarg :id :accessor serialized-save-descr/id :type fixnum) (player-name :initarg :player-name :accessor serialized-save-descr/player-name :type string) (sector-name :initarg :sector-name :accessor serialized-save-descr/sector-name :type string) (mission-name :initarg :mission-name :accessor serialized-save-descr/mission-name :type string) (save-date :initarg :save-date :accessor serialized-save-descr/save-date :type fixnum) (world-date-str :initarg :world-date-str :accessor serialized-save-descr/world-date-str :type fixnum) (params :initarg :params :accessor serialized-save-descr/params :type list))) (defun validate-serialized-game (serialized-game &optional pathname) (loop for slot-name in '(save-type world mobs items lvl-features effects player-name player-title) when (null (slot-boundp serialized-game slot-name)) do (log:error "Invalid saved game loaded, pathname: ~A." pathname) (return-from validate-serialized-game nil)) t) (defun validate-serialized-descr (serialized-descr &optional pathname) (loop for slot-name in '(id player-name sector-name mission-name save-date world-date-str params) when (null (slot-boundp serialized-descr slot-name)) do (log:error "Invalid save description loaded, pathname: ~A." pathname) (return-from validate-serialized-descr nil)) t) (declaim (ftype (function (save-game-type-enum) pathname) find-save-game-paths)) (defun find-save-game-path (save-game-type) (declare (type save-game-type-enum save-game-type)) (let ((pathname-middle-section (case save-game-type (:save-game-campaign *campaign-saves-pathlist*) (:save-game-scenario *scenario-saves-pathlist*)))) (merge-pathnames (make-pathname :directory (append '(:relative) pathname-middle-section)) *current-dir*))) (declaim (ftype (function (save-game-type-enum) list) find-all-save-game-paths)) (defun find-all-save-game-paths (save-game-type) (declare (type save-game-type-enum save-game-type)) (directory (merge-pathnames (make-pathname :directory '(:relative :wild)) (find-save-game-path save-game-type))) ) (declaim (ftype (function (save-game-type-enum save-type-enum) null) save-game-to-disk)) (defun save-game-to-disk (save-game-type save-type) (declare (type save-game-type-enum save-game-type) (type save-type-enum save-type)) ;; if the save slot is not set, find all saves to determine the id of the next save slot (when (not (game-manager/game-slot-id *game-manager*)) (loop with save-slots = () for pathname in (find-all-save-game-paths save-game-type) for last-dir = (nth (1- (length (pathname-directory pathname))) (pathname-directory pathname)) for final-num = nil do (handler-case (setf final-num (parse-integer (string-left-trim *save-final-base-dirname* last-dir))) (t (c) (log:error "~A in ~A does not end with an integer - ignored. Error: ~A" last-dir pathname c))) (when final-num (push final-num save-slots)) finally ;; find a free save slot id (loop with n = 0 while (find n save-slots) do (incf n) finally (setf (game-manager/game-slot-id *game-manager*) n)))) (handler-case (let* ((final-save-name (format nil "~A~A" *save-final-base-dirname* (game-manager/game-slot-id *game-manager*))) (dir-pathname (merge-pathnames (make-pathname :directory `(:relative ,final-save-name)) (find-save-game-path save-game-type))) (descr-file-pathname (merge-pathnames (make-pathname :name *save-descr-filename*) dir-pathname)) (game-file-pathname (merge-pathnames (make-pathname :name *save-game-filename*) dir-pathname)) (serialized-game (make-instance 'serialized-game :save-type save-type)) (serialized-save-descr (make-instance 'serialized-save-descr :id (game-manager/game-slot-id *game-manager*) :player-name (if (and *player-name* *player-title*) (format nil "~A the ~A" *player-name* *player-title*) (options-player-name *options*)) :sector-name (if (and (level *world*) (or (eql (game-manager/game-state *game-manager*) :game-state-campaign-scenario) (eql (game-manager/game-state *game-manager*) :game-state-custom-scenario))) (name (world-sector (level *world*))) nil) :mission-name (if (and (level *world*) (or (eql (game-manager/game-state *game-manager*) :game-state-campaign-scenario) (eql (game-manager/game-state *game-manager*) :game-state-custom-scenario))) (name (mission (level *world*))) nil) :save-date (get-universal-time) :world-date-str (format nil "Game Time: ~A~A" (show-date-time-ymd (world-game-time *world*)) (if (eql save-type :save-scenario) (format nil ", T: ~A" (player-game-time (level *world*))) "")) :params (list :version *save-version*)))) (ensure-directories-exist dir-pathname) (cl-store:store serialized-save-descr descr-file-pathname) (cl-store:store serialized-game game-file-pathname)) (t (c) (log:error "Error occured while saving to file: ~A" c))) nil ) (declaim (ftype (function (pathname) (or null serialized-save-descr)) load-descr-from-disk)) (defun load-descr-from-disk (descr-pathname) (declare (type pathname descr-pathname)) (let ((saved-descr nil)) (handler-case (if (probe-file descr-pathname) (setf saved-descr (cl-store:restore descr-pathname)) (progn (log:error "No file ~A to read the save description from." descr-pathname) nil)) (t (c) (log:error "Error occured while reading the save description from file ~A: ~A." descr-pathname c) nil)) (when saved-descr (unless (validate-serialized-descr saved-descr descr-pathname) (setf saved-descr nil))) saved-descr)) (declaim (ftype (function (pathname) (or null serialized-game)) load-game-from-disk)) (defun load-game-from-disk (game-pathname) (declare (type pathname game-pathname)) (let ((saved-game nil)) (handler-case (if (probe-file game-pathname) (setf saved-game (cl-store:restore game-pathname)) (progn (log:error "No file ~A to read the saved game from." game-pathname) nil)) (t (c) (log:error "Error occured while reading the saved game from file ~A: ~A." game-pathname c) nil)) (when saved-game (unless (validate-serialized-game saved-game game-pathname) (setf saved-game nil))) (when saved-game (with-slots (world mobs items lvl-features effects player-name player-title) saved-game (setf *world* world) (setf *mobs* mobs) (setf *items* items) (setf *lvl-features* lvl-features) (setf *effects* effects) (setf *player-name* player-name) (setf *player-title* player-title) (setf *player* (find 'player *mobs* :key #'(lambda (a) (type-of a)))))) saved-game)) (declaim (ftype (function (pathname) (or null t)) delete-descr-from-disk)) (defun delete-descr-from-disk (descr-pathname) (declare (type pathname descr-pathname)) (handler-case (if (probe-file descr-pathname) (delete-file descr-pathname) (progn (log:error "No file ~A to remove the saved description." descr-pathname) nil)) (t (c) (log:error "Error occured while deleting the saved description from file ~A: ~A." descr-pathname c) nil))) (declaim (ftype (function (pathname) (or null t)) delete-game-from-disk)) (defun delete-game-from-disk (game-pathname) (declare (type pathname game-pathname)) (handler-case (if (probe-file game-pathname) (delete-file game-pathname) (progn (log:error "No file ~A to remove the saved game." game-pathname) nil)) (t (c) (log:error "Error occured while deleting the saved game from file ~A: ~A." game-pathname c) nil))) (declaim (ftype (function (pathname) (or null t)) delete-dir-from-disk)) (defun delete-dir-from-disk (dir-pathname) (declare (type pathname dir-pathname)) (handler-case (if (probe-file dir-pathname) (uiop:delete-directory-tree dir-pathname :validate t) (progn (log:error "No directory ~A to remove." dir-pathname) nil)) (t (c) (log:error "Error occured while deleting the directory ~A: ~A." dir-pathname c) nil)))
11,500
Common Lisp
.lisp
202
41.747525
154
0.569565
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
9d9225b31b4c6ae7416274b70828b3ea74ffe46f0ddd197c72c9d2d619c9de1f
2,875
[ -1 ]
2,876
astar.lisp
gwathlobal_CotD/src/astar.lisp
;; by Thomas Daniel Lowe, dlowe@bitmuse.com ;; edited by Gwathlobal (in-package :cotd) (defstruct node (x-pos 0 :type fixnum) (y-pos 0 :type fixnum) (z-pos 0 :type fixnum) (parent nil) (g-val 0) (f-val 0)) (defvar *h-func*) (defun make-new-node (parent x y z end-x end-y end-z g-val) (declare (type fixnum x y z end-x end-y end-z)) (make-node :x-pos x :y-pos y :z-pos z :parent parent :g-val (if parent (+ (node-g-val parent) g-val) 0) :f-val (+ (if parent (+ (node-g-val parent) g-val) 0) (funcall *h-func* x y z end-x end-y end-z)))) (defun pos-equal (node-a node-b) "Returns true if node-a references the same position as node-b. Otherwise, returns NIL." (and (= (node-x-pos node-a) (node-x-pos node-b)) (= (node-y-pos node-a) (node-y-pos node-b)) (= (node-z-pos node-a) (node-z-pos node-b)))) (defun find-node-with-coords (x y z node-list) "Returns the node in NODE-LIST with the coordinates <X, Y, Z>. Returns NIL if no such node was found." (declare (optimize (speed 3) (safety 0)) (type fixnum x y z) (type list node-list)) (find-if (lambda (node) (and (= (node-x-pos node) x) (= (node-y-pos node) y) (= (node-z-pos node) z))) node-list)) (defun a-star (start-coord goal-coord valid-func cost-func) (declare (optimize (speed 3) (safety 0)) (type function valid-func cost-func)) " An implementation of the A* pathfinding algorithm by Daniel Lowe. Given a 2 element list of START-COORD and GOAL-COORD, returns a list of coordinates which form a path between them. VALID-FUNC should return t if a particular node should be considered as part of the path, nil if not. G-FUNC should return the distance of the given path so far. H-FUNC should return an estimate of the distance to the goal, and may depend on many factors" (let* ((open-nodes '()) (closed-nodes '()) (start-node (make-new-node nil (first start-coord) (second start-coord) (third start-coord) (first goal-coord) (second goal-coord) (third goal-coord) (funcall cost-func (first start-coord) (second start-coord) (third start-coord)) )) (goal-node (make-new-node nil (first goal-coord) (second goal-coord) (third goal-coord) (first goal-coord) (second goal-coord) (third goal-coord) (funcall cost-func (first goal-coord) (second goal-coord) (third goal-coord)) ))) (declare (type list open-nodes closed-nodes)) ;; The list of open nodes starts with the beginning coordinate (push start-node open-nodes) ;; Pop open nodes to check until we reach the goal coordinate (loop for node = (first open-nodes) while (and node (not (pos-equal node goal-node))) do (pop open-nodes) ;; Check all the adjacent coordinates. This method counts ;; diagonals as well. If you don't want diagonals, you can ;; change it here, or you can check it with the valid-func (loop for (x-offset y-offset z-offset) of-type (fixnum fixnum fixnum) in '((-1 -1 -1) (-1 0 -1) (-1 1 -1) (0 -1 -1) (0 0 -1) (0 1 -1) (1 -1 -1) (1 0 -1) (1 1 -1) (-1 -1 0) (-1 0 0) (-1 1 0) (0 -1 0) (0 0 0) (0 1 0) (1 -1 0) (1 0 0) (1 1 0) (-1 -1 1) (-1 0 1) (-1 1 1) (0 -1 1) (0 0 1) (0 1 1) (1 -1 1) (1 0 1) (1 1 1)) for x of-type fixnum = (+ (node-x-pos node) x-offset) for y of-type fixnum = (+ (node-y-pos node) y-offset) for z of-type fixnum = (+ (node-z-pos node) z-offset) unless (and (zerop x-offset) (zerop y-offset) (zerop z-offset)) ;; don't need to check already closed nodes unless (find-node-with-coords x y z closed-nodes) ;; don't need to find already open nodes, either unless (find-node-with-coords x y z open-nodes) ;; only check valid coordinates when (funcall valid-func x y z (node-x-pos node) (node-y-pos node) (node-z-pos node)) do (push (make-new-node node x y z (first goal-coord) (second goal-coord) (third goal-coord) (funcall cost-func x y z)) open-nodes)) ;; We exhausted the possibilities of this node, so add it ;; to the closed nodes (push node closed-nodes) ;; If node-f increments steadily, we don't need to do ;; this. However, we can't really count on it in a generic ;; solution. (setf open-nodes (sort open-nodes #'< :key #'node-f-val))) ;; If open-nodes is non-empty, a solution was found. We ;; traverse them in reverse to obtain our path. (when open-nodes (loop for trail = (first open-nodes) then (node-parent trail) until (pos-equal trail start-node) collect (list (node-x-pos trail) (node-y-pos trail) (node-z-pos trail)) into result finally (return (cons start-coord (nreverse result))))))) (defun diagonal (cur-x cur-y end-x end-y) (let* ((dx (abs (- cur-x end-x))) (dy (abs (- cur-y end-y))) (diag (min dx dy)) (straight (+ dx dy))) (+ (* (sqrt 2) diag) (* 1 (- straight (* 2 diag)))))) (defun path-distance (cur-x cur-y cur-z end-x end-y end-z) (declare (type fixnum cur-x cur-y cur-z end-x end-y end-z)) (let ((dx (abs (- cur-x end-x))) (dy (abs (- cur-y end-y))) (dz (abs (- cur-z end-z)))) (+ dx dy dz))) (setf *h-func* #'path-distance)
6,116
Common Lisp
.lisp
113
41.584071
174
0.546324
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e5326dcdf741d7190a42074535e00313c1f99ad7145b7512813b0bfa93c206b4
2,876
[ -1 ]
2,877
cotd.lisp
gwathlobal_CotD/src/cotd.lisp
(in-package :cotd) (defun game-loop () "Main game loop" (loop with turn-finished = t do ;;(format t "GAME-LOOP: Start loop~%") (setf turn-finished t) (log:info "~%REAL-GAME-TURN: ~A~%" (player-game-time (level *world*))) ;; check for the player's win conditions first (when (and *player* (find (loyal-faction *player*) (win-condition-list (get-mission-type-by-id (mission-type-id (mission (level *world*))))) :key #'(lambda (a) (first a))) (funcall (on-check (get-game-event-by-id (second (find (loyal-faction *player*) (win-condition-list (get-mission-type-by-id (mission-type-id (mission (level *world*))))) :key #'(lambda (a) (first a)))))) *world*)) (funcall (on-trigger (get-game-event-by-id (second (find (loyal-faction *player*) (win-condition-list (get-mission-type-by-id (mission-type-id (mission (level *world*))))) :key #'(lambda (a) (first a)))))) *world*)) ;; check all available game events (loop for game-event-id of-type fixnum in (game-events (level *world*)) for game-event of-type game-event = (get-game-event-by-id game-event-id) when (and (not (disabled game-event)) (funcall (on-check game-event) *world*)) do (funcall (on-trigger game-event) *world*)) ;; we need this for events to get triggered only once (setf (turn-finished *world*) nil) (process-animations-on-level (level *world*)) (when (or (check-dead *player*) (master-mob-id *player*) (player-outside-level *player*)) (unless (player-outside-level *player*) (when (master-mob-id *player*) (setf (x *player*) (x (get-mob-by-id (master-mob-id *player*))) (y *player*) (y (get-mob-by-id (master-mob-id *player*))) (z *player*) (z (get-mob-by-id (master-mob-id *player*))))) (update-visible-mobs *player*) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*))) (make-output *current-window*) (pause-for-poll)) ;; iterate through all the mobs ;; those who are not dead and have cur-ap > 0 can make a move (loop for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) do (when (and (not (check-dead mob)) (> (cur-ap mob) 0) (not (is-merged mob))) (setf turn-finished nil) (setf (made-turn mob) nil) (set-message-this-turn nil) (setf (motion-set-p mob) nil) ;; for trinity mimics - set the current mob as the player ;; for split soul - set the current mob as the player (when (or (and (subtypep (type-of mob) 'player) (mob-ability-p mob +mob-abil-trinity-mimic+) (find (id mob) (mimic-id-list *player*))) (and (subtypep (type-of mob) 'player) (mob-effect-p mob +mob-effect-split-soul-target+)) (and (subtypep (type-of mob) 'player) (mob-effect-p mob +mob-effect-split-soul-source+))) (setf *player* mob)) (setf (if-cur-mob-seen-through-shared-vision *player*) (if (mounted-by-mob-id mob) (and (find (mounted-by-mob-id mob) (shared-visible-mobs *player*)) (not (find (mounted-by-mob-id mob) (proper-visible-mobs *player*)))) (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))))) (ai-function mob) (when (get-message-this-turn) (add-message (format nil "~%"))) (setf (heard-sounds mob) nil) ;;(format t "~%TIME-ELAPSED MOB ~A [~A] after AI func finished: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) (update-visible-mobs mob) ;;(format t "~%TIME-ELAPSED AI ~A [~A] after UPDATE-VISIBLE-MOBS: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) (when (eq mob *player*) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*)) (update-map-area *start-map-x* 0) ) ;;(format t "~%TIME-ELAPSED AI ~A [~A] after players' UPDATE-VISIBLE-MOBS (if any): ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) ;; process animations for this turn if any (process-animations-on-level (level *world*)) (when (<= (cur-ap mob) 0) ;;(format t "~%TIME-ELAPSED AI ~A [~A] before ON-TICK: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) (on-tick mob) ;;(format t "~%TIME-ELAPSED AI ~A [~A] after ON-TICK: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) ) (unless *cotd-release* ;; checking for inconsistences between *items* and item-quadrant-map (loop for y from 0 below (array-dimension (item-quadrant-map (level *world*)) 1) do (loop for x from 0 below (array-dimension (item-quadrant-map (level *world*)) 0) do (loop for item-id in (aref (item-quadrant-map (level *world*)) x y) unless (get-item-by-id item-id) do (error (format nil "ITEM ID ~A AT (~A ~A) NIL, FAILED!!!" item-id x y))))) ;; checking for inconsistences between actual number of angels on map and (total-angels *world*) (loop with result = 0 for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) when (and (not (check-dead mob)) (and (mob-ability-p mob +mob-abil-angel+) (not (mob-ability-p mob +mob-abil-animal+)))) do (incf result) ;(loop for merged-id in (merged-id-list mob) ; for merged-mob = (get-mob-by-id merged-id) ; when (and (not (check-dead merged-mob)) ; (and (mob-ability-p merged-mob +mob-abil-angel+) ; (not (mob-ability-p merged-mob +mob-abil-animal+)))) ; do ; (incf result)) finally (when (/= (total-angels (level *world*)) result) (error (format nil "FAILED!!! TOTAL ANGELS = ~A, ACTUAL ANGELS ALIVE = ~A" (total-angels (level *world*)) result))) ) ) )) (bt:with-lock-held ((path-lock *world*)) (when (and *path-thread* (bt:thread-alive-p *path-thread*)) (bt:destroy-thread *path-thread*))) (when turn-finished (incf (player-game-time (level *world*))) (when (check-dead *player*) (incf (world-game-time *world*) +normal-ap+)) (setf (turn-finished *world*) t) (set-message-this-turn nil) (loop for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) do (when (and (not (check-dead mob)) (not (is-merged mob))) ;; increase cur-ap by max-ap (incf (cur-ap mob) (max-ap mob)) ;; tick piety if the mob worships a god (setf (if-cur-mob-seen-through-shared-vision *player*) (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*))))) (when (worshiped-god mob) (funcall (piety-tick-func (get-god-by-id (get-worshiped-god-type (worshiped-god mob)))) (get-god-by-id (get-worshiped-god-type (worshiped-god mob))) mob)))) (loop for feature-id of-type fixnum in (feature-id-list (level *world*)) for feature of-type feature = (get-feature-by-id feature-id) when (and feature (on-tick-func feature)) do (funcall (on-tick-func feature) (level *world*) feature)) (when (zerop (random 3)) (setf (wind-dir (level *world*)) (1+ (random 9)))) (when (get-message-this-turn) (add-message (format nil "~%"))) )) ) (defun init-game (mission world-sector) (setf *mobs* (make-array (list 0) :adjustable t)) (setf *lvl-features* (make-array (list 0) :adjustable t)) (setf *items* (make-array (list 0) :adjustable t)) (setf *cur-angel-names* (copy-list *init-angel-names*)) (setf *cur-demon-names* (copy-list *init-demon-names*)) (setf *cur-human-names* (copy-list *init-human-names*)) (setf *cur-human-surnames* (copy-list *init-human-surnames*)) (setf *update-screen-closure* #'(lambda (str) (when (and str (subtypep (type-of *current-window*) 'loading-window)) (setf (cur-str *current-window*) str)) (make-output *current-window*) )) (let ((sector-level-gen-func (sector-level-gen-func (get-world-sector-type-by-id (wtype world-sector)))) (level-template-pre-process-func-list ()) (overall-post-process-func-list ()) (terrain-post-process-func-list ())) ;; add all funcs from world sector (let ((world-sector-type (get-world-sector-type-by-id (wtype world-sector)))) (when (template-level-gen-func world-sector-type) (setf level-template-pre-process-func-list (append level-template-pre-process-func-list (list (template-level-gen-func world-sector-type))))) (when (overall-post-process-func-list world-sector-type) (setf overall-post-process-func-list (append overall-post-process-func-list (funcall (overall-post-process-func-list world-sector-type))))) (when (terrain-post-process-func-list world-sector-type) (setf terrain-post-process-func-list (append terrain-post-process-func-list (funcall (terrain-post-process-func-list world-sector-type))))) ) ;; add all funcs from level-modifiers ;; sort them by level-modifier priority, to ensure that all template-level reservations are made in the right order (loop with lm-controlled-by = (list (get-level-modifier-by-id (controlled-by world-sector))) with lm-feats = (loop for (lm-feat-id) in (feats world-sector) collect (get-level-modifier-by-id lm-feat-id)) with lm-item = (loop for lm-item-id in (items world-sector) collect (get-level-modifier-by-id lm-item-id)) with sorted-lvl-mod-list = (stable-sort (append lm-controlled-by lm-feats lm-item) #'(lambda (a b) (if (< (priority a) (priority b)) t nil))) for lvl-mod in sorted-lvl-mod-list do (when (template-level-gen-func lvl-mod) (setf level-template-pre-process-func-list (append level-template-pre-process-func-list (list (template-level-gen-func lvl-mod))))) (when (overall-post-process-func-list lvl-mod) (setf overall-post-process-func-list (append overall-post-process-func-list (funcall (overall-post-process-func-list lvl-mod))))) (when (terrain-post-process-func-list lvl-mod) (setf terrain-post-process-func-list (append terrain-post-process-func-list (funcall (terrain-post-process-func-list lvl-mod)))))) ;; add all level modifiers from the mission (loop for lvl-mod-id in (level-modifier-list mission) for lvl-mod = (get-level-modifier-by-id lvl-mod-id) do (when (template-level-gen-func lvl-mod) (setf level-template-pre-process-func-list (append level-template-pre-process-func-list (list (template-level-gen-func lvl-mod))))) (when (overall-post-process-func-list lvl-mod) (setf overall-post-process-func-list (append overall-post-process-func-list (funcall (overall-post-process-func-list lvl-mod))))) (when (terrain-post-process-func-list lvl-mod) (setf terrain-post-process-func-list (append terrain-post-process-func-list (funcall (terrain-post-process-func-list lvl-mod)))))) ;; add all funcs from mission (let ((mission-type (get-mission-type-by-id (mission-type-id mission)))) (when (template-level-gen-func mission-type) (setf level-template-pre-process-func-list (append level-template-pre-process-func-list (list (template-level-gen-func mission-type))))) (when (overall-post-process-func-list mission-type) (setf overall-post-process-func-list (append overall-post-process-func-list (funcall (overall-post-process-func-list mission-type))))) (when (terrain-post-process-func-list mission-type) (setf terrain-post-process-func-list (append terrain-post-process-func-list (funcall (terrain-post-process-func-list mission-type))))) ) (generate-level-from-sector sector-level-gen-func :level-template-pre-process-func-list level-template-pre-process-func-list :overall-post-process-func-list overall-post-process-func-list :terrain-level-post-process-func-list terrain-post-process-func-list :world-sector world-sector :mission mission :world *world*) ) (when (player-specific-faction mission) (setf *previous-scenario* (list (mission-type-id mission) (player-specific-faction mission)))) (clear-message-list (level/full-message-box (level *world*))) (clear-message-list (level/small-message-box (level *world*))) ;;(format t "FACTION-LIST ~A~%" faction-list) (setf (name *player*) "Player") (add-message (format nil "This is a ")) (add-message (format nil "~(~A~)" (name mission)) sdl:*yellow*) (add-message (format nil " in ")) (add-message (format nil "~(~A~)" (name (get-world-sector-type-by-id (wtype world-sector)))) sdl:*yellow*) (add-message (format nil "!~%~%To view help, press '?'.~%To view your current objective, press 'j'.~%")) (when (player-outside-level *player*) (add-message (format nil "~%Your arrival here is delayed, please wait!~%"))) ) (defun main-menu () (setf *current-window* (make-instance 'main-menu-window)) (make-output *current-window*) (run-window *current-window*)) (defun cotd-init () (let ((tiles-path)) ;; create default options (setf *options* (make-options :tiles 'large)) ;; get options from file if possible (if (probe-file (merge-pathnames "options.cfg" *current-dir*)) (progn (with-open-file (file (merge-pathnames "options.cfg" *current-dir*) :direction :input) (handler-case (loop for s-expr = (read file nil) while s-expr do (read-options s-expr *options*)) (t (c) (log:error "OPTIONS.CFG: Error occured while reading the options.cfg: ~A. Overwriting with defaults.~%" c) (with-open-file (file (merge-pathnames "options.cfg" *current-dir*) :direction :output :if-exists :supersede) (format file "~A" (create-options-file-string *options*))))))) (progn (with-open-file (file (merge-pathnames "options.cfg" *current-dir*) :direction :output) (format file "~A" (create-options-file-string *options*)))) ) ;; set parameters depending on options ;; tiles (cond (t (setf *glyph-w* 15 *glyph-h* 15 tiles-path "data/font_large.bmp"))) ;; font (cond ((equal (options-font *options*) 'font-6x13) (sdl:initialise-default-font sdl:*font-6x13*)) (t (sdl:initialise-default-font sdl:*font-8x13*))) ;; name (cond ((options-player-name *options*) nil) (t (setf (options-player-name *options*) "Player"))) ;; create default highscores (setf *highscores* (make-instance 'highscores-table)) (load-highscores-from-disk) (truncate-highscores *highscores*) (setf *msg-box-window-height* (* (sdl:get-font-height) 8)) (setf *random-state* (make-random-state t)) (setf *window-width* (+ 540 (+ 30 (* *glyph-w* *max-x-view*))) *window-height* (+ 30 (* *glyph-h* *max-y-view*) *msg-box-window-height* (* 3 (sdl:char-height sdl:*default-font*)))) (when (<= *window-height* 384) (incf *window-height* (+ (* 6 (sdl:char-height sdl:*default-font*)) 0))) (sdl:window *window-width* *window-height* :title-caption "The City of the Damned" :icon-caption "The City of the Damned") (sdl:enable-key-repeat nil nil) (sdl:enable-unicode) (setf *temp-rect* (sdl::rectangle-from-edges-* 0 0 *glyph-w* *glyph-h*)) (log:info "current-dir = ~A" *current-dir*) (log:info "path = ~A" (sdl:create-path tiles-path *current-dir*)) (setf *glyph-front* (sdl:load-image (sdl:create-path tiles-path *current-dir*) :color-key sdl:*white*)) (setf *glyph-temp* (sdl:create-surface *glyph-w* *glyph-h* :color-key sdl:*black*)) (setf *path-thread* nil) (setf *previous-scenario* nil) (setf *game-manager* (make-instance 'game-manager)) (game-state-start->init))) (defun stop-path-thread () (when (and *path-thread* (bt:thread-alive-p *path-thread*)) (bt:destroy-thread *path-thread*))) (defun enter-player-name () (sdl:with-rectangle (a-rect (sdl:rectangle :x 0 :y 0 :w *window-width* :h *window-height*)) (sdl:fill-surface sdl:*black* :template a-rect)) ;; let player enter his\her name (setf *current-window* (make-instance 'input-str-window :init-input (options-player-name *options*) :header-str "Choose name" :main-str "Enter you name" :prompt-str "[Enter] Confirm" :all-func nil :no-escape t :input-check-func #'(lambda (char cur-str) (if (and (not (null char)) (or (find (string-downcase (string char)) *char-list* :test #'string=) (char= char #\Space) (char= char #\-)) (< (length cur-str) *max-player-name-length*)) t nil)) :final-check-func #'(lambda (full-input-str) (if (not (null full-input-str)) t nil)) )) (make-output *current-window*) (setf (options-player-name *options*) (run-window *current-window*)) (setf *player-name* (options-player-name *options*))) (defun prepare-game-scenario (mission world-sector) (setf *current-window* (make-instance 'loading-window :update-func #'(lambda (win) (when (/= *max-progress-bar* 0) (let ((str (format nil "~A... ~3D%" (cur-str win) (truncate (* 100 *cur-progress-bar*) *max-progress-bar*)))) (sdl:draw-string-solid-* str (truncate (- (/ *window-width* 2) (/ (* (length str) (sdl:char-width sdl:*default-font*)) 2))) (truncate (- (/ *window-height* 2) (/ (sdl:char-height sdl:*default-font*) 2))) :color sdl:*white*)) )))) (init-game mission world-sector) ;; initialize thread, that will calculate random-movement paths while the system waits for player input (handler-case (setf *path-thread* (bt:make-thread #'(lambda () (thread-path-loop)) :name "Pathing thread")) (t (c) (log:error "MAIN: This system does not support multithreading! Error: ~A~%" c))) (bt:condition-notify (path-cv *world*)) ;; set the same name for mimics if any (setf (name *player*) *player-name*) (setf (alive-name *player*) (name *player*)) (when (mob-ability-p *player* +mob-abil-trinity-mimic+) (loop for mob-id in (mimic-id-list *player*) for mob = (get-mob-by-id mob-id) do (setf (name mob) (name *player*)) (setf (alive-name mob) (alive-name *player*)))) (with-open-file (file (merge-pathnames "options.cfg" *current-dir*) :direction :output :if-exists :supersede) (format file "~A" (create-options-file-string *options*)))) (defun scenario-game-loop () (setf *current-window* (make-instance 'cell-window)) (make-output *current-window*) ;; the game loop (game-loop)) (defun campaign-game-loop () (setf *current-window* (make-instance 'campaign-window :cur-mode (case (game-manager/game-state *game-manager*) (:game-state-campaign-init :campaign-window-map-mode) (t (if (and (zerop (message-list-length (world/mission-message-box *world*))) (zerop (message-list-length (world/event-message-box *world*))) (zerop (message-list-length (world/effect-message-box *world*)))) :campaign-window-mission-mode :campaign-window-status-mode))) :reveal-lair (if (or (eq (get-general-faction-from-specific (world/player-specific-faction *world*)) +faction-type-demons+) (find-campaign-effects-by-id *world* :campaign-effect-satanist-lair-visible)) t nil))) (make-output *current-window*) (multiple-value-bind (mission world-sector) (run-window *current-window*) (when (and mission world-sector) (setf (player-specific-faction mission) (world/player-specific-faction *world*)) (setf (player-lvl-mod-placement-id mission) (second (find (player-specific-faction mission) (scenario-faction-list (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))))) (game-state-campaign-map->campaign-scenario) (prepare-game-scenario mission world-sector) (return-from campaign-game-loop (values world-sector mission))))) (defun process-post-scenario () (with-slots (level world-map random-number) *world* (let ((present-missions (world/present-missions *world*))) ;; add AI commands before mission results are processed (loop for faction-type in (list +faction-type-demons+ +faction-type-angels+ +faction-type-military+ +faction-type-satanists+ +faction-type-church+ +faction-type-eater+) do (when (not (gethash faction-type (world/commands *world*))) (let ((command-hash (make-hash-table)) (selected-command nil)) ;; sort commands by priority (loop for command being the hash-values in *campaign-commands* when (and (eq (campaign-command/faction-type command) faction-type) (funcall (campaign-command/on-check-func command) *world* command)) do (push command (gethash (campaign-command/priority command) command-hash))) ;; select a random command out of the topmost priority list (loop for priority from 10 downto 0 for command-list = (gethash priority command-hash) when command-list do (setf selected-command (nth (random (length command-list)) command-list)) (loop-finish)) (setf (gethash faction-type (world/commands *world*)) (list :command (campaign-command/id selected-command) :cd (campaign-command/cd selected-command)))))) ;; clear results (setf (world/post-mission-results *world*) ()) ;; clear the situation report (clear-message-list (world/mission-message-box *world*)) (clear-message-list (world/event-message-box *world*)) (clear-message-list (world/effect-message-box *world*)) ;; advance one day forward (multiple-value-bind (year month day hour min sec) (get-current-date-time (world-game-time *world*)) (setf (world-game-time *world*) (set-current-date-time year month (1+ day) hour min sec))) ;; add date to the top (add-message (format nil " === ~A ===~%~%" (show-date-time-ymd (world-game-time *world*))) sdl:*white* `(,(world/mission-message-box *world*))) ;; process missions (loop with mission-result = nil for mission in present-missions for world-sector = (aref (cells (world-map *world*)) (x mission) (y mission)) do (if (and level (level/mission-result level) (mission level) (eq mission (mission level))) ;; where the player was present... (progn (setf mission-result (level/mission-result level))) ;; ...and where the player was absent (progn (setf mission-result (auto-resolve-mission *world* mission)) ;; increase world flesh points (when (or (eq (getf mission-result :mission-result) :game-over-demons-won) (eq (getf mission-result :mission-result) :game-over-satanists-won)) (setf (getf mission-result :flesh-points) (truncate (+ 75 (random 50)) 10))))) (case (getf mission-result :mission-result) (:game-over-angels-won (progn (add-message (format nil " - The angels were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*))))) (:game-over-church-won (progn (add-message (format nil " - The priests were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*))))) (:game-over-military-won (progn (add-message (format nil " - The military were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*))))) (:game-over-demons-won (progn (add-message (format nil " - The demons were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*))))) (:game-over-satanists-won (progn (add-message (format nil " - The satanists were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*))))) (:game-over-eater-won (progn (add-message (format nil " - The primordials were victorious during a ") sdl:*white* `(,(world/mission-message-box *world*)))))) (add-message (format nil "~(~A~)" (name mission)) sdl:*yellow* `(,(world/mission-message-box *world*))) (add-message (format nil " in ") sdl:*white* `(,(world/mission-message-box *world*))) (add-message (format nil "~(~A~)" (name world-sector)) sdl:*yellow* `(,(world/mission-message-box *world*))) (add-message (format nil ".") sdl:*white* `(,(world/mission-message-box *world*))) (loop with campaign-mission-result = (find (getf mission-result :mission-result) (mission-type/campaign-result (get-mission-type-by-id (mission-type-id mission))) :key #'(lambda (a) (first a))) for transform-sector-func in (second campaign-mission-result) do (funcall transform-sector-func world-map (x mission) (y mission))) (add-message (format nil "~%") sdl:*white* `(,(world/mission-message-box *world*))) ;; sum all flesh points (unless (getf (world/post-mission-results *world*) :flesh-points) (setf (getf (world/post-mission-results *world*) :flesh-points) 0)) (when (getf mission-result :flesh-points) (incf (getf (world/post-mission-results *world*) :flesh-points) (getf mission-result :flesh-points))) ) (loop for game-event-id in (game-events *world*) for game-event = (get-game-event-by-id game-event-id) when (and (not (disabled game-event)) (funcall (on-check game-event) *world*)) do (funcall (on-trigger game-event) *world*)) (with-slots (campaign-effects) *world* (loop for campaign-effect in campaign-effects when (campaign-effect/cd campaign-effect) do (decf (campaign-effect/cd campaign-effect)) (when (= (campaign-effect/cd campaign-effect) 0) (remove-campaign-effect *world* campaign-effect)))) (when (or (colored-txt-list (message-box-strings (world/event-message-box *world*))) (colored-txt-list (message-box-strings (world/effect-message-box *world*)))) (add-message (format nil "~%") sdl:*white* `(,(world/mission-message-box *world*)))) (when (and (colored-txt-list (message-box-strings (world/event-message-box *world*))) (colored-txt-list (message-box-strings (world/effect-message-box *world*)))) (add-message (format nil "~%") sdl:*white* `(,(world/event-message-box *world*)))) ;; reset all missions and regenerate them (reset-all-missions-on-world-map *world*) ;; regenerate transient feats (loop for x from 0 below (array-dimension (cells (world-map *world*)) 0) do (loop for y from 0 below (array-dimension (cells (world-map *world*)) 1) do (let ((world-sector (aref (cells (world-map *world*)) x y))) (regenerate-transient-feats-for-world-sector world-sector (world-map *world*))))) (generate-missions-on-world-map *world*)) (setf random-number (random 100))) (game-state-post-scenario->campaign-map)) (defmacro handle-errors-to-ui (&body body) `(if *cotd-release* (handler-case (progn ,@body) (t (c) (stop-path-thread) (setf *cotd-logging* :log-option-all) (setf *cotd-log-level* :info) (setup-log) (log:error "~A" c) (setf *current-window* (make-instance 'display-msg-window :msg-line (format nil "ERROR: ~A" c) :w (truncate (* *window-width* 2/3)) :prompt-line "[Esc] Exit")) (make-output *current-window*) (run-window *current-window*) (return-from cotd-main nil))) (progn ,@body))) (defun cotd-main () (in-package :cotd) (setup-log) (log:info "Start program") (sdl:with-init () (handle-errors-to-ui (cotd-init) (tagbody (setf *quit-func* #'(lambda () (when (and *game-manager* *world*) (case (game-manager/game-state *game-manager*) ((:game-state-custom-scenario) (save-game-to-disk :save-game-scenario :save-scenario)) ((:game-state-campaign-scenario) (save-game-to-disk :save-game-campaign :save-scenario)) ((:game-state-campaign-map :game-state-post-scenario) (save-game-to-disk :save-game-campaign :save-campaign)))) (go quit-menu-tag))) (setf *start-func* #'(lambda () (go start-game-tag))) (game-state-init->menu) start-game-tag (loop while t do (case (game-manager/game-state *game-manager*) (:game-state-main-menu (progn (stop-path-thread) (with-slots (game-slot-id) *game-manager* (setf game-slot-id nil)) (main-menu))) ((:game-state-custom-scenario) (scenario-game-loop)) ((:game-state-campaign-map :game-state-campaign-init) (campaign-game-loop)) ((:game-state-campaign-scenario) (scenario-game-loop)) (:game-state-post-scenario (process-post-scenario)))) quit-menu-tag (stop-path-thread)) (log:info "End program~%")) nil)) (defun setup-log () (case *cotd-logging* (:log-option-all (log:config :sane :console :daily (merge-pathnames (make-pathname :name "log.txt") *current-dir*) :pattern "%D - %p (%c{1}) %m%n" *cotd-log-level*)) (:log-option-file (log:config :sane :daily (merge-pathnames (make-pathname :name "log.txt") *current-dir*) :pattern "%D - %p (%c{1}) %m%n" *cotd-log-level*)) (t (log:config :off)))) #+clisp (defun cotd-exec () (cffi:define-foreign-library sdl (:darwin (:or (:framework "SDL") (:default "libSDL"))) (:windows "SDL.dll") (:unix (:or "libSDL-1.2.so.0.7.2" "libSDL-1.2.so.0" "libSDL-1.2.so" "libSDL.so" "libSDL"))) (cffi:use-foreign-library sdl) (setf *current-dir* *default-pathname-defaults*) (setf *cotd-release* t) (setf *cotd-logging* :log-option-none) (setf *cotd-log-level* :error) (sdl:with-init () (cotd-main)) (ext:quit)) #+sbcl (defun cotd-exec () (cffi:define-foreign-library sdl (:darwin (:or (:framework "SDL") (:default "libSDL"))) (:windows "SDL.dll") (:unix (:or "libSDL-1.2.so.0.7.2" "libSDL-1.2.so.0" "libSDL-1.2.so" "libSDL.so" "libSDL"))) (cffi:use-foreign-library sdl) (setf *current-dir* *default-pathname-defaults*) (setf *cotd-release* t) (setf *cotd-logging* :log-option-file) (setf *cotd-log-level* :error) (sdl:with-init () (cotd-main)) (sb-ext:exit)) #+clisp (defun make-exec () (ext:saveinitmem "cotd" :quiet t :script t :init-function #'cotd-exec :executable t)) #+(and sbcl windows) (defun make-exec () (sb-ext:save-lisp-and-die "cotd.exe" :toplevel #'cotd-exec :executable t :application-type :gui)) #+(and sbcl unix) (defun make-exec () (sb-ext:save-lisp-and-die "cotd" :toplevel #'cotd-exec :executable t :compression t))
38,916
Common Lisp
.lisp
606
44.731023
198
0.51644
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
048d9bc13e5461523fec08c462aee1bdd59e3efd1bc8f56712ca6f8dab0f8dd0
2,877
[ -1 ]
2,878
init-feature-types.lisp
gwathlobal_CotD/src/init-feature-types.lisp
(in-package :cotd) ;;-------------------- ;; FEATURE-TYPE Declarations ;;-------------------- (set-feature-type (make-instance 'feature-type :id +feature-blood-old+ :glyph-idx nil :glyph-color (sdl:color :r 100 :b 0 :b 0) :back-color nil :name "Bloodstain" :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-blood-fresh+) (= (feature-type feature-old) +feature-blood-stain+)) do (setf result t) (loop-finish) ) result)))) (set-feature-type (make-instance 'feature-type :id +feature-blood-fresh+ :glyph-idx nil :glyph-color (sdl:color :r 250 :b 0 :b 0) :back-color nil :name "Bloodstain" :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-blood-old+) (= (feature-type feature-old) +feature-blood-stain+)) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-blood-stain+)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (loop-finish) when (= (feature-type feature-old) +feature-blood-old+) do (remove-feature-from-level-list level feature-old) (remove-feature-from-world feature-old) (add-feature-to-level-list level feature-new) (loop-finish) ) ))) (set-feature-type (make-instance 'feature-type :id +feature-blood-stain+ :glyph-idx 97 :glyph-color (sdl:color :r 250 :b 0 :b 0) :back-color sdl:*black* :name "Bloodstain" :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-blood-old+) (= (feature-type feature-old) +feature-blood-fresh+)) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (loop-finish) when (or (= (feature-type feature-old) +feature-blood-old+) (= (feature-type feature-old) +feature-blood-fresh+)) do (remove-feature-from-level-list level feature-old) (remove-feature-from-world feature-old) (add-feature-to-level-list level feature-new) (loop-finish) ) ))) (set-feature-type (make-instance 'feature-type :id +feature-start-satanist-player+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Player Satanist Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-arrival-point-north+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "North Delayed Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-arrival-point-south+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "South Delayed Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-arrival-point-east+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "East Delayed Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-arrival-point-west+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "West Delayed Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-delayed-military-arrival-point+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Delayed Military Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-delayed-angels-arrival-point+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Delayed Angels Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-delayed-demons-arrival-point+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Delayed Demons Arrival Point" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-demons+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Demons Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-gold-small+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Small Gold Pile Placeholder")) (set-feature-type (make-instance 'feature-type :id +feature-start-gold-big+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Big Gold Pile Placeholder")) (set-feature-type (make-instance 'feature-type :id +feature-smoke-thin+ :glyph-idx +glyph-id-double-tilda+ :glyph-color (sdl:color :r 200 :g 200 :b 200) :back-color sdl:*black* :name "Smoke" :trait-blocks-vision 60 :trait-smoke +feature-smoke-thin+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-smoke-thick+)) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (when (> (counter feature-old) 4) (setf (feature-type feature-old) +feature-smoke-thick+)) (loop-finish) when (= (feature-type feature-old) +feature-smoke-thick+) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'feature-smoke-on-tick)) (set-feature-type (make-instance 'feature-type :id +feature-smoke-thick+ :glyph-idx +glyph-id-double-tilda+ :glyph-color (sdl:color :r 200 :g 200 :b 200) :back-color sdl:*black* :name "Smoke" :trait-blocks-vision 80 :trait-smoke +feature-smoke-thin+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-smoke-thin+)) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) (= (feature-type feature-old) +feature-smoke-thin+)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'feature-smoke-on-tick)) (set-feature-type (make-instance 'feature-type :id +feature-fire+ :glyph-idx 120 :glyph-color (sdl:color :r 255 :g 69 :b 0) :back-color sdl:*black* :name "Fire" :trait-fire t :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'(lambda (level feature) ;; damage mobs (when (get-mob-* level (x feature) (y feature) (z feature)) (let ((target (get-mob-* level (x feature) (y feature) (z feature)))) (inflict-damage target :min-dmg 1 :max-dmg (counter feature) :dmg-type +weapon-dmg-fire+ :att-spd nil :weapon-aux '(:is-fire) :acc 100 :add-blood nil :no-dodge t :actor nil :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A fire damage. " (capitalize-name (name target)) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from fire. " (capitalize-name (name target))))) (when (check-dead target) (when (eq target *player*) (setf (killed-by *player*) "fire"))) )) ;; spread fire (let ((dir (1+ (random 9))) (dx) (dy)) (multiple-value-setq (dx dy) (x-y-dir dir)) (setf dx (+ (x feature) dx) dy (+ (y feature) dy)) (ignite-tile level dx dy (z feature) (x feature) (y feature) (z feature))) ;; produce smoke (when (<= (random 3) 1) (add-feature-to-level-list level (make-instance 'feature :feature-type +feature-smoke-thin+ :x (x feature) :y (y feature) :z (z feature)))) ;; decrease counter and die out (decf (counter feature)) (when (<= (counter feature) 0) (remove-feature-from-level-list level feature) (remove-feature-from-world feature)) ))) (set-feature-type (make-instance 'feature-type :id +feature-start-church-player+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Player Church Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-relic+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Relic Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-book-of-rituals+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Church Book of Rituals Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-repel-demons+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Repel Demons Starting Location" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-strong-repel-demons+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Repel Demons Starting Location" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-military+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Military Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-sigil-point+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Sigil Starting Position" :trait-remove-on-dungeon-generation t :trait-no-gravity t)) (set-feature-type (make-instance 'feature-type :id +feature-start-machine-point+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Machine Starting Position" :trait-remove-on-dungeon-generation t :trait-no-gravity t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-angels+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Angel Starting Position" :trait-remove-on-dungeon-generation t :trait-no-gravity t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-church-priest+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Priest Starting Position" :trait-remove-on-dungeon-generation t :trait-no-gravity t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-civilian-man+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Man Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-civilian-woman+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Woman Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-start-place-civilian-child+ :glyph-idx 0 :glyph-color sdl:*black* :back-color sdl:*black* :name "Child Starting Position" :trait-remove-on-dungeon-generation t)) (set-feature-type (make-instance 'feature-type :id +feature-smoke-flare+ :glyph-idx +glyph-id-double-tilda+ :glyph-color sdl:*magenta* :back-color sdl:*black* :name "Smoke" :trait-blocks-vision 60 :trait-smoke +feature-smoke-flare+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) ) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'feature-smoke-on-tick)) (set-feature-type (make-instance 'feature-type :id +feature-smoke-flare-final+ :glyph-idx +glyph-id-double-tilda+ :glyph-color sdl:*magenta* :back-color sdl:*black* :name "Smoke" :trait-blocks-vision 60 :trait-smoke +feature-smoke-flare-final+ :trait-no-gravity t :on-tick-func #'(lambda (level feature) (decf (counter feature)) (when (zerop (counter feature)) (print-visible-message (x feature) (y feature) (z feature) (level *world*) (format nil "Artillery shoots. ")) (let ((x (x feature)) (y (y feature)) (z (z feature)) (max-range 2) (killer (get-mob-by-id (param1 feature)))) (remove-feature-from-level-list level feature) (remove-feature-from-world feature) (make-explosion-at-xyz level x y z max-range killer)) ) ))) (set-feature-type (make-instance 'feature-type :id +feature-corrosive-bile-target+ :glyph-idx 99 :glyph-color sdl:*yellow* :back-color sdl:*black* :name "Bile destination" :trait-no-gravity t :on-tick-func #'(lambda (level feature) (decf (counter feature)) (when (zerop (counter feature)) (print-visible-message (x feature) (y feature) (z feature) (level *world*) (format nil "Corrosive bile lands. ")) (let ((x (x feature)) (y (y feature)) (z (z feature)) (max-range 2) (killer (get-mob-by-id (param1 feature)))) (remove-feature-from-level-list level feature) (remove-feature-from-world feature) (make-explosion-at-xyz level x y z max-range killer :dmg-list `((:min-dmg 4 :max-dmg 8 :dmg-type ,+weapon-dmg-acid+ :weapon-aux ())) :animation-dot-id +anim-type-acid-dot+)) ) ))) (set-feature-type (make-instance 'feature-type :id +feature-sacrificial-circle+ :glyph-idx +glyph-id-sacrificial-circle+ :glyph-color sdl:*magenta* :back-color nil :name "Sacrificial circle" )) (set-feature-type (make-instance 'feature-type :id +feature-bomb-plant-target+ :glyph-idx +glyph-id-target-icon+ :glyph-color (sdl:color :r 255 :g 140 :b 0) :back-color nil :name "Target bomb location")) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-flesh+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Un" :trait-demonic-rune +item-type-scroll-demonic-rune-flesh+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-invite+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Ged" :trait-demonic-rune +item-type-scroll-demonic-rune-invite+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-away+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Veh" :trait-demonic-rune +item-type-scroll-demonic-rune-away+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-transform+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Med" :trait-demonic-rune +item-type-scroll-demonic-rune-transform+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-barrier+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Gon" :trait-demonic-rune +item-type-scroll-demonic-rune-barrier+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-all+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Tal" :trait-demonic-rune +item-type-scroll-demonic-rune-all+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-rune-decay+ :glyph-idx 123 :glyph-color sdl:*magenta* :back-color nil :name "Demonic rune Drux" :trait-demonic-rune +item-type-scroll-demonic-rune-decay+)) (set-feature-type (make-instance 'feature-type :id +feature-demonic-portal+ :glyph-idx +glyph-id-portal+ :glyph-color (sdl:color :r 255 :g 165 :b 0) :back-color nil :name "Demonic portal" )) (set-feature-type (make-instance 'feature-type :id +feature-divine-portal+ :glyph-idx +glyph-id-portal+ :glyph-color sdl:*cyan* :back-color nil :name "Divine portal" )) (set-feature-type (make-instance 'feature-type :id +feature-corrupted-spores+ :glyph-idx +glyph-id-double-tilda+ :glyph-color (sdl:color :r 100 :g 0 :b 0) :back-color sdl:*black* :name "Spores" :trait-blocks-vision 30 :trait-smoke +feature-corrupted-spores+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) ) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'(lambda (level feature) (let ((target (get-mob-* level (x feature) (y feature) (z feature)))) (when target (inflict-damage target :min-dmg 1 :max-dmg 2 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :actor nil :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from spores. " (capitalize-name (name target)) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from spores. " (capitalize-name (name target))))) (when (check-dead target) (when (eq target *player*) (setf (killed-by *player*) "spores"))))) (feature-smoke-on-tick level feature)))) (set-feature-type (make-instance 'feature-type :id +feature-smoke-acid-gas+ :glyph-idx +glyph-id-double-tilda+ :glyph-color (sdl:color :r 0 :g 200 :b 0) :back-color sdl:*black* :name "Poisoned gas" :trait-blocks-vision 60 :trait-smoke +feature-smoke-acid-gas+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old)) ) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'(lambda (level feature) (let ((target (get-mob-* level (x feature) (y feature) (z feature)))) (when target (inflict-damage target :min-dmg 3 :max-dmg 6 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :actor nil :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from poisoned gas. " (capitalize-name (name target)) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from poisoned gas. " (capitalize-name (name target))))) (when (check-dead target) (when (eq target *player*) (setf (killed-by *player*) "poisoned gas"))))) (feature-smoke-on-tick level feature)))) (set-feature-type (make-instance 'feature-type :id +feature-smoke-weak-acid-gas+ :glyph-idx +glyph-id-double-tilda+ :glyph-color sdl:*yellow* :back-color sdl:*black* :name "Acidic gas" :trait-blocks-vision 40 :trait-smoke +feature-smoke-weak-acid-gas+ :trait-no-gravity t :can-merge-func #'(lambda (level feature-new) (let ((result nil)) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (or (= (feature-type feature-new) (feature-type feature-old))) do (setf result t) (loop-finish) ) result)) :merge-func #'(lambda (level feature-new) (loop for feature-old-id in (aref (features level) (x feature-new) (y feature-new) (z feature-new)) for feature-old = (get-feature-by-id feature-old-id) when (= (feature-type feature-new) (feature-type feature-old)) do (remove-feature-from-level-list level feature-new) (remove-feature-from-world feature-new) (incf (counter feature-old)) (loop-finish) ) ) :on-tick-func #'(lambda (level feature) (let ((target (get-mob-* level (x feature) (y feature) (z feature)))) (when target (inflict-damage target :min-dmg 1 :max-dmg 2 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :actor nil :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from acidic gas. " (capitalize-name (name target)) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from acidic gas. " (capitalize-name (name target))))) (when (check-dead target) (when (eq target *player*) (setf (killed-by *player*) "acidic gas"))))) (feature-smoke-on-tick level feature))))
48,011
Common Lisp
.lisp
397
56.531486
242
0.350663
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
90470e2e69c678b2428fc155364ac9be09281c6ffaa737b0d4b6aa41ae0c3ba7
2,878
[ -1 ]
2,879
message-box.lisp
gwathlobal_CotD/src/message-box.lisp
(in-package :cotd) ;; :string - the string to display (defstruct message-box (had-message-this-turn nil :type boolean) (strings (make-colored-txt) :type colored-txt)) (defun add-message (str &optional (color sdl:*white*) (message-box-list (list (level/full-message-box (level *world*)) (level/small-message-box (level *world*))))) (log:info "~A" str) (loop for message-box in message-box-list do (add-colored-str (message-box-strings message-box) str color))) (defun get-message-str (n &optional (message-box (level/full-message-box (level *world*)))) (first (nth n (colored-txt-list (message-box-strings message-box))))) (defun message-list-length (&optional (message-box (level/full-message-box (level *world*)))) (length (colored-txt-list (message-box-strings message-box)))) (defun clear-message-list (&optional (message-box (level/full-message-box (level *world*)))) (setf (colored-txt-list (message-box-strings message-box)) ()) (setf (message-box-had-message-this-turn message-box) nil)) (defun set-message-this-turn (bool &optional (message-box (level/full-message-box (level *world*)))) (setf (message-box-had-message-this-turn message-box) bool)) (defun get-message-this-turn (&optional (message-box (level/full-message-box (level *world*)))) (message-box-had-message-this-turn message-box)) (defun get-msg-str-list (&optional (message-box (level/full-message-box (level *world*)))) (loop with str = (make-array '(0) :element-type 'character :adjustable t :fill-pointer t) for (line color) in (reverse (colored-txt-list (message-box-strings message-box))) do (format str "~A" line) finally (return str))) (defun prepend-article-func (article name &rest args) (let ((article-str (cond ((and (= article +article-a+) (find (char (string-downcase name) 0) '(#\a #\u #\o #\i #\e))) "an ") ((= article +article-a+) "a ") ((= article +article-the+) "the ") (t "")))) (when (or (find +noun-proper+ args) (and (find +noun-common+ args) (find +noun-plural+ args) (= article +article-a+))) (setf article-str "")) (format nil "~A~A" article-str name))) (defmacro prepend-article (article name-func) `(multiple-value-call #'prepend-article-func ,article ,name-func))
2,398
Common Lisp
.lisp
40
53.1
163
0.650192
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
382a1f34ce21c2a374e51fe113439b1808d8eaed52ca899dd631e145c10cf4ad
2,879
[ -1 ]
2,880
campaign-effects.lisp
gwathlobal_CotD/src/campaign-effects.lisp
(in-package :cotd) (defenum:defenum campaign-effect-enum (:campaign-effect-satanist-lair-visible :campaign-effect-satanist-sacrifice :campaign-effect-satanist-lair-hidden :campaign-effect-demon-protect-dimension :campaign-effect-demon-turmoil :campaign-effect-demon-delayed :campaign-effect-angel-hastened :campaign-effect-demon-corrupt-portals :campaign-effect-eater-agitated :campaign-effect-angel-crusade :campaign-effect-demon-malseraph-blessing :campaign-effect-demon-malseraph-bored)) (defclass campaign-effect-type () ((id :initarg :id :accessor campaign-effect-type/id :type campaign-effect-enum) (name :initarg :name :accessor campaign-effect-type/name) (descr :initarg :descr :accessor campaign-effect-type/descr) (displayed :initarg :displayed :accessor campaign-effect-type/displayed) (merge-func :initform nil :initarg :merge-func :accessor campaign-effect-type/merge-func) (on-add-func :initform nil :initarg :on-add-func :accessor campaign-effect-type/on-add-func) (on-remove-func :initform nil :initarg :on-remove-func :accessor campaign-effect-type/on-remove-func))) (defun set-campaign-effect-type (&key id name descr (displayed t) merge-func on-add-func on-remove-func) (unless id (error ":ID is an obligatory parameter!")) (unless name (error ":NAME is an obligatory parameter!")) (unless descr (error ":DESCR is an obligatory parameter!")) (setf (gethash id *campaign-effect-types*) (make-instance 'campaign-effect-type :id id :name name :descr descr :displayed displayed :merge-func merge-func :on-add-func on-add-func :on-remove-func on-remove-func))) (defun get-campaign-effect-type-by-id (campaign-effect-type-id) (gethash campaign-effect-type-id *campaign-effect-types*)) (defclass campaign-effect () ((id :initarg :id :accessor campaign-effect/id :type campaign-effect-enum) (cd :initform nil :initarg :cd :accessor campaign-effect/cd :type (or null fixnum)) (param :initform nil :initarg :param :accessor campaign-effect/param) )) (defmethod campaign-effect/name ((campaign-effect campaign-effect)) (campaign-effect-type/name (get-campaign-effect-type-by-id (campaign-effect/id campaign-effect)))) (defmethod campaign-effect/descr ((campaign-effect campaign-effect)) (campaign-effect-type/descr (get-campaign-effect-type-by-id (campaign-effect/id campaign-effect)))) (defmethod campaign-effect/displayed ((campaign-effect campaign-effect)) (campaign-effect-type/displayed (get-campaign-effect-type-by-id (campaign-effect/id campaign-effect)))) (defmethod campaign-effect/on-add-func ((campaign-effect campaign-effect)) (campaign-effect-type/on-add-func (get-campaign-effect-type-by-id (campaign-effect/id campaign-effect)))) (defmethod campaign-effect/on-remove-func ((campaign-effect campaign-effect)) (campaign-effect-type/on-remove-func (get-campaign-effect-type-by-id (campaign-effect/id campaign-effect))))
3,332
Common Lisp
.lisp
43
65.046512
215
0.679683
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
6673f7b2484f49b130490eb37045b1f12c220817eae3dca78807851730c6fcf9
2,880
[ -1 ]
2,881
init-mission-types.lisp
gwathlobal_CotD/src/init-mission-types.lisp
(in-package :cotd) ;;---------------------------------------- ;; MISSION-TYPES ;;---------------------------------------- (set-mission-type :id :mission-type-test :name "Test" :enabled nil :mission-slot-type :mission-slot-demons-city :faction-list-func #'(lambda (world-sector) (declare (ignore world-sector)) (let ((faction-list (list (list +faction-type-none+ :mission-faction-present) ))) faction-list)) :scenario-faction-list (list (list +specific-faction-type-test+ +lm-placement-test+)) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; place player (push #'place-player-on-level func-list) func-list)) ) (set-mission-type :id :mission-type-demonic-attack :name "Demonic attack" :mission-slot-type :mission-slot-demons-city :is-available-func #'(lambda (world-sector world) (let ((near-demons nil) (x (x world-sector)) (y (y world-sector))) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (cells (world-map world)) 0)) (< dy (array-dimension (cells (world-map world)) 1)) (= (controlled-by (aref (cells (world-map world)) dx dy)) +lm-controlled-by-demons+)) (setf near-demons t)))) (if (and near-demons (world-sector-normal-p world-sector) (not (eq (wtype world-sector) :world-sector-normal-island))) t nil))) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-demons+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (unless (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-normal-forest :world-sector-normal-port :world-sector-normal-residential :world-sector-normal-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-church+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) (list +faction-type-criminals+ (list +ai-package-patrol-district+)) (list +faction-type-ghost+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-demon-attack-win-for-demons+) (list +faction-type-angels+ +game-event-demon-attack-win-for-angels+) (list +faction-type-military+ +game-event-demon-attack-win-for-military+) (list +faction-type-church+ +game-event-demon-attack-win-for-church+) (list +faction-type-satanists+ +game-event-demon-attack-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) (list +faction-type-criminals+ +game-event-win-for-thief+) (list +faction-type-ghost+ +game-event-win-for-ghost+) ) :campaign-result (list (list :game-over-angels-won nil) (list :game-over-demons-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-military-won nil) (list :game-over-church-won nil) (list :game-over-satanists-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-eater-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic))) ) (set-mission-type :id :mission-type-demonic-raid :name "Demonic raid" :mission-slot-type :mission-slot-demons-city :is-available-func #'(lambda (world-sector world) (declare (ignore world)) (if (world-sector-normal-p world-sector) t nil)) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-demons+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (unless (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-normal-forest :world-sector-normal-port :world-sector-normal-residential :world-sector-normal-lake :world-sector-normal-island) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) ;; place demonic portals (push #'place-demonic-portals func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-search-corpses+ +ai-package-pick-corpses+ +ai-package-return-corpses-to-portal+ +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-church+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-search-corpses+ +ai-package-pick-corpses+ +ai-package-return-corpses-to-portal+ +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) (list +faction-type-criminals+ (list +ai-package-patrol-district+)) (list +faction-type-ghost+ (list +ai-package-patrol-district+)) ) :ability-list (list (list +faction-type-demons+ (list +mob-abil-throw-corpse-into-portal+))) :win-condition-list (list (list +faction-type-demons+ +game-event-demon-raid-win-for-demons+) (list +faction-type-angels+ +game-event-demon-raid-win-for-angels+) (list +faction-type-military+ +game-event-demon-raid-win-for-military+) (list +faction-type-church+ +game-event-demon-raid-win-for-church+) (list +faction-type-satanists+ +game-event-demon-raid-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) (list +faction-type-criminals+ +game-event-win-for-thief+) (list +faction-type-ghost+ +game-event-win-for-ghost+) ) :campaign-result (list (list :game-over-angels-won nil) (list :game-over-demons-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-military-won nil) (list :game-over-church-won nil) (list :game-over-satanists-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-eater-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic))) ) (set-mission-type :id :mission-type-demonic-conquest :name "Demonic conquest" :mission-slot-type :mission-slot-demons-city :is-available-func #'(lambda (world-sector world) (declare (ignore world)) (if (or (world-sector-normal-p world-sector) (world-sector-abandoned-p world-sector)) t nil)) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-demons+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (if (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-present) faction-list) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-normal-forest :world-sector-normal-port :world-sector-normal-residential :world-sector-normal-lake :world-sector-normal-island :world-sector-abandoned-forest :world-sector-abandoned-port :world-sector-abandoned-island :world-sector-abandoned-residential :world-sector-abandoned-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) ;; place demonic portals (push #'place-demonic-portals func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-military+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-church+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) (list +faction-type-criminals+ (list +ai-package-patrol-district+)) (list +faction-type-ghost+ (list +ai-package-patrol-district+)) ) :ability-list (list (list +faction-type-demons+ (list +mob-abil-create-demon-sigil+))) :win-condition-list (list (list +faction-type-demons+ +game-event-demon-conquest-win-for-demons+) (list +faction-type-angels+ +game-event-demon-conquest-win-for-angels+) (list +faction-type-military+ +game-event-demon-conquest-win-for-military+) (list +faction-type-church+ +game-event-demon-conquest-win-for-church+) (list +faction-type-satanists+ +game-event-demon-conquest-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) (list +faction-type-criminals+ +game-event-win-for-thief+) (list +faction-type-ghost+ +game-event-win-for-ghost+) ) :campaign-result (list (list :game-over-angels-won nil) (list :game-over-demons-won (list #'transform-residential-sector-to-corrupted #'transform-abandoned-sector-to-corrupted #'move-relic-to-corrupted-district #'move-military-to-free-sector #'demons-capture-book-of-rituals #'demons-capture-relic)) (list :game-over-military-won nil) (list :game-over-church-won nil) (list :game-over-satanists-won (list #'transform-residential-sector-to-corrupted #'transform-abandoned-sector-to-corrupted #'move-relic-to-corrupted-district #'move-military-to-free-sector #'demons-capture-book-of-rituals #'demons-capture-relic)) (list :game-over-eater-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic))) ) (set-mission-type :id :mission-type-demonic-thievery :name "Demonic thievery" :mission-slot-type :mission-slot-demons-city :is-available-func #'(lambda (world-sector world) ;; mission available only if ;; - there is a corrupted district on the map ;; - this sector has a church and a relic in it ;; - the sector is not corrupted (let ((x (x world-sector)) (y (y world-sector))) (if (and (loop with corrupted-district-present = nil for dx from 0 below (array-dimension (cells (world-map world)) 0) do (loop for dy from 0 below (array-dimension (cells (world-map world)) 1) do (when (world-sector-corrupted-p (aref (cells (world-map world)) dx dy)) (setf corrupted-district-present t))) finally (return corrupted-district-present)) (find +lm-feat-church+ (feats (aref (cells (world-map world)) x y)) :key #'(lambda (a) (first a))) (find +lm-item-holy-relic+ (items (aref (cells (world-map world)) x y))) (not (world-sector-corrupted-p world-sector))) t nil))) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-demons+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (if (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-present) faction-list) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-normal-forest :world-sector-normal-port :world-sector-normal-residential :world-sector-normal-lake :world-sector-normal-island :world-sector-abandoned-forest :world-sector-abandoned-port :world-sector-abandoned-island :world-sector-abandoned-residential :world-sector-abandoned-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) ;; place demonic portals (push #'place-demonic-portals func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-search-relic+ +ai-package-pick-relic+ +ai-package-return-relic-to-portal+ +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-church+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-search-relic+ +ai-package-pick-relic+ +ai-package-return-relic-to-portal+ +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) (list +faction-type-criminals+ (list +ai-package-patrol-district+)) (list +faction-type-ghost+ (list +ai-package-patrol-district+)) ) :ability-list (list (list +faction-type-demons+ (list +mob-abil-throw-relic-into-portal+))) :win-condition-list (list (list +faction-type-demons+ +game-event-demon-steal-win-for-demons+) (list +faction-type-angels+ +game-event-demon-steal-win-for-angels+) (list +faction-type-military+ +game-event-demon-steal-win-for-military+) (list +faction-type-church+ +game-event-demon-steal-win-for-church+) (list +faction-type-satanists+ +game-event-demon-steal-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) (list +faction-type-criminals+ +game-event-win-for-thief+) (list +faction-type-ghost+ +game-event-win-for-ghost+) ) :campaign-result (list (list :game-over-angels-won nil) (list :game-over-demons-won (list #'move-relic-to-corrupted-district)) (list :game-over-military-won nil) (list :game-over-church-won nil) (list :game-over-satanists-won (list #'move-relic-to-corrupted-district)) (list :game-over-eater-won (list #'transform-residential-sector-to-abandoned #'move-military-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic))) ) (set-mission-type :id :mission-type-military-conquest :name "Military conquest" :mission-slot-type :mission-slot-military-city :is-available-func #'(lambda (world-sector world) (let ((near-military nil) (x (x world-sector)) (y (y world-sector))) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (cells (world-map world)) 0)) (< dy (array-dimension (cells (world-map world)) 1)) (= (controlled-by (aref (cells (world-map world)) dx dy)) +lm-controlled-by-military+)) (setf near-military t)))) (if (and near-military (world-sector-corrupted-p world-sector)) t nil))) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-military+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-corrupted-forest :world-sector-corrupted-port :world-sector-corrupted-island :world-sector-corrupted-residential :world-sector-corrupted-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-military+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-military-conquest-win-for-demons+) (list +faction-type-angels+ +game-event-military-conquest-win-for-angels+) (list +faction-type-military+ +game-event-military-conquest-win-for-military+) (list +faction-type-satanists+ +game-event-military-conquest-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) ) :campaign-result (list (list :game-over-angels-won (list #'transform-corrupted-sector-to-residential #'move-relic-to-church #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-demons-won nil) (list :game-over-military-won (list #'transform-corrupted-sector-to-residential #'move-relic-to-church #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-church-won (list #'transform-corrupted-sector-to-residential #'move-relic-to-church #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-satanists-won nil) (list :game-over-eater-won (list #'move-demons-to-free-sector))) ) (set-mission-type :id :mission-type-military-raid :name "Military raid" :mission-slot-type :mission-slot-military-city :is-available-func #'(lambda (world-sector world) (let ((near-military nil) (x (x world-sector)) (y (y world-sector))) (check-surroundings x y nil #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (cells (world-map world)) 0)) (< dy (array-dimension (cells (world-map world)) 1)) (= (controlled-by (aref (cells (world-map world)) dx dy)) +lm-controlled-by-military+)) (setf near-military t)))) (if (and near-military (world-sector-abandoned-p world-sector)) t nil))) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-military+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) ))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-abandoned-forest :world-sector-abandoned-port :world-sector-abandoned-island :world-sector-abandoned-residential :world-sector-abandoned-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-military-raid-win-for-demons+) (list +faction-type-angels+ +game-event-military-raid-win-for-angels+) (list +faction-type-military+ +game-event-military-raid-win-for-military+) (list +faction-type-satanists+ +game-event-military-raid-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) ) :campaign-result (list (list :game-over-angels-won (list #'transform-abandoned-sector-to-residential #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-demons-won nil) (list :game-over-military-won (list #'transform-abandoned-sector-to-residential #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-church-won (list #'transform-abandoned-sector-to-residential #'move-demons-to-free-sector #'humans-capture-book-of-rituals #'humans-capture-relic)) (list :game-over-satanists-won nil) (list :game-over-eater-won nil)) ) (set-mission-type :id :mission-type-celestial-purge :name "Celestial purge" :mission-slot-type :mission-slot-angels-city :is-available-func #'(lambda (world-sector world) (declare (ignore world)) (if (world-sector-corrupted-p world-sector) t nil)) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-angels+ :mission-faction-present)))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list)) (if (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-present) faction-list) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-corrupted-forest :world-sector-corrupted-port :world-sector-corrupted-island :world-sector-corrupted-residential :world-sector-corrupted-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-military+ (list +ai-package-patrol-district+ +ai-package-find-sigil+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-military-conquest-win-for-demons+) (list +faction-type-angels+ +game-event-military-conquest-win-for-angels+) (list +faction-type-military+ +game-event-military-conquest-win-for-military+) (list +faction-type-satanists+ +game-event-military-conquest-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) ) :campaign-result (list (list :game-over-angels-won (list #'transform-corrupted-sector-to-abandoned #'move-demons-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-demons-won nil) (list :game-over-military-won (list #'transform-corrupted-sector-to-abandoned #'move-demons-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-church-won (list #'transform-corrupted-sector-to-abandoned #'move-demons-to-free-sector #'neutrals-capture-book-of-rituals #'neutrals-capture-relic)) (list :game-over-satanists-won nil) (list :game-over-eater-won (list #'move-demons-to-free-sector))) ) (set-mission-type :id :mission-type-celestial-retrieval :name "Celestial retrieval" :mission-slot-type :mission-slot-angels-city :is-available-func #'(lambda (world-sector world) (if (and (find +lm-item-holy-relic+ (items world-sector)) (or (world-sector-abandoned-p world-sector) (world-sector-corrupted-p world-sector)) (loop with free-church-present = nil for dx from 0 below (array-dimension (cells (world-map world)) 0) do (loop for dy from 0 below (array-dimension (cells (world-map world)) 1) do (when (and (world-sector-normal-p (aref (cells (world-map world)) dx dy)) (find +lm-feat-church+ (feats (aref (cells (world-map world)) dx dy)) :key #'(lambda (a) (first a)))) (setf free-church-present t))) finally (return free-church-present))) t nil)) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-angels+ :mission-faction-present)))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list)) (if (= (controlled-by world-sector) +lm-controlled-by-military+) (push (list +faction-type-military+ :mission-faction-present) faction-list) (push (list +faction-type-military+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-corrupted-forest :world-sector-corrupted-port :world-sector-corrupted-island :world-sector-corrupted-residential :world-sector-corrupted-lake :world-sector-abandoned-forest :world-sector-abandoned-port :world-sector-abandoned-island :world-sector-abandoned-residential :world-sector-abandoned-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+ +ai-package-search-relic+ +ai-package-pick-relic+ +ai-package-escape-with-relic+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-angelic-steal-win-for-demons+) (list +faction-type-angels+ +game-event-angelic-steal-win-for-angels+) (list +faction-type-military+ +game-event-angelic-steal-win-for-military+) (list +faction-type-satanists+ +game-event-angelic-steal-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater+) ) :campaign-result (list (list :game-over-angels-won (list #'move-relic-to-church)) (list :game-over-demons-won nil) (list :game-over-military-won (list #'move-relic-to-church)) (list :game-over-church-won (list #'move-relic-to-church)) (list :game-over-satanists-won nil) (list :game-over-eater-won nil)) ) (set-mission-type :id :mission-type-eliminate-satanists :name "Satanist elimination" :mission-slot-type :mission-slot-military-city :is-available-func #'(lambda (world-sector world) (if (and (find +lm-feat-lair+ (feats world-sector) :key #'(lambda (a) (first a))) (find-campaign-effects-by-id world :campaign-effect-satanist-lair-visible)) t nil) ) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-angels+ :mission-faction-present) (list +faction-type-angels+ :mission-faction-delayed) (list +faction-type-angels+ :mission-faction-absent) (list +faction-type-military+ :mission-faction-present) ))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list)) (when (or (not (mission world-sector)) (not (find +lm-misc-eater-incursion+ (level-modifier-list (mission world-sector))))) (push (list +faction-type-eater+ :mission-faction-absent) faction-list)) faction-list)) :world-sector-for-custom-scenario (list :world-sector-normal-forest :world-sector-normal-port :world-sector-normal-residential :world-sector-normal-lake :world-sector-normal-island :world-sector-corrupted-forest :world-sector-corrupted-port :world-sector-corrupted-island :world-sector-corrupted-residential :world-sector-corrupted-lake :world-sector-abandoned-forest :world-sector-abandoned-port :world-sector-abandoned-island :world-sector-abandoned-residential :world-sector-abandoned-lake) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; add disguises to satanists (push #'add-disguises-to-satanists func-list) ;; place 1 thief (push #'place-ai-thief-on-level func-list) ;; place 1 eater of the dead (push #'place-ai-primordial-on-level func-list) ;; place 1 ghost (push #'place-ai-ghost-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+)) (list +faction-type-church+ (list +ai-package-patrol-district+)) (list +faction-type-satanists+ (list +ai-package-patrol-district+ +ai-package-coward+)) (list +faction-type-eater+ (list +ai-package-patrol-district+)) (list +faction-type-criminals+ (list +ai-package-patrol-district+)) (list +faction-type-ghost+ (list +ai-package-patrol-district+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-eliminate-satanists-win-for-demons+) (list +faction-type-angels+ +game-event-eliminate-satanists-win-for-angels+) (list +faction-type-military+ +game-event-eliminate-satanists-win-for-military+) (list +faction-type-church+ +game-event-eliminate-satanists-win-for-church+) (list +faction-type-satanists+ +game-event-eliminate-satanists-win-for-satanists+) (list +faction-type-eater+ +game-event-win-for-eater-consume+) (list +faction-type-criminals+ +game-event-win-for-thief+) (list +faction-type-ghost+ +game-event-win-for-ghost+) ) :campaign-result (list (list :game-over-angels-won (list #'remove-satanist-lair-from-map)) (list :game-over-demons-won nil) (list :game-over-military-won (list #'remove-satanist-lair-from-map)) (list :game-over-church-won (list #'remove-satanist-lair-from-map)) (list :game-over-satanists-won nil) (list :game-over-eater-won (list #'remove-satanist-lair-from-map #'move-military-to-free-sector #'move-demons-to-free-sector))) ) (set-mission-type :id :mission-type-celestial-sabotage :name "Celestial sabotage" :mission-slot-type :mission-slot-angels-offworld :is-available-func #'(lambda (world-sector world) (let* ((angels-win-cond (get-win-condition-by-id :win-cond-angels-campaign)) (machines-left (funcall (win-condition/win-func angels-win-cond) world angels-win-cond))) (if (and (world-sector-hell-p world-sector) (> machines-left 0)) t nil))) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-angels+ :mission-faction-present)))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list) ) faction-list)) :world-sector-for-custom-scenario (list :world-sector-hell-jungle ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; place angels (push #'place-ai-angels-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-angels+ (list +ai-package-patrol-district+ +ai-package-find-machine+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-angelic-sabotage-win-for-demons+) (list +faction-type-angels+ +game-event-angelic-sabotage-win-for-angels+) ) :campaign-result (list (list :game-over-angels-won (list #'remove-hell-engine #'throw-hell-in-turmoil)) (list :game-over-demons-won nil)) ) (set-mission-type :id :mission-type-military-sabotage :name "Military sabotage" :mission-slot-type :mission-slot-military-offworld :is-available-func #'(lambda (world-sector world) (if (and (world-sector-hell-p world-sector) (> (world/flesh-points world) 0)) t nil)) :faction-list-func #'(lambda (world-sector) (let ((faction-list (list (list +faction-type-military+ :mission-faction-present)))) (if (= (controlled-by world-sector) +lm-controlled-by-demons+) (push (list +faction-type-demons+ :mission-faction-present) faction-list) (push (list +faction-type-demons+ :mission-faction-delayed) faction-list) ) faction-list)) :world-sector-for-custom-scenario (list :world-sector-hell-jungle ) :overall-post-process-func-list #'(lambda () (let ((func-list ())) ;; set up initial power (push #'set-up-inital-power func-list) ;; add lose condition on death & all other win conditions (push #'add-lose-and-win-coditions-to-level func-list) ;; remove signal flares from military (push #'remove-signal-flares-from-military func-list) ;; add bombs to military (push #'add-bombs-to-military func-list) ;; update visibility for all added mobs (push #'update-visibility-after-creation func-list) ;; remove all starting features (push #'remove-dungeon-gen-functions func-list) ;; set up turns for delayed arrival for all parties (push #'setup-turns-for-delayed-arrival func-list) ;; create delayed points from respective features (push #'place-delayed-arrival-points-on-level func-list) ;; add military (push #'place-ai-military-on-level func-list) ;; place demons (push #'place-ai-demons-on-level func-list) ;; place player (push #'place-player-on-level func-list) func-list)) :scenario-faction-list (list (list +specific-faction-type-player+ +lm-placement-player+) (list +specific-faction-type-dead-player+ +lm-placement-dead-player+) (list +specific-faction-type-angel-chrome+ +lm-placement-angel-chrome+) (list +specific-faction-type-angel-trinity+ +lm-placement-angel-trinity+) (list +specific-faction-type-demon-crimson+ +lm-placement-demon-crimson+) (list +specific-faction-type-demon-shadow+ +lm-placement-demon-shadow+) (list +specific-faction-type-demon-malseraph+ +lm-placement-demon-malseraph+) (list +specific-faction-type-military-chaplain+ +lm-placement-military-chaplain+) (list +specific-faction-type-military-scout+ +lm-placement-military-scout+) (list +specific-faction-type-priest+ +lm-placement-priest+) (list +specific-faction-type-satanist+ +lm-placement-satanist+) (list +specific-faction-type-eater+ +lm-placement-eater+) (list +specific-faction-type-skinchanger+ +lm-placement-skinchanger+) (list +specific-faction-type-thief+ +lm-placement-thief+) (list +specific-faction-type-ghost+ +lm-placement-ghost+) ) :ai-package-list (list (list +faction-type-demons+ (list +ai-package-patrol-district+)) (list +faction-type-military+ (list +ai-package-patrol-district+ +ai-package-find-bomb-plant-location+)) ) :win-condition-list (list (list +faction-type-demons+ +game-event-military-sabotage-win-for-demons+) (list +faction-type-military+ +game-event-military-sabotage-win-for-military+) ) :campaign-result (list (list :game-over-military-won (list #'remove-raw-flesh-from-demons #'throw-hell-in-turmoil)) (list :game-over-demons-won nil)) )
121,065
Common Lisp
.lisp
1,223
43.89861
262
0.367128
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
525cfe24b628b02e1779923a26097256317bdce68f446c720071e73b3435e3da
2,881
[ -1 ]
2,882
win-condition.lisp
gwathlobal_CotD/src/win-condition.lisp
(in-package :cotd) (defparameter *win-conditions* (make-hash-table)) (defenum:defenum win-cond-enum (:win-cond-demonic-attack :win-cond-demonic-raid :win-cond-thief :win-cond-demonic-conquest :win-cond-military-conquest :win-cond-celestial-sabotage :win-cond-military-sabotage :win-cond-demon-campaign :win-cond-military-campaign :win-cond-angels-campaign :win-cond-eater-cosnume)) (defclass win-condition () ((id :initarg :id :accessor win-condition/id :type win-cond-enum) (win-formula :initarg :win-formula :accessor win-condition/win-formula) (win-func :initarg :win-func :accessor win-condition/win-func))) (defun set-win-condition (&key id win-formula win-func) (unless id (error ":ID is an obligatory parameter!")) (unless win-formula (error ":WIN-FORMULA is an obligatory parameter!")) (unless win-func (error ":WIN-FUNC is an obligatory parameter!")) (setf (gethash id *win-conditions*) (make-instance 'win-condition :id id :win-formula win-formula :win-func win-func))) (defun get-win-condition-by-id (win-condition-id) (gethash win-condition-id *win-conditions*))
1,558
Common Lisp
.lisp
26
40.346154
92
0.535785
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
fcc2fef69270f024cb0064979839db1ace9aa88afaf5ca5edc88c4ab5e4da0d0
2,882
[ -1 ]
2,883
character-dump.lisp
gwathlobal_CotD/src/character-dump.lisp
(in-package :cotd) (defun find-mob-with-max-kills () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (calculate-total-kills mob) (calculate-total-kills mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-blesses () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (stat-blesses mob) (stat-blesses mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-calls () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (stat-calls mob) (stat-calls mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-answers () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (stat-answers mob) (stat-answers mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-friendly-kills () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (calculate-total-friendly-kills mob) (calculate-total-friendly-kills mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun calculate-total-value (mob) (if (and (check-dead mob) (eq mob *player*)) (stat-gold mob) (get-overall-value (inv mob)))) (defun find-mob-with-max-value () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (calculate-total-value mob) (calculate-total-value mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-possessions () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (stat-possess mob) (stat-possess mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun find-mob-with-max-reanimations () (loop for mob across *mobs* with mob-found = nil finally (return mob-found) do (if mob-found (when (> (stat-raised-dead mob) (stat-raised-dead mob-found)) (setf mob-found mob)) (setf mob-found mob)))) (defun return-scenario-stats (&optional (on-screen t)) (let ((str (create-string))) (format str " Humans: total ~A, killed ~A, left ~A~A~%" (initial-humans (level *world*)) (- (initial-humans (level *world*)) (total-humans (level *world*))) (total-humans (level *world*)) (new-line on-screen)) (format str " Angels: total ~A, killed ~A, left ~A~A~%" (initial-angels (level *world*)) (- (initial-angels (level *world*)) (total-angels (level *world*))) (total-angels (level *world*)) (new-line on-screen)) (format str " Demons: total ~A, killed ~A, left ~A~A~%" (initial-demons (level *world*)) (- (initial-demons (level *world*)) (total-demons (level *world*))) (total-demons (level *world*)) (new-line on-screen)) (format str " Undead: total ~A, killed ~A, left ~A~A~%" (initial-undead (level *world*)) (- (initial-undead (level *world*)) (total-undead (level *world*))) (total-undead (level *world*)) (new-line on-screen)) (format str "~%") (format str " The Butcher: ~A~A~%" (if (zerop (calculate-total-kills (find-mob-with-max-kills))) (format nil "-") (format nil "~A with ~A kills" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-kills))) (calculate-total-kills (find-mob-with-max-kills)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-kills))) (not (zerop (calculate-total-kills *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A kills" (prepend-article +article-a+ (get-qualified-name *player*)) (calculate-total-kills *player*)) (new-line on-screen))) (format str " The Hand of God: ~A~A~%" (if (zerop (stat-blesses (find-mob-with-max-blesses))) (format nil "-") (format nil "~A with ~A blessings" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-blesses))) (stat-blesses (find-mob-with-max-blesses)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-blesses))) (not (zerop (stat-blesses *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A blessings" (prepend-article +article-a+ (get-qualified-name *player*)) (stat-blesses *player*)) (new-line on-screen))) (format str " The Summoner: ~A~A~%" (if (zerop (stat-calls (find-mob-with-max-calls))) (format nil "-") (format nil "~A with ~A summons" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-calls))) (stat-calls (find-mob-with-max-calls)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-calls))) (not (zerop (stat-calls *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A summons" (prepend-article +article-a+ (get-qualified-name *player*)) (stat-calls *player*)) (new-line on-screen))) (format str " The Jumper: ~A~A~%" (if (zerop (stat-answers (find-mob-with-max-answers))) (format nil "-") (format nil "~A with ~A summon answers" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-answers))) (stat-answers (find-mob-with-max-answers)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-answers))) (not (zerop (stat-answers *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A summons answers" (prepend-article +article-a+ (get-qualified-name *player*)) (stat-answers *player*)) (new-line on-screen))) (format str " The Berserker: ~A~A~%" (if (zerop (calculate-total-friendly-kills (find-mob-with-max-friendly-kills))) (format nil "-") (format nil "~A with ~A friendly kills" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-friendly-kills))) (calculate-total-friendly-kills (find-mob-with-max-friendly-kills)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-friendly-kills))) (not (zerop (calculate-total-friendly-kills *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A friendly kills" (prepend-article +article-a+ (get-qualified-name *player*)) (calculate-total-friendly-kills *player*)) (new-line on-screen))) (format str " The Evil Spirit: ~A~A~%" (if (zerop (stat-possess (find-mob-with-max-possessions))) (format nil "-") (format nil "~A with ~A possessions" (prepend-article +article-a+ (if (and (not (eq (find-mob-with-max-possessions) *player*)) (mob-ability-p (find-mob-with-max-possessions) +mob-abil-ghost-possess+)) (name (get-mob-type-by-id +mob-type-ghost+)) (get-qualified-name (find-mob-with-max-possessions)))) (stat-possess (find-mob-with-max-possessions)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-possessions))) (not (zerop (stat-possess *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A possessions" (prepend-article +article-a+ (get-qualified-name *player*)) (stat-possess *player*)) (new-line on-screen))) (format str " The Necromancer: ~A~A~%" (if (zerop (stat-raised-dead (find-mob-with-max-reanimations))) (format nil "-") (format nil "~A with ~A reanimations" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-reanimations))) (stat-raised-dead (find-mob-with-max-reanimations)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-reanimations))) (not (zerop (stat-raised-dead *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A reanimations" (prepend-article +article-a+ (get-qualified-name *player*)) (stat-raised-dead *player*)) (new-line on-screen))) (format str " The Scrooge: ~A~A~%" (if (zerop (calculate-total-value (find-mob-with-max-value))) (format nil "-") (format nil "~A with ~A$ worth of items" (prepend-article +article-a+ (get-qualified-name (find-mob-with-max-value))) (calculate-total-value (find-mob-with-max-value)))) (new-line on-screen)) (if (and (not (eq *player* (find-mob-with-max-value))) (not (zerop (calculate-total-value *player*)))) (format str " vs ~A~A~%" (format nil "~A with ~A$ worth of items" (prepend-article +article-a+ (get-qualified-name *player*)) (calculate-total-value *player*)) (new-line on-screen))) str)) (defun dump-character-on-game-over (player-name score game-time layout-str final-str scenario-stats) (declare (ignore player-name)) (multiple-value-bind (second minute hour date month year day daylight-p zone) (get-decoded-time) (declare (ignore day daylight-p zone)) (let* ((file-name (format nil "~A-~A-~4,'0d-~2,'0d-~2,'0d-~2,'0d-~2,'0d-~2,'0d.txt" (get-qualified-name *player*) score year month date hour minute second)) (dir-path (merge-pathnames "morgue/" *current-dir*))) (ensure-directories-exist dir-path) (with-open-file (file (merge-pathnames file-name dir-path) :direction :output :if-exists :supersede) (format file "~A - ~4,'0d-~2,'0d-~2,'0d ~2,'0d:~2,'0d:~2,'0d~A~%" (get-qualified-name *player*) year month date hour minute second (new-line)) (format file "~A~%" (new-line)) (format file "Mission: ~A~A~%" (name (mission (level *world*))) (new-line)) (format file "Game time: ~D turn~:P~A~%" game-time (new-line)) (format file "Game score: ~A~A~%" score (new-line)) (format file "Layout: ~A~A~%" layout-str (new-line)) (format file "~A~A~%" final-str (new-line)) (format file "~A~%" (new-line)) (format file "~A~A~%" scenario-stats (new-line)) (format file "~A~%" (new-line)) (let ((x 6) (y (+ 40 (* 13 (sdl:get-font-height)))) (w 800) (h (- 520 40 10 (sdl:char-height sdl:*default-font*) (* 14 (sdl:get-font-height))))) (sdl:with-rectangle (rect (sdl:rectangle :x x :y y :w w :h h)) (let ((max-lines (write-text (get-msg-str-list (level/full-message-box (level *world*))) rect :count-only t))) (when (> (message-list-length) 0) (multiple-value-bind (max-lines final-txt) (write-text (get-msg-str-list (level/full-message-box (level *world*))) rect :start-line (if (< (truncate h (sdl:char-height sdl:*default-font*)) max-lines) (- max-lines (truncate h (sdl:char-height sdl:*default-font*))) 0) :count-only t) (declare (ignore max-lines)) (format file "~A~A~%" final-txt (new-line)) ))))) ))))
13,088
Common Lisp
.lisp
190
51.357895
240
0.520555
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
bbd4cee2db7f7ab067e3649e7642a4248525bdb46e614e8fcb7e209ea7374bcf
2,883
[ -1 ]
2,884
base-methods.lisp
gwathlobal_CotD/src/base-methods.lisp
(in-package :cotd) (defun find-free-id (array) (loop for i from 0 below (length array) unless (aref array i) do (return-from find-free-id i)) (adjust-array array (list (1+ (length array)))) (1- (length array))) (defun capitalize-name (str) (string-upcase str :start 0 :end 1)) (defun x-y-into-dir (x y) (let ((xy (list x y))) (cond ((equal xy '(-1 1)) 1) ((equal xy '(0 1)) 2) ((equal xy '(1 1)) 3) ((equal xy '(-1 0)) 4) ((equal xy '(0 0)) 5) ((equal xy '(1 0)) 6) ((equal xy '(-1 -1)) 7) ((equal xy '(0 -1)) 8) ((equal xy '(1 -1)) 9) (t nil)))) (defun x-y-into-str (xy-cons) (cond ((equal xy-cons '(-1 . 1)) "SW") ((equal xy-cons '(0 . 1)) "S") ((equal xy-cons '(1 . 1)) "SE") ((equal xy-cons '(-1 . 0)) "W") ((equal xy-cons '(0 . 0)) "None") ((equal xy-cons '(1 . 0)) "E") ((equal xy-cons '(-1 . -1)) "NW") ((equal xy-cons '(0 . -1)) "N") ((equal xy-cons '(1 . -1)) "NE") (t "ERR"))) (defun x-y-dir (dir) "Determine the x-y coordinate change from the single number specifying direction" (cond ((eql dir 1) (values-list '(-1 1))) ((eql dir 2) (values-list '(0 1))) ((eql dir 3) (values-list '(1 1))) ((eql dir 4) (values-list '(-1 0))) ((eql dir 5) (values-list '(0 0))) ((eql dir 6) (values-list '(1 0))) ((eql dir 7) (values-list '(-1 -1))) ((eql dir 8) (values-list '(0 -1))) ((eql dir 9) (values-list '(1 -1))) (t (error "Wrong direction supplied!!!")))) (defun dir-neighbours (dir) ;; find the neighbours of the direction ;; the result is <along the direction> <not along the direction> <to the left from the direction> <to the right from the direction> <near the opposite direction> <opposite the direction> ;; for more info see the move-mob func (cond ((eql dir 1) (values-list '((4 1 2) (3 6 7 8) (3 6) (7 8) (8 6) (9)))) ((eql dir 2) (values-list '((1 2 3) (4 6 7 9) (6 9) (4 7) (7 9) (8)))) ((eql dir 3) (values-list '((2 3 6) (1 4 8 9) (9 8) (1 4) (4 8) (7)))) ((eql dir 4) (values-list '((1 4 7) (8 2 9 3) (2 3) (8 9) (9 3) (6)))) ((eql dir 5) (values-list '((1 2 3 4 5 6 7 8 9) () () () () ()))) ((eql dir 6) (values-list '((9 6 3) (8 2 7 1) (8 7) (2 1) (7 1) (4)))) ((eql dir 7) (values-list '((4 7 8) (1 9 2 6) (1 2) (9 3) (6 2) (3)))) ((eql dir 8) (values-list '((7 8 9) (4 6 1 3) (4 1) (6 3) (1 3) (2)))) ((eql dir 9) (values-list '((8 9 6) (7 3 4 2) (7 4) (3 2) (4 2) (1)))) (t (error "Wrong direction supplied!!!")))) (defun check-surroundings (x y include-center func) (dotimes (x1 3) (dotimes (y1 3) (when include-center (funcall func (+ (1- x) x1) (+ (1- y) y1))) (when (and (eql include-center nil) (or (/= (+ (1- x) x1) x) (/= (+ (1- y) y1) y))) (funcall func (+ (1- x) x1) (+ (1- y) y1)))))) (defun check-surroundings-3d (x y z include-center func) (loop for dx from -1 to 1 do (loop for dy from -1 to 1 do (loop for dz from -1 to 1 do (cond ((and include-center (= dx dy dz 0)) (funcall func (+ x dx) (+ y dy) (+ z dz))) ((and (not include-center) (= dx dy dz 0)) nil) (t (funcall func (+ x dx) (+ y dy) (+ z dz)))))))) (defun print-visible-message (x y z level str &key (observed-mob nil) (color sdl:*white*) (tags ())) (when (member :singlemind tags) (setf color *shared-mind-msg-color*)) (when (and (options-ignore-singlemind-messages *options*) (member :singlemind tags)) (return-from print-visible-message nil)) (when (or (and (null observed-mob) (get-single-memo-visibility (get-memo-* level x y z))) (and observed-mob (get-single-memo-visibility (get-memo-* level x y z)) (check-mob-visible observed-mob :observer *player* :complete-check t))) (set-message-this-turn t) (add-message str color))) (defun place-animation (x y z animation-type-id &key (params nil)) (when (and (= z (z *player*)) (> x (- (x *player*) (truncate *max-x-view* 2))) (< x (+ (x *player*) (truncate *max-x-view* 2))) (> y (- (y *player*) (truncate *max-y-view* 2))) (< y (+ (y *player*) (truncate *max-y-view* 2)))) (push (make-animation :id animation-type-id :x x :y y :z z :params params) (animation-queue (level *world*))))) (defun process-animations-on-level (level) (when (animation-queue level) ;;(format t "~%TIME-ELAPSED AI ~A [~A] before animations: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) (loop for animation in (animation-queue (level *world*)) do (play-animation animation)) (sdl:update-display) (sdl-cffi::sdl-delay 100) (setf (animation-queue (level *world*)) nil) (update-map-area *start-map-x* 0) ;;(format t "~%TIME-ELAPSED AI ~A [~A] after all animations: ~A~%" (name mob) (id mob) (- (get-internal-real-time) *time-at-end-of-player-turn*)) )) (defun check-move-on-level (mob dx dy dz) (let ((sx) (sy) (mob-list nil) (obst-list nil)) ;; calculate the coords of the mob's NE corner (setf sx (- dx (truncate (1- (map-size mob)) 2))) (setf sy (- dy (truncate (1- (map-size mob)) 2))) (loop for nx from sx below (+ sx (map-size mob)) do (loop for ny from sy below (+ sy (map-size mob)) do ;; trying to move beyound the level border (when (or (< nx 0) (< ny 0) (>= nx *max-x-level*) (>= ny *max-y-level*)) (return-from check-move-on-level nil)) ;; checking for obstacle (when (get-terrain-type-trait (get-terrain-* (level *world*) nx ny dz) +terrain-trait-blocks-move+) ;(return-from check-move-on-level nil) (pushnew (list nx ny dz) obst-list) ) (when obst-list (return-from check-move-on-level (list :obstacles obst-list))) ;; checking for mobs (when (and (get-mob-* (level *world*) nx ny dz) (not (eq (get-mob-* (level *world*) nx ny dz) mob)) (or (eq (mounted-by-mob-id mob) nil) (not (eq (mounted-by-mob-id mob) (id (get-mob-* (level *world*) nx ny dz)))))) (pushnew (get-mob-* (level *world*) nx ny dz) mob-list) ))) (when mob-list (return-from check-move-on-level (list :mobs mob-list))) ;; all checks passed - can move freely (return-from check-move-on-level t))) (defun check-move-along-z (sx sy sz dx dy dz) (cond ;; move down ((< (- dz sz) 0) (progn (if (and (>= dz 0) (not (get-terrain-type-trait (get-terrain-* (level *world*) dx dy (1+ dz)) +terrain-trait-blocks-move-floor+)) ) t nil))) ;; move up ((> (- dz sz) 0) (progn (if (and (< dz (array-dimension (terrain (level *world*)) 2)) (not (get-terrain-type-trait (get-terrain-* (level *world*) sx sy dz) +terrain-trait-blocks-move-floor+)) ) t nil))) ;; no vertical movement (t t))) (defmethod apply-gravity ((mob mob)) (let ((result 0)) (if (or (and (mob-effect-p mob +mob-effect-flying+) (not (eq (cd (get-effect-by-id (mob-effect-p mob +mob-effect-flying+))) 0))) (mob-ability-p mob +mob-abil-flying+)) (setf result (z mob)) (loop for z from (z mob) downto 0 for check-result = (check-move-on-level mob (x mob) (y mob) z) do ;(format t "Z ~A FLOOR ~A~%" z (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) z) +terrain-trait-blocks-move-floor+)) (when (eq check-result t) (setf result z)) ;(format t "MOB ~A, Z = ~A, Z MOB = ~A, WATER = ~A~%" (name mob) z (z mob) (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) z) +terrain-trait-water+)) ;; stop falling if (when (or (not (eq check-result t)) ;; if there is water in the current tile (and (/= z (z mob)) (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) z) +terrain-trait-water+) ) ;; there is floor on this tile (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) z) +terrain-trait-blocks-move-floor+) ;; there is no floor on this tile, but the mob is in climbing mode and there is a wall or a floor nearby (and (not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) z) +terrain-trait-blocks-move-floor+)) (mob-effect-p mob +mob-effect-climbing-mode+) (funcall #'(lambda () (let ((result nil)) (check-surroundings (x mob) (y mob) nil #'(lambda (dx dy) (when (and (not (get-terrain-type-trait (get-terrain-* (level *world*) dx dy z) +terrain-trait-not-climable+)) (or (get-terrain-type-trait (get-terrain-* (level *world*) dx dy z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) dx dy z) +terrain-trait-blocks-move+))) (setf result t)))) result)))) ) (loop-finish)))) (when (eq result (z mob)) (setf result nil)) result)) (defmethod apply-gravity ((feature feature)) (let ((result 0)) (loop for z from (z feature) downto 0 do (when (or (get-terrain-type-trait (get-terrain-* (level *world*) (x feature) (y feature) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) (x feature) (y feature) z) +terrain-trait-water+)) (setf result z) (loop-finish))) (when (eq result (z feature)) (setf result nil)) result)) (defmethod apply-gravity ((item item)) (let ((result 0)) (loop for z from (z item) downto 0 do (when (or (get-terrain-type-trait (get-terrain-* (level *world*) (x item) (y item) z) +terrain-trait-blocks-move-floor+) (and (>= (1- z) 0) (get-terrain-type-trait (get-terrain-* (level *world*) (x item) (y item) (1- z)) +terrain-trait-blocks-move+))) (setf result z) (loop-finish))) (when (eq result (z item)) (setf result nil)) result)) (defun generate-sound (source-mob sx sy sz sound-power str-func &key (force-sound nil)) (when (zerop sound-power) (return-from generate-sound nil)) (loop for mob-id in (hear-range-mobs source-mob) for tmob = (get-mob-by-id mob-id) do (propagate-sound-from-location tmob sx sy sz sound-power str-func :source source-mob :force-sound force-sound))) (defun set-mob-location (mob x y z &key (apply-gravity t)) (log:debug "BEFORE: ~A [~A] (~A ~A ~A) to (~A ~A ~A) gravity = ~A" (name mob) (id mob) (x mob) (y mob) (z mob) x y z apply-gravity) (let ((place-func #'(lambda (nmob) (let ((sx) (sy)) ;; calculate the coords of the mob's NE corner (setf sx (- (x nmob) (truncate (1- (map-size nmob)) 2))) (setf sy (- (y nmob) (truncate (1- (map-size nmob)) 2))) ;; remove the mob from the orignal position ;; for size 1 (standard) mobs the loop executes only once, so it devolves into traditional movement (loop for nx from sx below (+ sx (map-size nmob)) do (loop for ny from sy below (+ sy (map-size nmob)) do ;; TODO: disabled due to a bug when the creature dies on razorthorns here but then continue to be placed on the level as usual ;;(when (on-step (get-terrain-type-by-id (get-terrain-* (level *world*) nx ny (z nmob)))) ;; (funcall (on-step (get-terrain-type-by-id (get-terrain-* (level *world*) nx ny (z nmob)))) nmob nx ny (z nmob))) (setf (aref (mobs (level *world*)) nx ny (z nmob)) nil))) (setf (aref (mob-quadrant-map (level *world*)) (truncate (x nmob) 10) (truncate (y nmob) 10)) (remove (id nmob) (aref (mob-quadrant-map (level *world*)) (truncate (x nmob) 10) (truncate (y nmob) 10)))) ;; change the coords of the center of the mob (setf (x nmob) x (y nmob) y (z nmob) z) (push (id nmob) (aref (mob-quadrant-map (level *world*)) (truncate (x nmob) 10) (truncate (y nmob) 10))) ;; calculate the new coords of the mob's NE corner (setf sx (- (x nmob) (truncate (1- (map-size nmob)) 2))) (setf sy (- (y nmob) (truncate (1- (map-size nmob)) 2))) ;; place the mob to the new position ;; for size 1 (standard) mobs the loop executes only once, so it devolves into traditional movement (loop for nx from sx below (+ sx (map-size nmob)) do (loop for ny from sy below (+ sy (map-size nmob)) do (setf (aref (mobs (level *world*)) nx ny z) (id nmob)) (when (on-step (get-terrain-type-by-id (get-terrain-* (level *world*) nx ny z))) (funcall (on-step (get-terrain-type-by-id (get-terrain-* (level *world*) nx ny z))) nmob nx ny z))))))) (orig-x (x mob)) (orig-y (y mob)) (orig-z (z mob))) ;; we have 3 cases of movement: ;; 1) the mob moves while is riding someone (currently available if the mob teleports somewhere with a mount, as normally the rider does not move, only gives directions to the mount) ;; 2) the mob moves while being ridden by someone (all kinds of mounted movement) ;; 3) the mob moves by itself (cond ((riding-mob-id mob) (progn ;; it is imperative the a 1-tile mob rides a multi-tile mob and not vice versa (if (and (= (x (get-mob-by-id (riding-mob-id mob))) x) (= (y (get-mob-by-id (riding-mob-id mob))) y) (= (z (get-mob-by-id (riding-mob-id mob))) z)) (incf-mob-motion (get-mob-by-id (riding-mob-id mob)) *mob-motion-stand*) (incf-mob-motion (get-mob-by-id (riding-mob-id mob)) *mob-motion-move*)) ;; remove the rider from the prev location (setf (aref (mobs (level *world*)) (x mob) (y mob) (z mob)) nil) (funcall place-func (get-mob-by-id (riding-mob-id mob))) (setf (aref (mob-quadrant-map (level *world*)) (truncate (x mob) 10) (truncate (y mob) 10)) (remove (id mob) (aref (mob-quadrant-map (level *world*)) (truncate (x mob) 10) (truncate (y mob) 10)))) ;; place the rider (setf (x mob) x (y mob) y (z mob) z) (setf (aref (mobs (level *world*)) x y z) (id mob)) (push (id mob) (aref (mob-quadrant-map (level *world*)) (truncate (x mob) 10) (truncate (y mob) 10))) ;; set motion (if (and (= orig-x x) (= orig-y y) (= orig-z z)) (incf-mob-motion mob *mob-motion-stand*) (incf-mob-motion mob *mob-motion-move*)) )) ((mounted-by-mob-id mob) (progn ;; it is imperative the a 1-tile mob rides a multi-tile mob and not vice versa (let ((rider-orig-x (x (get-mob-by-id (mounted-by-mob-id mob)))) (rider-orig-y (y (get-mob-by-id (mounted-by-mob-id mob)))) (rider-orig-z (z (get-mob-by-id (mounted-by-mob-id mob)))) (rider (get-mob-by-id (mounted-by-mob-id mob)))) ;; remove the rider from the prev location (setf (aref (mobs (level *world*)) rider-orig-x rider-orig-y rider-orig-z) nil) (funcall place-func mob) (setf (aref (mob-quadrant-map (level *world*)) (truncate (x rider) 10) (truncate (y rider) 10)) (remove (id rider) (aref (mob-quadrant-map (level *world*)) (truncate (x rider) 10) (truncate (y rider) 10)))) ;; place the rider (setf (x rider) x (y rider) y (z rider) z) (setf (aref (mobs (level *world*)) (x mob) (y mob) (z mob)) (id rider)) (push (id rider) (aref (mob-quadrant-map (level *world*)) (truncate (x rider) 10) (truncate (y rider) 10))) ;; set motion (if (and (= orig-x x) (= orig-y y) (= orig-z z)) (incf-mob-motion mob *mob-motion-stand*) (incf-mob-motion mob *mob-motion-move*)) (if (and (= rider-orig-x x) (= rider-orig-y y) (= rider-orig-z z)) (progn (incf-mob-motion rider *mob-motion-stand*) ;; generate sound (when (not (mob-ability-p mob +mob-abil-float+)) (generate-sound rider x y z *mob-sound-stand* #'(lambda (str) (format nil "You hear some scratching~A. " str))))) (progn (incf-mob-motion rider *mob-motion-move*) ;; generate sound (when (not (mob-ability-p mob +mob-abil-float+)) (generate-sound rider x y z *mob-sound-move* #'(lambda (str) (format nil "You hear rustling~A. " str)))) )) ))) (t (progn (funcall place-func mob) ;; set motion (if (and (= orig-x x) (= orig-y y) (= orig-z z)) (progn (incf-mob-motion mob *mob-motion-stand*) ;; generate sound (when (not (mob-ability-p mob +mob-abil-float+)) (generate-sound mob x y z *mob-sound-stand* #'(lambda (str) (format nil "You hear some scratching~A. " str))))) (progn (incf-mob-motion mob *mob-motion-move*) ;; generate sound (when (not (mob-ability-p mob +mob-abil-float+)) (generate-sound mob x y z *mob-sound-move* #'(lambda (str) (format nil "You hear rustling~A. " str)))) )) ))) ;; apply gravity (let ((init-z (z mob)) (final-z nil) (cur-dmg 0)) () (when (and apply-gravity (setf final-z (apply-gravity mob)) (not (check-dead mob))) (set-mob-location mob (x mob) (y mob) final-z :apply-gravity nil) ;; do not take any damage if you can float (when (or (not (mob-ability-p mob +mob-abil-float+)) (and (mob-ability-p mob +mob-abil-float+) (slave-mob-id mob))) (setf cur-dmg (* 5 (1- (- init-z (z mob))))) (decf (cur-hp mob) cur-dmg) (when (> cur-dmg 0) (cond ((eq mob *player*) (progn ;; a hack because sometimes the player may fall somewhere he does not see (when riding a horse for example) and then no message will be displayed normally (set-message-this-turn t) (add-message (format nil "~A falls and takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) cur-dmg) (if (eq *player* mob) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*)) ;; show message for LOW HP (when (and (eq *player* mob) (< (/ (cur-hp mob) (max-hp mob)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)) (when (check-dead mob) (setf (killed-by *player*) "falling")))) ((eq (id mob) (riding-mob-id *player*)) (progn ;; a hack because sometimes the player's horse may fall somewhere he does not see and then no message will be displayed normally (set-message-this-turn t) (add-message (format nil "~A falls and takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) cur-dmg) (if (eq *player* mob) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*)))) (t (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A falls and takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) cur-dmg) :observed-mob mob :color (if (eq *player* mob) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind)))))) (when (check-dead mob) (make-dead mob :splatter t :msg t :msg-newline nil :killer nil :corpse t :aux-params ()) (when (slave-mob-id mob) (setf (cur-hp (get-mob-by-id (slave-mob-id mob))) 0) (setf (x (get-mob-by-id (slave-mob-id mob))) (x mob) (y (get-mob-by-id (slave-mob-id mob))) (y mob) (z (get-mob-by-id (slave-mob-id mob))) (z mob)) (make-dead (get-mob-by-id (slave-mob-id mob)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type mob) +mob-type-ghost+) t nil) :aux-params ()))))) ) ;; apply gravity to the mob, standing on your head, if any (when (and (get-terrain-* (level *world*) orig-x orig-y (1+ orig-z)) (not (get-terrain-type-trait (get-terrain-* (level *world*) orig-x orig-y (1+ orig-z)) +terrain-trait-blocks-move-floor+)) (get-mob-* (level *world*) orig-x orig-y (1+ orig-z)) (not (eq mob (get-mob-* (level *world*) orig-x orig-y (1+ orig-z)))) (and (mounted-by-mob-id mob) (not (eq (get-mob-by-id (mounted-by-mob-id mob)) (get-mob-* (level *world*) orig-x orig-y (1+ orig-z)))))) (set-mob-location (get-mob-* (level *world*) orig-x orig-y (1+ orig-z)) orig-x orig-y (1+ orig-z))) ;; check if the mob is constricting somebody or being constricted and if the effect should be broken (when (mob-effect-p mob +mob-effect-constriction-source+) (let ((effect (get-effect-by-id (mob-effect-p mob +mob-effect-constriction-source+)))) (when (or (/= (first (first (param1 effect))) (x mob)) (/= (second (first (param1 effect))) (y mob)) (/= (third (first (param1 effect))) (z mob))) (rem-mob-effect mob +mob-effect-constriction-source+)))) (when (mob-effect-p mob +mob-effect-constriction-target+) (let ((effect (get-effect-by-id (mob-effect-p mob +mob-effect-constriction-target+)))) (when (or (/= (first (param1 effect)) (x mob)) (/= (second (param1 effect)) (y mob)) (/= (third (param1 effect)) (z mob))) (rem-mob-effect mob +mob-effect-constriction-target+)))) ) (log:debug "AFTER: ~A [~A] (~A ~A ~A)" (name mob) (id mob) (x mob) (y mob) (z mob))) (defun move-mob (mob dir &key (push nil) (dir-z 0)) (let ((dx 0) (dy 0) (sx (x mob)) (sy (y mob)) (along-dir) (opposite-dir) (not-along-dir) (near-opposite-dir) (to-the-left-dir) (to-the-right-dir) (c-dir)) (declare (type fixnum dx dy)) ;; if immobile - do not move (when (or (mob-ability-p mob +mob-abil-immobile+) (mob-effect-p mob +mob-abil-immobile+)) (setf dir 5) (setf dir-z 0)) ;; if being ridden - restore the direction from the order being given by the rider (when (and (mounted-by-mob-id mob) (order-for-next-turn mob)) (setf dir (first (order-for-next-turn mob))) (setf dir-z (second (order-for-next-turn mob)))) (multiple-value-setq (dx dy) (x-y-dir dir)) ;; if riding somebody, only give an order to your mount but do not move yourself (when (riding-mob-id mob) (log:info "~A [~A] gives orders to mount ~A [~A] to move in the dir ~A" (name mob) (id mob) (name (get-mob-by-id (riding-mob-id mob))) (id (get-mob-by-id (riding-mob-id mob))) dir) ;; assign the order for the mount for its next turn (setf (order-for-next-turn (get-mob-by-id (riding-mob-id mob))) (list dir dir-z)) ;; perform the attack in the chosen direction (otherwise it will be only the mount that attacks) (let ((check-result (check-move-on-level mob (+ (x mob) dx) (+ (y mob) dy) (+ (z mob) dir-z)))) ;; right now multi-tile mobs can not ride other multitile mobs and I intend to leave it this way ;; this means that there will always be only one mob in the affected mob list (when (and check-result (not (eq check-result t)) (eq (first check-result) :mobs) (not (eq (get-mob-by-id (riding-mob-id mob)) (first (second check-result))))) (on-bump (first (second check-result)) mob) (return-from move-mob check-result)) (when (or (eq check-result nil) (and (eq (check-move-on-level (get-mob-by-id (riding-mob-id mob)) (+ (x mob) dx) (+ (y mob) dy) (+ (z mob) dir-z)) nil) (= dir (x-y-into-dir (car (momentum-dir (get-mob-by-id (riding-mob-id mob)))) (cdr (momentum-dir (get-mob-by-id (riding-mob-id mob)))))))) (log:info "~A [~A] is unable to move to give order (CHECK = ~A, MOUNT DIR ~A)" (name mob) (id mob) check-result (x-y-into-dir (car (momentum-dir (get-mob-by-id (riding-mob-id mob)))) (cdr (momentum-dir (get-mob-by-id (riding-mob-id mob)))))) (return-from move-mob nil))) ;; set motion (incf-mob-motion mob *mob-motion-order*) (make-act mob (truncate (* (cur-move-speed mob) (move-spd (get-mob-type-by-id (mob-type mob)))) 100)) (return-from move-mob t)) (setf c-dir (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob)))) (multiple-value-setq (along-dir not-along-dir to-the-left-dir to-the-right-dir near-opposite-dir opposite-dir) (dir-neighbours c-dir)) (when (mob-ability-p mob +mob-abil-momentum+) (setf push t)) (log:debug "~A - spd ~A, c-dir ~A, dir ~A, dir-z ~A, ALONG-DIRS ~A, NOT-ALONG-DIRS ~A, OPPOSITE-DIRS ~A" (name mob) (momentum-spd mob) c-dir dir dir-z along-dir not-along-dir opposite-dir) (cond ;; NB: all this is necessary to introduce movement with momentum (for horses and the like) ;; (-1.-1) ( 0.-1) ( 1.-1) ;; (-1. 0) ( 0. 0) ( 1. 0) ;; (-1. 1) ( 0. 1) ( 1. 1) ;; if mob already moving in the direction ( 1. 1), then the chosen direction can be ;; "opposite direction" which is (-1.-1) ;; "along the direction" which is ( 1. 1), ( 0. 1) or ( 1. 0) ;; "not along the direction" which is (-1. 1), (-1. 0), ( 1.-1) or ( 0.-1) ;; "direction to the left" which is ( 1. -1) or ( 0.-1), note that mob's direction will be set to ( 1.-1) when the mob tries to change its direction abruptly ;; "direction to the right" which is (-1. 1) or (-1. 0), note that mob's direction will be set to (-1. 1) when the mob tries to change its direction abruptly ;; "near the opposite direction" which is (-1. 0) or ( 0.-1) ;; if speed is 0 or moving along the direction - increase spead and set the movement dir to chosen dir ((or (and (not (mob-ability-p mob +mob-abil-facing+)) (zerop (momentum-spd mob)) (/= dir 5)) (and (/= dir 5) (find dir along-dir))) (progn (incf (momentum-spd mob)) (setf (car (momentum-dir mob)) dx) (setf (cdr (momentum-dir mob)) dy) (log:debug "MOVE-MOB ALONG - SPD ~A DIR ~A DX ~A DY ~A" (momentum-spd mob) (momentum-dir mob) dx dy))) ;; if moving in the opposite direction - reduce speed ((find dir opposite-dir) (progn (decf (momentum-spd mob)) ;; if the mob is has facing, choose one of the directions neighbouring the opposite one, so that he turns around using this direction (when (mob-ability-p mob +mob-abil-facing+) (multiple-value-setq (along-dir not-along-dir to-the-left-dir to-the-right-dir near-opposite-dir opposite-dir) (dir-neighbours dir)) (if (zerop (random 2)) (multiple-value-setq (dx dy) (x-y-dir (first near-opposite-dir))) (multiple-value-setq (dx dy) (x-y-dir (second near-opposite-dir)))) (setf (car (momentum-dir mob)) dx) (setf (cdr (momentum-dir mob)) dy) (setf dx 0 dy 0)) (log:debug "MOVE-MOB OPPOSITE - SPD ~A DIR ~A DX ~A DY ~A" (momentum-spd mob) (momentum-dir mob) dx dy))) ;; if moving not along the direction - reduce spead and change the direction ((find dir not-along-dir) (progn (decf (momentum-spd mob)) ;; change direction either to the left or to the right depending on where the proposed direction lies (if (find dir to-the-left-dir) (multiple-value-setq (dx dy) (x-y-dir (first to-the-left-dir))) (multiple-value-setq (dx dy) (x-y-dir (first to-the-right-dir)))) (setf (car (momentum-dir mob)) dx) (setf (cdr (momentum-dir mob)) dy) (when (mob-ability-p mob +mob-abil-facing+) (setf dx 0 dy 0)) (log:debug "MOVE-MOB NOT ALONG - SPD ~A DIR ~A DX ~A DY ~A" (momentum-spd mob) (momentum-dir mob) dx dy))) ) ;; normalize direction ;; for x axis (when (> (car (momentum-dir mob)) 1) (setf (car (momentum-dir mob)) 1)) (when (< (car (momentum-dir mob)) -1) (setf (car (momentum-dir mob)) -1)) ;; for y axis (when (> (cdr (momentum-dir mob)) 1) (setf (cdr (momentum-dir mob)) 1)) (when (< (cdr (momentum-dir mob)) -1) (setf (cdr (momentum-dir mob)) -1)) ;; limit max speed (when (and (mob-ability-p mob +mob-abil-momentum+) (> (momentum-spd mob) (mob-ability-value mob +mob-abil-momentum+))) (setf (momentum-spd mob) (mob-ability-value mob +mob-abil-momentum+))) (when (not (mob-ability-p mob +mob-abil-momentum+)) (setf (momentum-spd mob) 0)) (when (< (momentum-spd mob) 0) (setf (momentum-spd mob) 0)) (when (mob-ability-p mob +mob-abil-momentum+) (setf dx (car (momentum-dir mob))) (setf dy (cdr (momentum-dir mob)))) (when (/= dir 5) (setf dir-z 0)) (loop repeat (if (zerop (momentum-spd mob)) 1 (momentum-spd mob)) for move-result = nil for move-spd = (truncate (* (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-move-cost-factor+) (truncate (* (cur-move-speed mob) (move-spd (get-mob-type-by-id (mob-type mob)))) 100))) for x = (+ (x mob) dx) for y = (+ (y mob) dy) for z = (cond ;; if the current cell is water and the cell along the direction is a wall - increase target z level, so that the mob can climb up ((and (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* (level *world*) x y (z mob)) +terrain-trait-blocks-move+)) (1+ (z mob))) ;; if the current cell is slope up and the cell along the direction is a wall - increase the target z level, so that the mob can go up ((and (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-slope-up+) (get-terrain-type-trait (get-terrain-* (level *world*) x y (z mob)) +terrain-trait-blocks-move+)) (1+ (z mob))) ;; if the target cell is slope down - decrease the target z level, so that the mob can go down ((and (not (mob-effect-p mob +mob-effect-climbing-mode+)) (get-terrain-type-trait (get-terrain-* (level *world*) x y (z mob)) +terrain-trait-slope-down+)) (1- (z mob))) ((and (< dir-z 0) (= (z mob) 0)) 0) ((and (> dir-z 0) (= (z mob) (1- (array-dimension (terrain (level *world*)) 2)))) 0) ;; otherwise the z level in unchanged (t (+ (z mob) dir-z))) for apply-gravity = (if (or ;(not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+)) ;(not (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-water+)) (and (not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+)) (not (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-water+))) (and (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+) (not (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-water+))) (and (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-water+) (= z (z mob)) (= dx 0) (= dy 0))) t nil) for check-result = (if (check-move-along-z (x mob) (y mob) (z mob) x y z) (check-move-on-level mob x y z) nil) do (log:debug "CHECK-MOVE ~A, XYZ = (~A ~A ~A)" check-result x y z) ;; TODO: replace this hack with something more solid (when (check-dead mob) (loop-finish)) (cond ;; all clear - move freely ((eq check-result t) (when (and (= z (z mob)) (= x (x mob)) (= y (y mob))) (setf move-spd (truncate (* (cur-move-speed mob) (move-spd (get-mob-type-by-id (mob-type mob)))) 100))) ;(format t "APPLY-GRAVITY ~A~%" apply-gravity) (set-mob-location mob x y z :apply-gravity apply-gravity) (when (not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+)) (setf dir-z 0)) (setf move-result t) ) ;; bumped into an obstacle or the map border ((or (eq check-result nil) (eq (first check-result) :obstacles)) (when (mob-ability-p mob +mob-abil-momentum+) (setf (momentum-spd mob) 0) (setf (momentum-dir mob) (cons 0 0))) (setf (order-for-next-turn mob) (list 5 0)) ;; if the obstacle is bumpable - bump & exit (when (and (eq (first check-result) :obstacles) (get-terrain-on-bump (get-terrain-* (level *world*) x y z)) (funcall (get-terrain-on-bump (get-terrain-* (level *world*) x y z)) mob x y z)) (setf move-result :ability-invoked) (loop-finish)) ;; a precaution so that horses finish their turn when they made a move and bumped into an obstacle ;; while not finishing their turn if they try to move into an obstacle standing next to it (when (or (/= sx (x mob)) (/= sy (y mob)) (and (mob-ability-p mob +mob-abil-facing+) (/= c-dir (x-y-into-dir dx dy))) ) (make-act mob move-spd)) (setf move-result nil) (loop-finish) ) ;; bumped into a mob ((eq (first check-result) :mobs) (log:info "~A [~A] bumped into mobs (~A)" (name mob) (id mob) (loop named nil with str = (create-string) for tmob in (second check-result) do (format str "~A [~A], " (name tmob) (id tmob)) finally (return-from nil str))) (loop with cur-ap = (cur-ap mob) for target-mob in (second check-result) do ;; if the mount bumps into its rider - do nothing (if (and (mounted-by-mob-id mob) (eq target-mob (get-mob-by-id (mounted-by-mob-id mob)))) (progn (setf move-result t)) (progn (when (and push (not (mob-ability-p target-mob +mob-abil-immovable+))) ;; check if you can push the mob farther (let* ((nx (+ (car (momentum-dir mob)) (x target-mob))) (ny (+ (cdr (momentum-dir mob)) (y target-mob))) (check-result-n (check-move-on-level target-mob nx ny z))) (when (eq check-result-n t) (incf-mob-motion mob *mob-motion-move*) (incf-mob-motion target-mob *mob-motion-move*) (set-mob-location target-mob nx ny z :apply-gravity (if (or (not (get-terrain-type-trait (get-terrain-* (level *world*) (x target-mob) (y target-mob) (z target-mob)) +terrain-trait-water+)) (and (get-terrain-type-trait (get-terrain-* (level *world*) (x target-mob) (y target-mob) (z target-mob)) +terrain-trait-water+) (= z (+ (z target-mob) dir-z)) (= dx 0) (= dy 0))) t nil)) (set-mob-location mob x y z :apply-gravity apply-gravity) (when (or (check-mob-visible mob :observer *player*) (check-mob-visible target-mob :observer *player*)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A pushes ~A. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) (prepend-article +article-the+ (visible-name target-mob))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) )) (on-bump target-mob mob))) finally (when (> (map-size mob) 1) (setf (cur-ap mob) cur-ap) (make-act mob (get-melee-weapon-speed mob)))) (when (eq move-result t) (loop-finish)) (when (mob-ability-p mob +mob-abil-momentum+) (setf (momentum-spd mob) 0) (setf (momentum-dir mob) (cons 0 0))) (setf move-result check-result) (loop-finish)) ) finally (setf (order-for-next-turn mob) nil) (cond ((mob-ability-p mob +mob-abil-momentum+) (when (zerop (momentum-spd mob)) (setf (momentum-dir mob) (cons 0 0)))) ((mob-ability-p mob +mob-abil-facing+) nil) (t (setf (momentum-dir mob) (cons 0 0)))) (when (eq move-result t) (make-act mob move-spd)) (return-from move-mob move-result)) ) nil) (defun make-act (mob speed) (log:info "~A SPD ~A" (name mob) speed) (when (zerop speed) (return-from make-act nil)) (decf (cur-ap mob) (truncate (* speed (cur-speed mob)) 100)) (setf (made-turn mob) t) (when (eq mob *player*) (incf (world-game-time *world*) (truncate (* speed +normal-ap+) (max-ap mob))))) (defun stumble-upon-mob (actor target) (log:info "~A [~A] stumbled upon ~A [~A]~%" (name actor) (id actor) (name target) (id target)) (set-mob-effect actor :effect-type-id +mob-effect-alertness+ :actor-id (id actor) :cd 5) (incf-mob-motion target 100) (pushnew (id actor) (visible-mobs target)) (when (riding-mob-id target) (pushnew (id actor) (visible-mobs (get-mob-by-id (riding-mob-id target))))) (when (mounted-by-mob-id target) (pushnew (id actor) (visible-mobs (get-mob-by-id (mounted-by-mob-id target))))) (pushnew (id target) (visible-mobs actor)) (when (riding-mob-id actor) (pushnew (id target) (visible-mobs (get-mob-by-id (riding-mob-id actor))))) (when (mounted-by-mob-id actor) (pushnew (id target) (visible-mobs (get-mob-by-id (mounted-by-mob-id actor))))) (when (or (eq *player* actor) (eq *player* target) (check-mob-visible actor :observer *player* :complete-check t) (check-mob-visible target :observer *player* :complete-check t)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A stumbles upon ~A! " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ) (defmethod on-bump ((target mob) (actor mob)) (if (eql target actor) (progn (make-act actor (truncate (* (cur-move-speed actor) (move-spd (get-mob-type-by-id (mob-type actor)))) 100))) (progn (log:info "~A [~A] bumped into ~A [~A]" (name actor) (id actor) (name target) (id target)) ;; if they are of the same faction and do not like infighting - do nothing (when (or (and (= (faction actor) (faction target)) (not (mob-ability-p actor +mob-abil-loves-infighting+))) (and (order actor) (= (first (order actor)) +mob-order-follow+) (= (second (order actor)) (id target))) (and (order actor) (order target) (= (first (order actor)) +mob-order-follow+) (= (first (order target)) +mob-order-follow+) (= (second (order actor)) (second (order target))))) (log:info "~A [~A] and ~A [~A] are of the same faction and would not attack each other" (name actor) (id actor) (name target) (id target)) (when (not (check-mob-visible target :observer actor)) (stumble-upon-mob actor target)) (make-act actor (truncate (* (cur-move-speed actor) (move-spd (get-mob-type-by-id (mob-type actor)))) 100)) (return-from on-bump t)) (when (not (check-mob-visible target :observer actor)) (stumble-upon-mob actor target)) ;; if the target is mounted, 50% chance that the actor will bump target's mount (when (riding-mob-id target) (when (zerop (random 2)) (setf target (get-mob-by-id (riding-mob-id target))))) (let ((abil-list nil)) ;; collect all passive non-final on-touch abilities (setf abil-list (loop for abil-type-id in (get-mob-all-abilities actor) when (and (abil-passive-p abil-type-id) (abil-on-touch-p abil-type-id) (not (abil-final-p abil-type-id))) collect abil-type-id)) ;; invoke all applicable abilities (loop for abil-type-id in abil-list when (can-invoke-ability actor target abil-type-id) do (mob-invoke-ability actor target abil-type-id)) ) (let ((abil-list nil)) ;; collect all passive final on-touch abilities (setf abil-list (loop for abil-type-id in (get-mob-all-abilities actor) when (and (abil-passive-p abil-type-id) (abil-on-touch-p abil-type-id) (abil-final-p abil-type-id)) collect abil-type-id)) ;; invoke first applicable ability (loop for abil-type-id in abil-list when (can-invoke-ability actor target abil-type-id) do (mob-invoke-ability actor target abil-type-id) (return-from on-bump t)) ) ;; if no abilities could be applied - melee target (melee-target actor target) ;; if the target is killed without purging - the slave mob also dies (when (and (check-dead target) (slave-mob-id target)) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type target) +mob-type-ghost+) t nil) :aux-params nil)) ))) (defun mob-possess-target (actor target) (remove-mob-from-level-list (level *world*) target) (set-mob-location actor (x target) (y target) (z target)) (setf (master-mob-id target) (id actor)) (setf (slave-mob-id actor) (id target)) (set-mob-effect actor :effect-type-id +mob-effect-possessed+ :actor-id (id actor)) (set-mob-effect target :effect-type-id +mob-effect-possessed+ :actor-id (id target)) (setf (face-mob-type-id actor) (mob-type target)) (incf (stat-possess actor)) ;(decf (nth (loyal-faction target) (total-faction-list (level *world*)))) ;(when (mob-ability-p target +mob-abil-civilian+) ; (incf (lost-civilians (level *world*)))) ;; give all items to the master (loop for item-id in (inv target) for item = (get-item-by-id item-id) do (setf (inv target) (remove-from-inv item (inv target))) (setf (inv actor) (add-to-inv item (inv actor) (id actor)))) ;; when the target is riding something - replace the rider with the actor (when (riding-mob-id target) (setf (riding-mob-id actor) (riding-mob-id target)) (setf (mounted-by-mob-id (get-mob-by-id (riding-mob-id actor))) (id actor)) (setf (riding-mob-id target) nil))) (defun mob-depossess-target (actor) (log:info (format nil "MOB-DEPOSSESS-TARGET: Master ~A [~A], slave [~A]~%" (name actor) (id actor) (slave-mob-id actor))) (let ((target (get-mob-by-id (slave-mob-id actor)))) (log:info (format nil "MOB-DEPOSSESS-TARGET: ~A [~A] releases its possession of ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (setf (x target) (x actor) (y target) (y actor) (z target) (z actor)) (add-mob-to-level-list (level *world*) target) (setf (master-mob-id target) nil) (setf (slave-mob-id actor) nil) (setf (face-mob-type-id actor) (mob-type actor)) (rem-mob-effect actor +mob-effect-possessed+) (rem-mob-effect target +mob-effect-possessed+) (rem-mob-effect target +mob-effect-reveal-true-form+) ;(incf (nth (loyal-faction target) (total-faction-list (level *world*)))) (when (mob-ability-p target +mob-abil-civilian+) (decf (lost-civilians (level *world*)))) ;; give all items to the slave (loop for item-id in (inv actor) for item = (get-item-by-id item-id) do (setf (inv actor) (remove-from-inv item (inv actor))) (setf (inv target) (add-to-inv item (inv target) (id target)))) ;; if the master is riding something - put slave as the rider (when (riding-mob-id actor) (setf (riding-mob-id target) (riding-mob-id actor)) (setf (mounted-by-mob-id (get-mob-by-id (riding-mob-id target))) (id target)) (setf (riding-mob-id actor) nil)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A releases its possession of ~A. " (capitalize-name (prepend-article +article-the+ (name actor))) (prepend-article +article-the+ (name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )) (defun mob-burn-blessing (actor target) (inflict-damage target :min-dmg 1 :max-dmg 2 :dmg-type +weapon-dmg-fire+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :no-hit-message t :no-check-dead t :actor actor :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A is scorched by ~A for ~A damage. " (capitalize-name (prepend-article +article-the+ (name target))) (prepend-article +article-the+ (visible-name actor)) cur-dmg))) (when (zerop (random 4)) (generate-sound target (x target) (y target) (z target) 80 #'(lambda (str) (format nil "You hear gasps~A." str)))) (when (check-dead target) (when (mob-effect-p target +mob-effect-possessed+) (mob-depossess-target target)) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params (list :is-fire)) ) ) (defun mob-can-shoot (actor) (unless (is-weapon-ranged actor) (return-from mob-can-shoot nil)) (if (or (find :no-charges (get-ranged-weapon-aux actor)) (not (zerop (get-ranged-weapon-charges actor)))) t nil)) (defun mob-reload-ranged-weapon (actor) (unless (is-weapon-ranged actor) (return-from mob-reload-ranged-weapon nil)) (log:info (format nil "MOB-RELOAD: ~A [~A] reloads his ~A~%" (name actor) (id actor) (get-weapon-name actor))) ;; set motion (incf-mob-motion actor *mob-motion-reload*) ;; generate sound (generate-sound actor (x actor) (y actor) (z actor) *mob-sound-reload* #'(lambda (str) (format nil "You hear some clanking sounds~A. " str))) (set-ranged-weapon-charges actor (get-ranged-weapon-max-charges actor)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reloads his ~(~A~). " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-weapon-name actor)) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (make-act actor +normal-ap+)) (defun mob-shoot-target (actor target) (log:info (format nil "MOB-SHOOT-TARGET: ~A [~A] shoots ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (let ((cur-dmg 0) (bullets-left) (affected-targets nil) (completely-missed t)) (unless (is-weapon-ranged actor) (return-from mob-shoot-target nil)) ;; set motion (incf-mob-motion actor *mob-motion-shoot*) ;; generate sound (generate-sound actor (x actor) (y actor) (z actor) *mob-sound-shoot* #'(lambda (str) (format nil "You hear shooting~A. " str))) ;; reduce the number of bullets in the magazine (if (not (find :no-charges (get-ranged-weapon-aux actor))) (if (> (get-ranged-weapon-charges actor) (get-ranged-weapon-rof actor)) (progn (setf bullets-left (get-ranged-weapon-rof actor)) (set-ranged-weapon-charges actor (- (get-ranged-weapon-charges actor) (get-ranged-weapon-rof actor)))) (progn (setf bullets-left (get-ranged-weapon-charges actor)) (set-ranged-weapon-charges actor 0))) (setf bullets-left (get-ranged-weapon-rof actor))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A ~A ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-ranged-weapon-shoot-str actor) (prepend-article +article-the+ (visible-name target))) :color (if (or (eq *player* actor) (eq *player* target)) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop repeat bullets-left with rx with ry with target1 with tx with ty with tz do (setf rx 0 ry 0) ;; disperse ammo depending on the distance to the target (let ((dist (get-distance (x actor) (y actor) (x target) (y target)))) (when (and (>= dist 2) (< (- (r-acc actor) (* dist *acc-loss-per-tile*)) (random 100))) (setf rx (- (random (+ 3 (* 2 (truncate dist (r-acc actor))))) (+ 1 (truncate dist (r-acc actor))))) (setf ry (- (random (+ 3 (* 2 (truncate dist (r-acc actor))))) (+ 1 (truncate dist (r-acc actor))))))) ;; trace a line to the target so if we encounter an obstacle along the path we hit it (line-of-sight (x actor) (y actor) (z actor) (+ (x target) rx) (+ (y target) ry) (z target) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let ((exit-result t)) (block nil (setf tx dx ty dy tz dz) (unless (check-LOS-propagate dx dy dz prev-cell :check-projectile t) (setf exit-result 'exit) (return)) ) exit-result))) ;; place a fire dot if the dest point is visible (place-animation tx ty tz +anim-type-fire-dot+ :params ()) (setf target1 (get-mob-* (level *world*) tx ty tz)) ;; if the target is mounted, 50% chance that the actor will hit target's mount (when (and target1 (riding-mob-id target1)) (when (zerop (random 2)) (setf target1 (get-mob-by-id (riding-mob-id target1))))) (when target1 (setf completely-missed nil) (setf cur-dmg (inflict-damage target1 :min-dmg (get-ranged-weapon-dmg-min actor) :max-dmg (get-ranged-weapon-dmg-max actor) :dmg-type (get-ranged-weapon-dmg-type actor) :att-spd nil :weapon-aux (get-ranged-weapon-aux actor) :acc 100 :add-blood t :no-dodge t :no-hit-message t :no-check-dead t :actor actor)) (if (find target1 affected-targets :key #'(lambda (n) (car n))) (incf (cdr (find target1 affected-targets :key #'(lambda (n) (car n)))) cur-dmg) (push (cons target1 cur-dmg) affected-targets)) ) ) (loop for (a-target . dmg) in affected-targets do (if (zerop dmg) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name a-target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is hit for ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name a-target))) dmg) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; show message for LOW HP (when (and (eq *player* a-target) (< (/ (cur-hp a-target) (max-hp a-target)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)))) (when (check-dead a-target) (make-dead a-target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params (get-ranged-weapon-aux actor)) (when (slave-mob-id a-target) (setf (cur-hp (get-mob-by-id (slave-mob-id a-target))) 0) (setf (x (get-mob-by-id (slave-mob-id a-target))) (x a-target) (y (get-mob-by-id (slave-mob-id a-target))) (y a-target) (z (get-mob-by-id (slave-mob-id a-target))) (z a-target)) (make-dead (get-mob-by-id (slave-mob-id a-target)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type a-target) +mob-type-ghost+) t nil) :aux-params ())) )) (when completely-missed (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A misses. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) (let ((ranged-spd (get-ranged-weapon-speed actor))) (when (mob-effect-p actor +mob-effect-adrenaline+) (let ((adrenaline-value (param1 (get-effect-by-id (mob-effect-p actor +mob-effect-adrenaline+))))) (setf ranged-spd (truncate (* ranged-spd (- 100 (* adrenaline-value 5))) 100)))) (make-act actor ranged-spd)) )) (defun mob-invoke-ability (actor target ability-type-id) (when (can-invoke-ability actor target ability-type-id) (let ((ability-type (get-ability-type-by-id ability-type-id))) (when (and (removes-disguise ability-type) (mob-effect-p actor +mob-effect-disguised+)) (rem-mob-effect actor +mob-effect-disguised+)) (funcall (on-invoke ability-type) ability-type actor target) (set-abil-cur-cd actor ability-type-id (abil-max-cd-p ability-type-id)) (incf-mob-motion actor (motion ability-type)) (make-act actor (spd ability-type))))) (defun mob-use-item (actor target item) (when (on-use item) (when (funcall (on-use item) actor target item) (setf (inv actor) (remove-from-inv item (inv actor) :qty 1)) (remove-item-from-world item)) (incf-mob-motion actor *mob-motion-use-item*) (make-act actor (truncate +normal-ap+ 2)))) (defun inflict-damage (target &key (min-dmg 0) (max-dmg 0) (dmg-type +weapon-dmg-iron+) (att-spd nil) (weapon-aux nil) (actor nil) (acc 100) (no-dodge nil) (add-blood t) (no-hit-message nil) (no-check-dead nil) (specific-hit-string-func nil) (specific-no-dmg-string-func nil) (kill-possessed t)) ;; specific-hit-string-func is #'(lambda (cur-dmg) (return string)) ;; specific-no-dmg-string-func is #'(lambda () (return string)) (log:info (format nil "INFLICT-DAMAGE: target = ~A [~A]~%" (name target) (id target))) ;; actor is under effect of strength in numbers, increase max-dmg (when (and actor (mob-effect-p actor +mob-effect-strength-in-numbers+)) (let ((bonus (param1 (get-effect-by-id (mob-effect-p actor +mob-effect-strength-in-numbers+))))) (setf max-dmg (truncate (* max-dmg (/ (+ 100 bonus) 100)))))) ;; target under protection of divine shield - consume the shield and quit (when (mob-effect-p target +mob-effect-divine-shield+) (if actor (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A attacks ~A, but can not harm ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is not harmed. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (rem-mob-effect target +mob-effect-divine-shield+) (when (and actor att-spd) (make-act actor att-spd)) (return-from inflict-damage 0)) ;; if the target has keen senses - destroy the illusions (when (mob-ability-p target +mob-abil-keen-senses+) (when (and actor (mob-effect-p actor +mob-effect-divine-concealed+)) (rem-mob-effect actor +mob-effect-divine-concealed+) (when (or (check-mob-visible actor :observer *player*) (check-mob-visible target :observer *player*)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name target))) (prepend-article +article-the+ (get-qualified-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (when (and actor (mob-effect-p actor +mob-effect-possessed+)) (unless (mob-effect-p actor +mob-effect-reveal-true-form+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name target))) (prepend-article +article-the+ (get-qualified-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (set-mob-effect actor :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5))) ;; if the attacker is disguised - remove the disguise (when (and actor (mob-effect-p actor +mob-effect-disguised+)) (rem-mob-effect actor +mob-effect-disguised+)) (multiple-value-bind (dx dy) (x-y-dir (1+ (random 9))) (let* ((cur-dmg) (dodge-chance) (x (+ dx (x target))) (y (+ dy (y target))) (dodge-target (cur-dodge target)) (check-result (check-move-on-level target x y (z target)))) ;; check if attacker has hit the target (if (> acc (random 100)) (progn ;; attacker hit ;; check if the target dodged (setf dodge-chance (random 100)) (if (and (> dodge-target dodge-chance) (eq check-result t) (not no-dodge)) ;; target dodged (progn (cond ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target))) (check-mob-visible actor :observer *player*) (check-mob-visible target :observer *player*)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A attacks ~A, but ~A evades the attack. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (check-mob-visible actor :observer *player*)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A attacks somebody, but it evades the attack. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target))) (check-mob-visible target :observer *player*)) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "Somebody attacks ~A, but ~A evades the attack. " (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind)) )))) (set-mob-location target x y (z target)) ;; reduce the momentum to zero (setf (momentum-dir target) (cons 0 0)) (setf (momentum-spd target) 0) ) ;; target did not dodge (progn ;; apply damage (setf cur-dmg (+ (random (- (1+ max-dmg) min-dmg)) min-dmg)) (when (and actor (= (faction actor) (faction target))) (setf cur-dmg min-dmg)) ;; if the attacker is under pain link effect and the target is the caster of pain link then amplify the damage by 30% (when (and actor (mob-effect-p actor +mob-effect-pain-link-target+) (= (id target) (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-pain-link-target+))))) (setf cur-dmg (truncate (* cur-dmg 1.3)))) ;; if the attacker is under pain link effect and the target is NOT the caster of pain link then decrease the damage by 30% (when (and actor (mob-effect-p actor +mob-effect-pain-link-target+) (/= (id target) (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-pain-link-target+))))) (setf cur-dmg (truncate (* cur-dmg 0.7)))) ;; reduce damage by the amount of risistance to this damage type ;; first reduce the damage directly ;; then - by percent (when (get-armor-resist target dmg-type) (decf cur-dmg (get-armor-d-resist target dmg-type)) (setf cur-dmg (truncate (* cur-dmg (- 100 (get-armor-%-resist target dmg-type))) 100))) (when (< cur-dmg 0) (setf cur-dmg 0)) ;; check for soul reinforcement on target (when (and (mob-effect-p target +mob-effect-soul-reinforcement+) (<= (- (cur-hp target) cur-dmg) 0)) (setf cur-dmg (1- (cur-hp target))) (rem-mob-effect target +mob-effect-soul-reinforcement+) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "Reinforced soul of ~A prevents a fatal blow. " (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind)))) (decf (cur-hp target) cur-dmg) ;; place a blood spattering (when (and add-blood (not (zerop cur-dmg))) (let ((dir (1+ (random 9)))) (multiple-value-bind (dx dy) (x-y-dir dir) (when (> 50 (random 100)) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-fresh+ :x (+ (x target) dx) :y (+ (y target) dy) :z (z target))))))) (if (zerop cur-dmg) (progn (cond ((and actor (not no-hit-message) (not specific-no-dmg-string-func) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits ~A, but ~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (not specific-no-dmg-string-func) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits somebody, but it is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (not specific-no-dmg-string-func) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "Somebody hits ~A, but ~A is not hurt. " (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) ((and (not actor) (not no-hit-message) (not specific-no-dmg-string-func) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) ((and specific-no-dmg-string-func (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (funcall specific-no-dmg-string-func) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))))) (progn (cond ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits ~A for ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) cur-dmg) :color (if (or (eq *player* actor) (eq *player* target)) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits somebody for ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) cur-dmg) :color (if (or (eq *player* actor) (eq *player* target)) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "Somebody hits ~A for ~A damage. " (prepend-article +article-the+ (visible-name target)) cur-dmg) :color (if (or (eq *player* actor) (eq *player* target)) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) ((and (not actor) (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name target))) cur-dmg) :color (if (eq *player* target) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))))) ((and specific-hit-string-func (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (funcall specific-hit-string-func cur-dmg) :color (if (or (and actor (eq *player* actor)) (eq *player* target)) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind)))))) ;; show message for LOW HP (when (and (eq *player* target) (not no-hit-message) (< (/ (cur-hp target) (max-hp target)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)) ) ) ;; if the attacker can constrict - constrict around the target (when (and actor weapon-aux (find :constricts weapon-aux)) (set-mob-effect target :effect-type-id +mob-effect-constriction-target+ :actor-id (id actor) :param1 (list (x target) (y target) (z target))) (if (mob-effect-p actor +mob-effect-constriction-source+) (progn (let ((effect (get-effect-by-id (mob-effect-p actor +mob-effect-constriction-source+)))) (setf (second (param1 effect)) (append (second (param1 effect)) (list (id target)))))) (progn (set-mob-effect actor :effect-type-id +mob-effect-constriction-source+ :actor-id (id actor) :param1 (list (list (x actor) (y actor) (z actor)) (list (id target)))))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A grabs ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind)))) ;; if the attack corrodes - corrode the target (when (and weapon-aux (find :corrodes weapon-aux)) (set-mob-effect target :effect-type-id +mob-effect-corroded+ :actor-id (if actor (id actor) (id target)) :cd 3)) ))) (progn ;; attacker missed (cond ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A misses ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A misses somebody. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and actor (not no-hit-message) (get-single-memo-visibility (get-memo-* (level *world*) (x target) (y target) (z target)))) (progn (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "Somebody misses ~A. " (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))) )) (when (and actor (mob-ability-p actor +mob-abil-adrenal-gland+)) (if (mob-effect-p actor +mob-effect-adrenaline+) (progn (let ((effect (get-effect-by-id (mob-effect-p actor +mob-effect-adrenaline+)))) (incf (param1 effect) 1))) (progn (set-mob-effect actor :effect-type-id +mob-effect-adrenaline+ :actor-id (id actor) :param1 2)))) (when (and (not no-check-dead) (check-dead target)) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params weapon-aux :keep-items (not kill-possessed)) (when (and kill-possessed (slave-mob-id target)) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type target) +mob-type-ghost+) t nil) :aux-params ())) ) (when (and actor att-spd) (make-act actor att-spd)) cur-dmg)) ) (defun melee-target (attacker target &key (kill-possessed t)) (log:info (format nil "MELEE-TARGET: ~A attacks ~A~%" (name attacker) (name target))) ;; no weapons - no attack (when (or (null (weapon attacker)) (null (is-weapon-melee attacker))) (make-act attacker +normal-ap+) (return-from melee-target nil)) ;; set motion (incf-mob-motion attacker *mob-motion-melee*) ;; generate sound (generate-sound attacker (x attacker) (y attacker) (z attacker) *mob-sound-melee* #'(lambda (str) (format nil "You hear sounds of fighting~A. " str))) (let ((melee-spd (get-melee-weapon-speed attacker))) (when (mob-effect-p attacker +mob-effect-adrenaline+) (let ((adrenaline-value (param1 (get-effect-by-id (mob-effect-p attacker +mob-effect-adrenaline+))))) (setf melee-spd (truncate (* melee-spd (- 100 (* adrenaline-value 5))) 100))) (when (<= melee-spd 0) (setf melee-spd 1))) (inflict-damage target :min-dmg (get-melee-weapon-dmg-min attacker) :max-dmg (get-melee-weapon-dmg-max attacker) :dmg-type (get-melee-weapon-dmg-type attacker) :att-spd melee-spd :weapon-aux (get-melee-weapon-aux-simple (weapon attacker)) :acc (m-acc attacker) :add-blood t :actor attacker :kill-possessed kill-possessed)) ;; the target has spines active (when (mob-effect-p target +mob-effect-spines+) (let ((dmg-type (if (mob-ability-p target +mob-abil-acidic-tips+) +weapon-dmg-acid+ +weapon-dmg-flesh+))) (inflict-damage attacker :min-dmg 2 :max-dmg 3 :dmg-type dmg-type :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :no-hit-message t :actor target :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from spines. " (capitalize-name (prepend-article +article-the+ (name attacker))) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from spines. " (capitalize-name (prepend-article +article-the+ (name attacker)))))))) ) (defun check-dead (mob) (when (<= (cur-hp mob) 0) (return-from check-dead t)) nil) (defun make-dead (mob &key (splatter t) (msg nil) (msg-newline nil) (killer nil) (corpse t) (aux-params ()) (keep-items nil)) (log:info "MAKE-DEAD: ~A [~A] (~A ~A ~A)" (name mob) (id mob) (x mob) (y mob) (z mob)) (let ((dead-msg-str (format nil "~A dies. " (capitalize-name (prepend-article +article-the+ (visible-name mob))))) (ghost-that-cheats-death nil)) (when (dead= mob) (return-from make-dead nil)) ;; a hack to make the slave die instead of the master if the mob is a ghost (when (and (mob-effect-p mob +mob-effect-life-guard+) (slave-mob-id mob)) (let ((slave-mob (get-mob-by-id (slave-mob-id mob)))) (rem-mob-effect mob +mob-effect-life-guard+) (mob-depossess-target mob) (setf ghost-that-cheats-death mob) (mob-transfer-effects mob slave-mob) (when (and aux-params (mob-ability-p slave-mob +mob-abil-undead+) (find :is-fire aux-params)) (setf (cur-hp ghost-that-cheats-death) 0)) (setf mob slave-mob) (setf (brightness mob) (brightness ghost-that-cheats-death)) (setf (motion mob) (motion ghost-that-cheats-death)) (setf dead-msg-str (format nil "~A dies. " (capitalize-name (prepend-article +article-the+ (visible-name mob))))) ) ) (loop for merged-id in (merged-id-list mob) for merged-mob = (get-mob-by-id merged-id) do (setf (cur-hp merged-mob) 0) (make-dead merged-mob :splatter nil :msg nil :corpse nil)) (when (and (eq mob *player*) killer) (setf (killed-by *player*) (prepend-article +article-a+ (get-qualified-name killer)))) (when (and killer (eq killer *player*)) (incf (cur-score *player*) (* 10 (strength mob))) (when (and (mob-ability-p *player* +mob-abil-demon+) (= (strength mob) 0)) (incf (cur-score *player*) 5))) ;; set stat-gold before dropping inventory (setf (stat-gold mob) (get-overall-value (inv mob))) ;; remove all effects on death (loop for effect-id being the hash-value in (effects mob) for effect = (get-effect-by-id effect-id) do (when (not (= (effect-type effect) +mob-effect-climbing-mode+)) (rem-mob-effect mob (effect-type effect)))) ;; place the inventory on the ground (unless keep-items (loop for item-id in (inv mob) for item = (get-item-by-id item-id) do (mob-drop-item mob item :spd nil :silent t))) ;; place the corpse (when (and corpse (not (mob-ability-p mob +mob-abil-no-corpse+))) (let ((item) (r) (left-body-str) (left-body-type) (burns-corpse nil)) (setf r 0) ;; determine which body part to sever (if any) (when (and aux-params (find :chops-body-parts aux-params)) (setf r (random 4))) ;; if the mob in undead and weapon is fire - no chopping (when (and aux-params (mob-ability-p mob +mob-abil-undead+) (find :is-fire aux-params)) (setf r 0) (setf burns-corpse t) (setf dead-msg-str (format nil "~A burns to ashes. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))))) (cond ;; sever head ((= r 1) (progn (place-animation (x mob) (y mob) (z mob) +anim-type-severed-body-part+ :params (list mob "head" +item-type-body-part-limb+)) (setf left-body-str "multilated body" left-body-type +item-type-body-part-body+) (when killer (setf dead-msg-str (format nil "~A chops off ~A's head. " (capitalize-name (prepend-article +article-the+ (visible-name killer))) (visible-name mob)))))) ;; sever limb ((= r 2) (progn (place-animation (x mob) (y mob) (z mob) +anim-type-severed-body-part+ :params (list mob "limb" +item-type-body-part-limb+)) (setf left-body-str "multilated body" left-body-type +item-type-body-part-body+) (when killer (setf dead-msg-str (format nil "~A severs ~A's limb. " (capitalize-name (prepend-article +article-the+ (visible-name killer))) (visible-name mob)))))) ;; sever torso ((= r 3) (progn (place-animation (x mob) (y mob) (z mob) +anim-type-severed-body-part+ :params (list mob "upper body" +item-type-body-part-half+)) (setf left-body-str "lower body" left-body-type +item-type-body-part-half+) (when killer (setf dead-msg-str (format nil "~A cuts ~A in half. " (capitalize-name (prepend-article +article-the+ (visible-name killer))) (visible-name mob)))))) ;; do not sever anything (t (setf left-body-str "body" left-body-type +item-type-body-part-full+))) (unless burns-corpse (setf item (make-instance 'item :item-type left-body-type :x (x mob) :y (y mob) :z (z mob))) (setf (name item) (format nil "~A's ~A" (alive-name mob) left-body-str)) (setf (alive-name item) (format nil "~A" (alive-name mob))) (when (= left-body-type +item-type-body-part-full+) (setf (dead-mob item) (id mob))) (add-item-to-level-list (level *world*) item) (log:info "MAKE-DEAD: ~A [~A] leaves ~A [~A] at (~A ~A ~A)" (name mob) (id mob) (name item) (id item) (x mob) (y mob) (z mob))) )) (when msg (if (eq (id mob) (riding-mob-id *player*)) (add-message dead-msg-str) (print-visible-message (x mob) (y mob) (z mob) (level *world*) dead-msg-str :color (sdl:color :r 150 :g 0 :b 0) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (when msg-newline (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~%") :color (sdl:color :r 150 :g 0 :b 0) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ;; apply all on-kill abilities of the killer (when killer (when (or (and (mob-ability-p killer +mob-abil-angel+) (mob-ability-p mob +mob-abil-demon+)) (and (mob-ability-p killer +mob-abil-demon+) (mob-ability-p mob +mob-abil-angel+)) (and (mob-ability-p killer +mob-abil-demon+) (mob-ability-p mob +mob-abil-human+)) (and (mob-ability-p killer +mob-abil-demon+) (mob-ability-p mob +mob-abil-demon+))) (log:info "MAKE-DEAD: ~A [~A] Real mob strength to be transferred to the killer ~A [~A] is ~A" (name mob) (id mob) (name killer) (id killer) (strength (get-mob-type-by-id (mob-type mob)))) (incf (cur-fp killer) (1+ (strength (get-mob-type-by-id (mob-type mob))))) (when (> (cur-fp killer) (max-fp killer)) (setf (cur-fp killer) (max-fp killer)))) (if (gethash (mob-type mob) (stat-kills killer)) (incf (gethash (mob-type mob) (stat-kills killer))) (setf (gethash (mob-type mob) (stat-kills killer)) 1)) (let ((abil-list nil)) ;; collect all passive on-kill abilities (setf abil-list (loop for abil-type-id in (get-mob-all-abilities killer) when (and (abil-passive-p abil-type-id) (abil-on-kill-p abil-type-id)) collect abil-type-id)) ;; invoke all applicable abilities (loop for abil-type-id in abil-list when (can-invoke-ability killer mob abil-type-id) do (mob-invoke-ability killer mob abil-type-id)) )) (when (or (and (null (master-mob-id mob)) (null (slave-mob-id mob))) (and (null (master-mob-id mob)) (slave-mob-id mob))) (remove-mob-from-level-list (level *world*) mob)) ;;(remove-mob-from-level-list (level *world*) mob) ;; if the target is being ridden, dismount the rider (when (mounted-by-mob-id mob) (setf (riding-mob-id (get-mob-by-id (mounted-by-mob-id mob))) nil) (adjust-dodge (get-mob-by-id (mounted-by-mob-id mob))) (add-mob-to-level-list (level *world*) (get-mob-by-id (mounted-by-mob-id mob))) (setf (mounted-by-mob-id mob) nil)) ;; if the target is riding something, place back the mount on map (when (riding-mob-id mob) (setf (mounted-by-mob-id (get-mob-by-id (riding-mob-id mob))) nil) (setf (x (get-mob-by-id (riding-mob-id mob))) (x mob) (y (get-mob-by-id (riding-mob-id mob))) (y mob)) (add-mob-to-level-list (level *world*) (get-mob-by-id (riding-mob-id mob))) (setf (riding-mob-id mob) nil)) (when (and ghost-that-cheats-death (not (check-dead ghost-that-cheats-death))) (when (riding-mob-id ghost-that-cheats-death) (setf (mounted-by-mob-id (get-mob-by-id (riding-mob-id ghost-that-cheats-death))) (id ghost-that-cheats-death))) (add-mob-to-level-list (level *world*) ghost-that-cheats-death)) ;; place blood stain if req (when (and splatter (< (random 100) 75)) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-stain+ :x (x mob) :y (y mob) :z (z mob)))) (setf (dead= mob) t))) (defun mob-evolve (mob) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A assumes a superior form of ~A! " (capitalize-name (prepend-article +article-the+ (name mob))) (prepend-article +article-a+ (name (get-mob-type-by-id (evolve-into mob))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf (mob-type mob) (evolve-into mob)) (setf (cur-hp mob) (max-hp mob)) (setf (cur-fp mob) 0) (setf (cur-sight mob) (base-sight mob)) (setf (face-mob-type-id mob) (mob-type mob)) (set-cur-weapons mob) (adjust-abilities mob) (adjust-dodge mob) (adjust-armor mob) (adjust-m-acc mob) (adjust-r-acc mob) (adjust-sight mob) (when (or (= (mob-type mob) +mob-type-demon+) (= (mob-type mob) +mob-type-shadow-demon+)) (set-name mob) (unless (eq mob *player*) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "It will be hereby known as ~A! " (get-qualified-name mob)) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ;; if the mob has no climbing ability - disable it (when (not (mob-ability-p mob +mob-abil-climbing+)) (rem-mob-effect mob +mob-effect-climbing-mode+)) (when (slave-mob-id mob) (setf (cur-hp (get-mob-by-id (slave-mob-id mob))) 0) (make-dead (get-mob-by-id (slave-mob-id mob)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type mob) +mob-type-ghost+) t nil) :aux-params ()) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-stain+ :x (x mob) :y (y mob))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Its ascension destroyed its vessel.") :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect mob +mob-effect-possessed+) (setf (master-mob-id mob) nil) (setf (slave-mob-id mob) nil) ) (setf (alive-name mob) (name mob)) (incf-mob-motion mob *mob-motion-ascend*) (generate-sound mob (x mob) (y mob) (z mob) *mob-sound-ascend* #'(lambda (str) (format nil "You hear some eerie sounds~A." str))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~%") :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (defmethod on-tick ((mob mob)) (when (< (cur-fp mob) 0) (setf (cur-fp mob) 0)) ;; a special case for revealing demons & angels that ride fiends & gargantaur (when (and (riding-mob-id mob) (or (mob-ability-p (get-mob-by-id (riding-mob-id mob)) +mob-abil-demon+) (mob-ability-p (get-mob-by-id (riding-mob-id mob)) +mob-abil-angel+))) (if (mob-effect-p mob +mob-effect-reveal-true-form+) (when (eq (cd (get-effect-by-id (mob-effect-p mob +mob-effect-reveal-true-form+))) 1) (setf (cd (get-effect-by-id (mob-effect-p mob +mob-effect-reveal-true-form+))) 2)) (set-mob-effect mob :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id mob) :cd 2))) (let ((was-flying (if (mob-effect-p mob +mob-effect-flying+) t nil))) (loop for effect-id being the hash-value in (effects mob) for effect = (get-effect-by-id effect-id) with was-flying = nil when (not (eq (cd effect) t)) do (decf (cd effect)) (when (zerop (cd effect)) (when (= (effect-type effect) +mob-effect-flying+) (setf was-flying t)) (rem-mob-effect mob (effect-type effect)))) (when (and was-flying (not (mob-effect-p mob +mob-effect-flying+)) (not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+)) (apply-gravity mob)) (set-mob-location mob (x mob) (y mob) (z mob))) ) (loop for effect-id being the hash-value in (effects mob) for effect = (get-effect-by-id effect-id) do (funcall (on-tick (get-effect-type-by-id (effect-type effect))) effect mob)) (loop for ability-id being the hash-key in (abilities-cd mob) when (not (zerop (abil-cur-cd-p mob ability-id))) do (set-abil-cur-cd mob ability-id (1- (abil-cur-cd-p mob ability-id)))) (adjust-dodge mob) (adjust-armor mob) (adjust-m-acc mob) (adjust-r-acc mob) (adjust-sight mob) (when (and (evolve-into mob) (>= (cur-fp mob) (max-fp mob))) (mob-evolve mob)) ;; if the mob has climbing ability - turn it on, if disabled (when (and (mob-ability-p mob +mob-abil-climbing+) (not (mob-effect-p mob +mob-effect-climbing-mode+)) (not (mob-effect-p mob +mob-effect-sprint+))) (set-mob-effect mob :effect-type-id +mob-effect-climbing-mode+ :actor-id (id mob) :cd t)) (if (or (mob-ability-p mob +mob-abil-no-breathe+) (not (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-water+)) (and (< (z mob) (1- (array-dimension (terrain (level *world*)) 2))) (not (or (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (1+ (z mob))) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (1+ (z mob))) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (1+ (z mob))) +terrain-trait-blocks-move+))))) (progn (setf (cur-oxygen mob) *max-oxygen-level*)) (progn (when (> (cur-oxygen mob) 0) (decf (cur-oxygen mob))) (when (zerop (cur-oxygen mob)) (decf (cur-hp mob) *lack-oxygen-dmg*) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A can not breath and takes ~A dmg. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) *lack-oxygen-dmg*) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; show message for LOW HP (when (and (eq *player* mob) (< (/ (cur-hp mob) (max-hp mob)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)) (when (check-dead mob) (when (eq mob *player*) (setf (killed-by *player*) "drowning")) (make-dead mob :splatter nil :msg t) (when (slave-mob-id mob) (setf (cur-hp (get-mob-by-id (slave-mob-id mob))) 0) (setf (x (get-mob-by-id (slave-mob-id mob))) (x mob) (y (get-mob-by-id (slave-mob-id mob))) (y mob) (z (get-mob-by-id (slave-mob-id mob))) (z mob)) (make-dead (get-mob-by-id (slave-mob-id mob)) :splatter nil :msg nil :msg-newline nil :corpse (if (= (mob-type mob) +mob-type-ghost+) t nil) :aux-params ()))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~%") :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))) ) (defun get-current-mob-glyph-idx (mob &key (x (x mob)) (y (y mob)) (z (z mob))) (declare (ignore z)) (cond ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 3)) 114) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 1)) 115) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 9)) 116) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 7)) 117) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 6)) 112) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 4)) 113) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 2)) 111) ((and (> (map-size mob) 1) (= (+ (x mob) (car (momentum-dir mob))) x) (= (+ (y mob) (cdr (momentum-dir mob))) y) (= (x-y-into-dir (car (momentum-dir mob)) (cdr (momentum-dir mob))) 8)) 110) ((and (> (map-size mob) 1) (= (- (x mob) x) (* -1 (truncate (1- (map-size mob)) 2))) (= (- (y mob) y) (* -1 (truncate (1- (map-size mob)) 2)))) 106) ((and (> (map-size mob) 1) (= (- (x mob) x) (* 1 (truncate (1- (map-size mob)) 2))) (= (- (y mob) y) (* -1 (truncate (1- (map-size mob)) 2)))) 107) ((and (> (map-size mob) 1) (= (- (x mob) x) (* -1 (truncate (1- (map-size mob)) 2))) (= (- (y mob) y) (* 1 (truncate (1- (map-size mob)) 2)))) 105) ((and (> (map-size mob) 1) (= (- (x mob) x) (* 1 (truncate (1- (map-size mob)) 2))) (= (- (y mob) y) (* 1 (truncate (1- (map-size mob)) 2)))) 104) ((and (> (map-size mob) 1) (or (= (- (x mob) x) (* 1 (truncate (1- (map-size mob)) 2))) (= (- (x mob) x) (* -1 (truncate (1- (map-size mob)) 2))))) 108) ((and (> (map-size mob) 1) (or (= (- (y mob) y) (* 1 (truncate (1- (map-size mob)) 2))) (= (- (y mob) y) (* -1 (truncate (1- (map-size mob)) 2))))) 109) ((and (> (map-size mob) 1) (or (/= (- (x mob) x) 0) (/= (- (y mob) y) 0))) 0) ((and (mob-effect-p mob +mob-effect-possessed+) (mob-effect-p mob +mob-effect-reveal-true-form+)) (glyph-idx (get-mob-type-by-id (mob-type (get-mob-by-id (slave-mob-id mob)))))) (t (glyph-idx (get-mob-type-by-id (face-mob-type-id mob)))))) (defun get-current-mob-glyph-color (mob) (cond ((and (mob-effect-p mob +mob-effect-possessed+) (mob-effect-p mob +mob-effect-reveal-true-form+)) (glyph-color (get-mob-type-by-id (mob-type mob))) ) ((and (or (mob-effect-p mob +mob-effect-possessed+) (mob-effect-p mob +mob-effect-disguised+)) (= (faction *player*) (faction mob)) (not (mob-effect-p mob +mob-effect-life-guard+))) (glyph-color (get-mob-type-by-id (mob-type mob)))) ((and (mob-ability-p *player* +mob-abil-angel+) (= (faction *player*) (faction mob))) (glyph-color (get-mob-type-by-id (mob-type mob)))) ((mob-effect-p mob +mob-effect-blessed+) sdl:*blue*) (t (glyph-color (get-mob-type-by-id (face-mob-type-id mob)))))) (defun get-current-mob-back-color (mob) (back-color (get-mob-type-by-id (face-mob-type-id mob)))) (defun get-current-mob-name (mob) (cond ;; player always knows himself ((eq mob *player*) (get-qualified-name mob)) ;; revealed demons show their true name ((and (mob-effect-p mob +mob-effect-possessed+) (mob-effect-p mob +mob-effect-reveal-true-form+)) (get-qualified-name mob)) ;; demons know true names of each other ((and (mob-ability-p mob +mob-abil-demon+) (mob-ability-p *player* +mob-abil-demon+)) (get-qualified-name mob)) ;; angels know true names of each other ((and (mob-ability-p mob +mob-abil-angel+) (mob-ability-p *player* +mob-abil-angel+)) (get-qualified-name mob)) ;; in all other cases see current appearence name (t (name (get-mob-type-by-id (face-mob-type-id mob)))))) (defgeneric on-bump (target actor)) (defun sense-evil () (setf (sense-evil-id *player*) nil) (let ((nearest-enemy)) (setf nearest-enemy (loop for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) with nearest-mob = nil when (and (not (check-dead mob)) (mob-ability-p mob +mob-abil-demon+)) do (unless nearest-mob (setf nearest-mob mob)) (when (< (get-distance (x *player*) (y *player*) (x mob) (y mob)) (get-distance (x *player*) (y *player*) (x nearest-mob) (y nearest-mob))) (setf nearest-mob mob)) finally (return nearest-mob))) (if nearest-enemy (setf (sense-evil-id *player*) (id nearest-enemy)) (setf (sense-evil-id *player*) nil)))) (defun sense-good () (let ((nearest-enemy)) (setf nearest-enemy (loop for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) with nearest-mob = nil when (and (not (check-dead mob)) (mob-ability-p mob +mob-abil-angel+)) do (unless nearest-mob (setf nearest-mob mob)) (when (< (get-distance (x *player*) (y *player*) (x mob) (y mob)) (get-distance (x *player*) (y *player*) (x nearest-mob) (y nearest-mob))) (setf nearest-mob mob)) finally (return nearest-mob))) (if nearest-enemy (setf (sense-good-id *player*) (id nearest-enemy)) (setf (sense-good-id *player*) nil)))) (defun sense-unnatural () (setf (sense-unnatural-pos *player*) nil) (let ((nearest-power nil) (book-item) (mob-with-book)) ;; find the book (when (level/book-id (level *world*)) (setf book-item (get-item-by-id (level/book-id (level *world*)))) (if (null (inv-id book-item)) (progn (setf nearest-power (list (x book-item) (y book-item)))) (progn (setf mob-with-book (get-mob-by-id (inv-id book-item))) (when (and (not (check-dead mob-with-book)) (not (eq mob-with-book *player*))) (setf nearest-power (list (x mob-with-book) (y mob-with-book))))))) ;; search for features (loop for feature-id in (feature-id-list (level *world*)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-sacrificial-circle+) do (unless nearest-power (setf nearest-power (list (x feature) (y feature)))) (when (< (get-distance (x *player*) (y *player*) (x feature) (y feature)) (get-distance (x *player*) (y *player*) (first nearest-power) (second nearest-power))) (setf nearest-power (list (x feature) (y feature))))) (setf (sense-unnatural-pos *player*) nearest-power))) (defun sense-relic () (setf (sense-relic-pos *player*) nil) (let ((nearest-power nil) (relic-item) (mob-with-relic)) ;; find the relic (on the map or inside somebody's inventory) (when (level/relic-id (level *world*)) (setf relic-item (get-item-by-id (level/relic-id (level *world*)))) (if (null (inv-id relic-item)) (progn (setf nearest-power (list (x relic-item) (y relic-item)))) (progn (setf mob-with-relic (get-mob-by-id (inv-id relic-item))) (when (and (not (check-dead mob-with-relic)) (not (eq mob-with-relic *player*))) (setf nearest-power (list (x mob-with-relic) (y mob-with-relic))))))) (setf (sense-relic-pos *player*) nearest-power))) (defun sense-portal () (setf (sense-portal-pos *player*) nil) (let ((portals nil)) ;; search for nearest portal on the map (setf portals (stable-sort (loop for feature-id in (demonic-portals (level *world*)) for feature = (get-feature-by-id feature-id) collect feature) #'(lambda (a b) (if (< (get-distance-3d (x *player*) (y *player*) (z *player*) (x a) (y a) (z a)) (get-distance-3d (x *player*) (y *player*) (z *player*) (x b) (y b) (z b))) t nil)))) (when portals (setf (sense-portal-pos *player*) (list (x (first portals)) (y (first portals))))))) (defun sense-sigil () (setf (sense-sigil-pos *player*) nil) (let ((nearest-power nil)) ;; search for sigil on the map (loop for mob-id in (mob-id-list (level *world*)) for mob = (get-mob-by-id mob-id) when (= (mob-type mob) +mob-type-demon-sigil+) do (unless nearest-power (setf nearest-power (list (x mob) (y mob)))) (when (< (get-distance (x *player*) (y *player*) (x mob) (y mob)) (get-distance (x *player*) (y *player*) (first nearest-power) (second nearest-power))) (setf nearest-power (list (x mob) (y mob))))) (setf (sense-sigil-pos *player*) nearest-power))) (defun sense-machines () (setf (sense-machine-pos *player*) nil) (let ((nearest-machine nil)) ;; search for machine on the map (loop for mob-id in (demonic-machines (level *world*)) for mob = (get-mob-by-id mob-id) when (= (mob-type mob) +mob-type-demon-machine+) do (unless nearest-machine (setf nearest-machine (list (x mob) (y mob)))) (when (< (get-distance (x *player*) (y *player*) (x mob) (y mob)) (get-distance (x *player*) (y *player*) (first nearest-machine) (second nearest-machine))) (setf nearest-machine (list (x mob) (y mob))))) (setf (sense-machine-pos *player*) nearest-machine))) (defun sense-stockpiles () (setf (sense-stockpile-pos *player*) nil) (let ((nearest-stockpile nil)) ;; search for stockpiles on the map (loop for feature-id in (bomb-plant-locations (level *world*)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-bomb-plant-target+) do (unless nearest-stockpile (setf nearest-stockpile (list (x feature) (y feature)))) (when (< (get-distance (x *player*) (y *player*) (x feature) (y feature)) (get-distance (x *player*) (y *player*) (first nearest-stockpile) (second nearest-stockpile))) (setf nearest-stockpile (list (x feature) (y feature))))) (setf (sense-stockpile-pos *player*) nearest-stockpile))) (defun mob-pick-item (mob item &key (spd (move-spd (get-mob-type-by-id (mob-type mob)))) (silent nil)) (log:info "~A [~A] picks up ~A [~A]" (name mob) (id mob) (name item) (id item)) (if (null (inv-id item)) (progn (unless silent (incf-mob-motion mob *mob-motion-pick-drop*) ;; generate sound (generate-sound mob (x mob) (y mob) (z mob) *mob-sound-pick-drop* #'(lambda (str) (format nil "You hear rustling~A. " str))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A picks up ~A. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) (cond ((> (qty item) 1) (format nil "~A ~A" (qty item) (plural-name item))) (t (format nil "~A" (prepend-article +article-a+ (name item)))))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (remove-item-from-level-list (level *world*) item) (setf (inv mob) (add-to-inv item (inv mob) (id mob))) (when spd (make-act mob spd))) (progn (log:info "Pick up failed, item is not on the ground!")))) (defun mob-drop-item (mob item &key (qty (qty item)) (spd (move-spd (get-mob-type-by-id (mob-type mob)))) silent) (log:info "~A [~A] drops ~A [~A]" (name mob) (id mob) (name item) (id item)) (if (eq (inv-id item) (id mob)) (progn (setf (inv mob) (remove-from-inv item (inv mob) :qty qty)) (setf (x item) (x mob) (y item) (y mob) (z item) (z mob)) (add-item-to-level-list (level *world*) item) (unless silent (incf-mob-motion mob *mob-motion-pick-drop*) ;; generate sound (generate-sound mob (x mob) (y mob) (z mob) *mob-sound-pick-drop* #'(lambda (str) (format nil "You hear rustling~A. " str))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A drops ~A. " (capitalize-name (prepend-article +article-the+ (visible-name mob))) (cond ((> (qty item) 1) (format nil "~A ~A" (qty item) (plural-name item))) (t (format nil "~A" (prepend-article +article-a+ (name item)))))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (when spd (make-act mob spd))) (progn (log:info "Drop failed, item is not in the mob's inventory!")))) (defun ignite-tile (level x y z src-x src-y src-z) (when (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-flammable+) (add-feature-to-level-list level (make-instance 'feature :feature-type +feature-fire+ :x x :y y :z z :counter (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-flammable+))) (if (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move-floor+) (progn (set-terrain-* level x y z +terrain-floor-ash+) ;(check-surroundings x y nil #'(lambda (dx dy) ; (when (and (get-connect-map-value (aref (connect-map level) 1) dx dy z +connect-map-move-walk+) ; (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move-floor+)) ; (set-connect-map-value (aref (connect-map level) 1) x y z +connect-map-move-walk+ ; (get-connect-map-value (aref (connect-map level) 1) dx dy z +connect-map-move-walk+))) ; (when (and (get-connect-map-value (aref (connect-map level) 1) dx dy z +connect-map-move-climb+) ; (get-terrain-type-trait (get-terrain-* level dx dy z) +terrain-trait-blocks-move-floor+)) ; (set-connect-map-value (aref (connect-map level) 1) x y z +connect-map-move-climb+ ; (get-connect-map-value (aref (connect-map level) 1) dx dy z +connect-map-move-climb+))))) ) (progn (set-terrain-* level x y z +terrain-floor-air+) )) (set-connect-map-value (aref (connect-map level) 1) x y z +connect-map-move-walk+ (get-connect-map-value (aref (connect-map level) 1) src-x src-y src-z +connect-map-move-walk+)) (set-connect-map-value (aref (connect-map level) 1) x y z +connect-map-move-climb+ (get-connect-map-value (aref (connect-map level) 1) src-x src-y src-z +connect-map-move-climb+)) (set-connect-map-value (aref (connect-map level) 1) x y z +connect-map-move-fly+ (get-connect-map-value (aref (connect-map level) 1) src-x src-y src-z +connect-map-move-fly+)) )) (defun calculate-player-score (bonus) (let ((score (+ (cur-score *player*) bonus (- (if (> (player-game-time (level *world*)) 200) (- (player-game-time (level *world*)) 200) (* 2 (- (player-game-time (level *world*)) 200)))) (if (= (mob-type *player*) +mob-type-thief+) (calculate-total-value *player*) 0) (if (= (mob-type *player*) +mob-type-ghost+) (* (stat-possess *player*) 3) 0)))) (when (< score 0) (setf score 0)) score)) (defun adjust-disguise-for-mob (mob) (setf (face-mob-type-id mob) (mob-type mob)) (when (mob-effect-p mob +mob-effect-divine-concealed+) (if (angel-disguised-mob-type-id (world-sector (level *world*))) (setf (face-mob-type-id mob) (angel-disguised-mob-type-id (world-sector (level *world*)))) (setf (face-mob-type-id mob) +mob-type-man+)) ) (when (and (slave-mob-id mob) (not (mob-effect-p mob +mob-effect-reveal-true-form+))) (setf (face-mob-type-id mob) (mob-type (get-mob-by-id (slave-mob-id mob))))) (when (mob-effect-p mob +mob-effect-disguised+) (setf (face-mob-type-id mob) (param1 (get-effect-by-id (mob-effect-p mob +mob-effect-disguised+)))))) (defun mob-transfer-effects (actor target) (loop for effect-id being the hash-value in (effects actor) for effect = (get-effect-by-id effect-id) do (if (mob-effect-p target (effect-type effect)) (progn (if (or (eq (cd effect) t) (> (cd effect) (cd (get-effect-by-id (mob-effect-p target (effect-type effect)))))) (setf (cd (get-effect-by-id (mob-effect-p target (effect-type effect)))) (cd effect)) (rem-mob-effect actor (effect-type effect)))) (progn (setf (gethash (effect-type effect) (effects target)) effect-id) (setf (actor-id effect) (id target)) (funcall (on-add (get-effect-type-by-id (effect-type effect))) effect target) (remhash (effect-type effect) (effects actor)))))) ;;------------------------------- ;; Common cards & abilities funcs ;;------------------------------- (defun invoke-bend-space (actor) (log:info (format nil "MOB-BEND-SPACE: ~A [~A] invokes bend space.~%" (name actor) (id actor))) (let ((applicable-tiles ()) (dx) (dy) (dz) (r)) (loop for dx of-type fixnum from (- (x actor) 6) to (+ (x actor) 6) do (loop for dy of-type fixnum from (- (y actor) 6) to (+ (y actor) 6) do (loop for dz of-type fixnum from (- (z actor) 6) to (+ (z actor) 6) when (and (>= dx 0) (< dx (array-dimension (terrain (level *world*)) 0)) (>= dy 0) (< dy (array-dimension (terrain (level *world*)) 1)) (>= dz 0) (< dz (array-dimension (terrain (level *world*)) 2)) (eq (check-move-on-level actor dx dy dz) t) (level-cells-connected-p (level *world*) (x actor) (y actor) (z actor) dx dy dz (if (riding-mob-id actor) (map-size (get-mob-by-id (riding-mob-id actor))) (map-size actor)) (get-mob-move-mode actor) :can-open-doors (can-open-doors actor)) (or (get-terrain-type-trait (get-terrain-* (level *world*) dx dy dz) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) dx dy dz) +terrain-trait-water+))) do (push (list dx dy dz) applicable-tiles)))) (when applicable-tiles (setf r (random (length applicable-tiles))) (setf dx (first (nth r applicable-tiles)) dy (second (nth r applicable-tiles)) dz (third (nth r applicable-tiles)))) (log:info (format nil "MOB-BEND-SPACE: ~A [~A] teleports to (~A ~A ~A).~%" (name actor) (id actor) dx dy dz)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear crackling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A bends space around itself and disappeares in thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location actor dx dy dz) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear crackling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A appears out of thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )) (defun invoke-teleport-self (actor min-distance z) (log:info (format nil "MOB-TELEPORT-SELF: ~A [~A] teleports self~%" (name actor) (id actor))) (let ((max-x (array-dimension (terrain (level *world*)) 0)) (max-y (array-dimension (terrain (level *world*)) 1)) (rx (- (+ 80 (x actor)) (1+ (random 160)))) (ry (- (+ 80 (y actor)) (1+ (random 160)))) (n 2000)) ;; 2000 hundred tries to find a suitable place for teleport (loop while (or (< rx 0) (< ry 0) (>= rx max-x) (>= ry max-y) (< (get-distance (x actor) (y actor) rx ry) min-distance) (not (get-terrain-type-trait (get-terrain-* (level *world*) rx ry z) +terrain-trait-blocks-move-floor+)) (not (eq (check-move-on-level actor rx ry z) t)) (= (get-level-connect-map-value (level *world*) rx ry z (if (riding-mob-id actor) (map-size (get-mob-by-id (riding-mob-id actor))) (map-size actor)) (get-mob-move-mode actor)) +connect-room-none+)) do (decf n) (when (zerop n) (loop-finish)) (setf rx (- (+ 80 (x actor)) (1+ (random 160)))) (setf ry (- (+ 80 (y actor)) (1+ (random 160))))) (if (not (zerop n)) (progn (generate-sound actor (x actor) (y actor) (z actor) 120 #'(lambda (str) (format nil "You hear crackling~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A disappeares in thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location actor rx ry z) (generate-sound actor (x actor) (y actor) (z actor) 120 #'(lambda (str) (format nil "You hear crackling~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A appears out of thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (generate-sound actor (x actor) (y actor) (z actor) 120 #'(lambda (str) (format nil "You hear crackling~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A blinks for a second, but remains in place. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) )) (defun invoke-disguise (actor) (generate-sound actor (x actor) (y actor) (z actor) 30 #'(lambda (str) (format nil "You hear some hiss~A. " str))) (let ((face-mob-type-id (if (zerop (random 2)) +mob-type-man+ +mob-type-woman+))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A disguises itself as ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-a+ (name (get-mob-type-by-id face-mob-type-id)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect actor :effect-type-id +mob-effect-disguised+ :actor-id (id actor) :param1 face-mob-type-id) (adjust-disguise-for-mob actor))) (defun invoke-curse (actor) (let ((enemy-list nil)) (when (zerop (random 2)) ;; 1/2th chance to do anything ;; collect all unholy enemies in sight (setf enemy-list (loop for enemy-mob-id in (visible-mobs actor) when (not (get-faction-relation (faction actor) (faction (get-mob-by-id enemy-mob-id)))) collect enemy-mob-id)) (log:info (format nil "MOB-CURSE: ~A [~A] affects the following enemies ~A with the curse~%" (name actor) (id actor) enemy-list)) ;; place a curse on them for 5 turns (loop for enemy-mob-id in enemy-list with protected = nil do (setf protected nil) ;; divine shield and blessings also grant one-time protection from curses (when (and (not protected) (mob-effect-p (get-mob-by-id enemy-mob-id) +mob-effect-blessed+)) (rem-mob-effect (get-mob-by-id enemy-mob-id) +mob-effect-blessed+) (setf protected t)) (when (and (not protected) (mob-effect-p (get-mob-by-id enemy-mob-id) +mob-effect-divine-shield+)) (rem-mob-effect (get-mob-by-id enemy-mob-id) +mob-effect-divine-shield+) (setf protected t)) (if protected (progn (log:info (format nil "MOB-CURSE: ~A [~A] was protected, so the curse removes protection only~%" (name (get-mob-by-id enemy-mob-id)) (id (get-mob-by-id enemy-mob-id)))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A's curse removed divine protection from ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name (get-mob-by-id enemy-mob-id)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) (progn (log:info (format nil "MOB-CURSE: ~A [~A] affects the enemy ~A with a curse~%" (name actor) (id actor) (get-mob-by-id enemy-mob-id))) (set-mob-effect (get-mob-by-id enemy-mob-id) :effect-type-id +mob-effect-cursed+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is cursed. " (capitalize-name (prepend-article +article-the+ (visible-name (get-mob-by-id enemy-mob-id))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) ))) (defun invoke-fear (actor fear-strength) (log:info (format nil "MOB-INSTILL-FEAR: ~A [~A] casts instill fear.~%" (name actor) (id actor))) ;; fear nearby visible enemy mobs ;; fear can be resisted depending on the strength of the mob (loop for i from 0 below (length (visible-mobs actor)) for mob = (get-mob-by-id (nth i (visible-mobs actor))) when (not (get-faction-relation (faction actor) (faction mob))) do (if (> (random (+ (strength mob) fear-strength)) (strength mob)) (progn (set-mob-effect mob :effect-type-id +mob-effect-fear+ :actor-id (id actor) :cd 3) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A is feared. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A resists fear. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))))) (defun invoke-reanimate-body (corpse-item) (let ((mob-corpse-type) (mob-corpse)) (cond ((eq (item-ability-p corpse-item +item-abil-corpse+) 1) (setf mob-corpse-type +mob-type-reanimated-pwr-1+)) ((eq (item-ability-p corpse-item +item-abil-corpse+) 2) (setf mob-corpse-type +mob-type-reanimated-pwr-2+)) ((eq (item-ability-p corpse-item +item-abil-corpse+) 3) (setf mob-corpse-type +mob-type-reanimated-pwr-3+)) (t (setf mob-corpse-type +mob-type-reanimated-pwr-4+))) (setf mob-corpse (make-instance 'mob :mob-type mob-corpse-type :x (x corpse-item) :y (y corpse-item) :z (z corpse-item))) (setf (name mob-corpse) (format nil "reanimated ~A" (name corpse-item))) (setf (alive-name mob-corpse) (alive-name corpse-item)) (add-mob-to-level-list (level *world*) mob-corpse) (remove-item-from-level-list (level *world*) corpse-item) (print-visible-message (x mob-corpse) (y mob-corpse) (z mob-corpse) (level *world*) (format nil "~A starts to move. " (capitalize-name (prepend-article +article-the+ (visible-name corpse-item)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (log:info (format nil "INVOKE-REANIMATE-BODY: ~A [~A] is reanimated at (~A ~A ~A).~%" (name corpse-item) (id corpse-item) (x mob-corpse) (y mob-corpse) (z mob-corpse))) (remove-item-from-world corpse-item) )) (defun set-mob-piety (mob piety-num) (when (worshiped-god mob) (let ((old-piety (get-worshiped-god-piety (worshiped-god mob)))) (cond ((< piety-num 0) (setf piety-num 0)) ((> piety-num 200) (setf piety-num 200))) (setf (second (worshiped-god mob)) piety-num) (when (and (eq mob *player*) (check-piety-level-changed (get-worshiped-god-type (worshiped-god mob)) old-piety (get-worshiped-god-piety (worshiped-god mob)))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (return-piety-change-str (get-worshiped-god-type (worshiped-god mob)) (get-worshiped-god-piety (worshiped-god mob)) old-piety) :color sdl:*magenta* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))))) (defun mob-move-passwall (actor dx dy dz) (loop with mx = (x actor) with my = (y actor) with mz = (z actor) with has-path = t do (incf mx dx) (incf my dy) (incf mz dz) (when (or (< mx 0) (>= mx (array-dimension (terrain (level *world*)) 0)) (< my 0) (>= my (array-dimension (terrain (level *world*)) 1)) (< mz 0) (>= mz (array-dimension (terrain (level *world*)) 2))) (setf has-path nil) (loop-finish)) (when (eq (check-move-on-level actor mx my mz) t) (loop-finish)) finally (if has-path (return (list mx my mz)) nil))) (defun player-start-map-select-nearest-hostile () (let ((hostile-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction *player*) (get-visible-faction mob))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id)))) do (push mob-id hostile-mobs)) (setf hostile-mobs (sort hostile-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1))))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2)))))) t nil)) :key #'(lambda (mob-id) (get-mob-by-id mob-id)))) (if hostile-mobs (setf (view-x *player*) (x (get-mob-by-id (first hostile-mobs))) (view-y *player*) (y (get-mob-by-id (first hostile-mobs))) (view-z *player*) (z (get-mob-by-id (first hostile-mobs)))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-nearest-hostile-next () (let ((hostile-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob))))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (< (get-distance-3d (x *player*) (y *player*) (z *player*) (x mob) (y mob) (z mob)) 2)) do (push mob-id hostile-mobs)) (setf hostile-mobs (sort hostile-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1))))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2)))))) t nil)) :key #'(lambda (mob-id) (get-mob-by-id mob-id)))) (if hostile-mobs (setf (view-x *player*) (x (get-mob-by-id (first hostile-mobs))) (view-y *player*) (y (get-mob-by-id (first hostile-mobs))) (view-z *player*) (z (get-mob-by-id (first hostile-mobs)))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-nearest-ally () (let ((allied-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob)))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id)))) do (push mob allied-mobs)) (setf allied-mobs (sort allied-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1)))) (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2))))) t nil)) )) (if allied-mobs (setf (view-x *player*) (x (first allied-mobs)) (view-y *player*) (y (first allied-mobs)) (view-z *player*) (z (first allied-mobs))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-nearest-ally-next () (let ((allied-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (get-faction-relation (faction *player*) (faction mob)) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (< (get-distance-3d (x *player*) (y *player*) (z *player*) (x mob) (y mob) (z mob)) 2)) do (push mob allied-mobs)) (setf allied-mobs (sort allied-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (get-faction-relation (faction *player*) (faction mob-1)) (get-faction-relation (faction *player*) (faction mob-2))) t nil)) )) (if allied-mobs (setf (view-x *player*) (x (first allied-mobs)) (view-y *player*) (y (first allied-mobs)) (view-z *player*) (z (first allied-mobs))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-self () (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*))) (defun player-start-map-select-death-from-above () (let ((hostile-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob))))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (< (z mob) (z *player*))) do (push mob-id hostile-mobs)) (setf hostile-mobs (sort hostile-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1))))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2)))))) t nil)) :key #'(lambda (mob-id) (get-mob-by-id mob-id)))) (if hostile-mobs (setf (view-x *player*) (x (get-mob-by-id (first hostile-mobs))) (view-y *player*) (y (get-mob-by-id (first hostile-mobs))) (view-z *player*) (z (get-mob-by-id (first hostile-mobs)))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-door () (let ((doors nil)) (check-surroundings (x *player*) (y *player*) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z *player*)))) (when (and terrain (not (get-mob-* (level *world*) dx dy (z *player*))) (get-terrain-type-trait terrain +terrain-trait-openable-door+)) (push (list dx dy (z *player*)) doors))))) (if doors (setf (view-x *player*) (first (first doors)) (view-y *player*) (second (first doors)) (view-z *player*) (third (first doors))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-light () (let ((lights nil)) (check-surroundings (x *player*) (y *player*) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z *player*)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-light-source+)) (push (list dx dy (z *player*)) lights))))) (if lights (setf (view-x *player*) (first (first lights)) (view-y *player*) (second (first lights)) (view-z *player*) (third (first lights))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-window () (let ((windows nil)) (check-surroundings (x *player*) (y *player*) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z *player*)))) (when (and terrain (not (get-mob-* (level *world*) dx dy (z *player*))) (get-terrain-type-trait terrain +terrain-trait-openable-window+)) (push (list dx dy (z *player*)) windows))))) (if windows (setf (view-x *player*) (first (first windows)) (view-y *player*) (second (first windows)) (view-z *player*) (third (first windows))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-corpse () (let ((corpses nil)) (update-visible-items-player) (loop for item-id in (visible-items *player*) for item = (get-item-by-id item-id) when (and (item-ability-p item +item-abil-corpse+)) do (push item corpses)) (setf corpses (sort corpses #'(lambda (item-1 item-2) (if (and (< (get-distance (x *player*) (y *player*) (x item-1) (y item-1)) (get-distance (x *player*) (y *player*) (x item-2) (y item-2)))) t nil)) )) (if corpses (setf (view-x *player*) (x (first corpses)) (view-y *player*) (y (first corpses)) (view-z *player*) (z (first corpses))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-empower-undead () (let ((allied-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (get-faction-relation (faction *player*) (faction mob)) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (mob-ability-p mob +mob-abil-undead+)) do (push mob allied-mobs)) (setf allied-mobs (sort allied-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (get-faction-relation (faction *player*) (faction mob-1)) (get-faction-relation (faction *player*) (faction mob-2))) t nil)) )) (if allied-mobs (setf (view-x *player*) (x (first allied-mobs)) (view-y *player*) (y (first allied-mobs)) (view-z *player*) (z (first allied-mobs))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-hostile-unholy () (let ((hostile-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob))))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (mob-ability-p mob +mob-abil-unholy+)) do (push mob-id hostile-mobs)) (setf hostile-mobs (sort hostile-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1))))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2)))))) t nil)) :key #'(lambda (mob-id) (get-mob-by-id mob-id)))) (if hostile-mobs (setf (view-x *player*) (x (get-mob-by-id (first hostile-mobs))) (view-y *player*) (y (get-mob-by-id (first hostile-mobs))) (view-z *player*) (z (get-mob-by-id (first hostile-mobs)))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-extinguish-light () (let ((hostile-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob))))) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (> (cur-light mob) 0)) do (push mob-id hostile-mobs)) (setf hostile-mobs (sort hostile-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-1))))) (not (get-faction-relation (faction *player*) (faction (get-mob-type-by-id (face-mob-type-id mob-2)))))) t nil)) :key #'(lambda (mob-id) (get-mob-by-id mob-id)))) (if hostile-mobs (setf (view-x *player*) (x (get-mob-by-id (first hostile-mobs))) (view-y *player*) (y (get-mob-by-id (first hostile-mobs))) (view-z *player*) (z (get-mob-by-id (first hostile-mobs)))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-merge () (let ((allied-mobs)) ;; find the nearest hostile mob & set it as target (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (get-faction-relation (faction *player*) (faction mob)) (not (and (riding-mob-id *player*) (= (riding-mob-id *player*) mob-id))) (< (get-distance-3d (x *player*) (y *player*) (z *player*) (x mob) (y mob) (z mob)) 2) (find (id mob) (mimic-id-list *player*))) do (push mob allied-mobs)) (setf allied-mobs (sort allied-mobs #'(lambda (mob-1 mob-2) (if (and (< (get-distance (x *player*) (y *player*) (x mob-1) (y mob-1)) (get-distance (x *player*) (y *player*) (x mob-2) (y mob-2)))) t nil)) )) (if allied-mobs (setf (view-x *player*) (x (first allied-mobs)) (view-y *player*) (y (first allied-mobs)) (view-z *player*) (z (first allied-mobs))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-resurrect () (let ((corpses nil)) (update-visible-items-player) (loop for item-id in (visible-items *player*) for item = (get-item-by-id item-id) when (and (item-ability-p item +item-abil-corpse+) (dead-mob item) (not (mob-ability-p (get-mob-by-id (dead-mob item)) +mob-abil-demon+)) (= (item-type item) +item-type-body-part-full+)) do (push item corpses)) (setf corpses (sort corpses #'(lambda (item-1 item-2) (if (and (< (get-distance (x *player*) (y *player*) (x item-1) (y item-1)) (get-distance (x *player*) (y *player*) (x item-2) (y item-2)))) t nil)) )) (if corpses (setf (view-x *player*) (x (first corpses)) (view-y *player*) (y (first corpses)) (view-z *player*) (z (first corpses))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-ghost-possess () (let ((corpses nil) (possessable-mobs)) (update-visible-items-player) (loop for item-id in (visible-items *player*) for item = (get-item-by-id item-id) when (and (item-ability-p item +item-abil-corpse+)) do (push item corpses)) (loop for mob-id in (visible-mobs *player*) for mob = (get-mob-by-id mob-id) when (and (gethash +mob-abil-possessable+ (abilities (get-mob-type-by-id (face-mob-type-id mob)))) ) do (push mob possessable-mobs)) (setf corpses (append corpses possessable-mobs)) (setf corpses (sort corpses #'(lambda (item-1 item-2) (if (and (< (get-distance (x *player*) (y *player*) (x item-1) (y item-1)) (get-distance (x *player*) (y *player*) (x item-2) (y item-2)))) t nil)) )) (if corpses (setf (view-x *player*) (x (first corpses)) (view-y *player*) (y (first corpses)) (view-z *player*) (z (first corpses))) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) ))) (defun player-start-map-select-rune () (let ((runes ())) (check-surroundings (x *player*) (y *player*) nil #'(lambda (dx dy) (when (remove-if #'(lambda (a) (if (get-feature-type-trait (get-feature-by-id a) +feature-trait-demonic-rune+) nil t)) (get-features-* (level *world*) dx dy (z *player*))) (setf runes (list dx dy (z *player*)))) )) (if runes (setf (view-x *player*) (first runes) (view-y *player*) (second runes) (view-z *player*) (third runes)) (setf (view-x *player*) (x *player*) (view-y *player*) (y *player*) (view-z *player*) (z *player*)) )) ) (defun player-check-dead () (if (or (and (not (mob-ability-p *player* +mob-abil-trinity-mimic+)) (check-dead *player*)) (and (mob-ability-p *player* +mob-abil-trinity-mimic+) (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with dead = 0 when (check-dead mimic) do (incf dead) finally (return (= dead (length (mimic-id-list *player*))))))) t nil)) (defun make-explosion-at-xyz (level x y z radius actor &key (dmg-list `((:min-dmg 3 :max-dmg 6 :dmg-type ,+weapon-dmg-fire+ :weapon-aux (:is-fire)) (:min-dmg 5 :max-dmg 7 :dmg-type ,+weapon-dmg-iron+ :weapon-aux (:is-fire)))) (animation-dot-id +anim-type-fire-dot+)) (let ((targets nil) (fire-on-death (loop for single-dmg-cmd in dmg-list when (find :is-fire (getf single-dmg-cmd :weapon-aux)) do (return t)))) (draw-fov x y z radius #'(lambda (dx dy dz prev-cell) (let ((exit-result t)) (block nil (when (> (get-distance-3d x y z dx dy dz) (1+ radius)) (setf exit-result 'exit) (return)) (when (eq (check-LOS-propagate dx dy dz prev-cell :check-move t) nil) (setf exit-result 'exit) (return)) (place-animation dx dy dz animation-dot-id :params ()) ;;(when (and (get-terrain-* level dx dy dz) ;; (get-terrain-type-trait (get-terrain-* level dx dy dz) +terrain-trait-flammable+)) ;; (push (list dx dy dz) cell-targets)) (when (and (get-mob-* level dx dy dz) ) (pushnew (get-mob-* level dx dy dz) targets) ) ) exit-result))) ;; inflict damage to mobs (loop for target in targets for cur-dmg = 0 do (loop for single-dmg-cmd in dmg-list do (incf cur-dmg (inflict-damage target :min-dmg (getf single-dmg-cmd :min-dmg) :max-dmg (getf single-dmg-cmd :max-dmg) :dmg-type (getf single-dmg-cmd :dmg-type) :att-spd nil :weapon-aux (getf single-dmg-cmd :weapon-aux) :acc 100 :add-blood t :no-dodge t :no-hit-message t :no-check-dead t :actor actor))) (if (zerop cur-dmg) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name target))) cur-dmg) :color sdl:*white* :tags (list (when (and (find (id target) (shared-visible-mobs *player*)) (not (find (id target) (proper-visible-mobs *player*)))) :singlemind)))) (when (check-dead target) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params (if fire-on-death (list :is-fire) ())) (when (mob-effect-p target +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ())))) ;; place fires ;; TODO: should not be implemented until ignite-tile properly sets ignited tile connectivity ;;(loop for (dx dy dz) in cell-targets ;; when (and (zerop (random 5)) ;; (get-terrain-type-trait (get-terrain-* level dx dy dz) +terrain-trait-flammable+)) ;; do ;; (ignite-tile level dx dy dz dx dy dz) ;; ) ;; process animations for this turn if any (process-animations-on-level level) )) (defun can-open-doors (mob) (if (mob-ability-p mob +mob-abil-open-close-door+) t nil))
176,936
Common Lisp
.lisp
2,765
44.603617
276
0.489204
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
7111a46b7f77441e116dc04c1a90b701fff9a8c3fceaeccc8949a94ff7e0098c
2,884
[ -1 ]
2,885
init-gods.lisp
gwathlobal_CotD/src/init-gods.lisp
(in-package :cotd) (set-god-type (make-instance 'god :id +god-entity-malseraph+ :name "Malseraph" :piety-level-func #'(lambda (god piety-num) (declare (ignore god)) (cond ((<= piety-num +malseraphs-piety-very-low+) 0) ((<= piety-num +malseraphs-piety-low+) 1) ((<= piety-num +malseraphs-piety-medium+) 2) ((<= piety-num +malseraphs-piety-high+) 3) (t 4))) :piety-str-func #'(lambda (god piety-num) (let ((piety-level (funcall (piety-level-func god) god piety-num))) (cond ((= piety-level 0) "Bored!") ((= piety-level 1) "Losing interest") ((= piety-level 2) "Interested") ((= piety-level 3) "Intrigued") (t "Amazed!")))) :piety-change-str-func #'(lambda (god piety-num-new piety-num-old) (let ((piety-level (funcall (piety-level-func god) god piety-num-new)) (piety-level-old (funcall (piety-level-func god) god piety-num-old))) (cond ((= piety-level 0) "Malseraph is bored! ") ((and (= piety-level 1) (< piety-level piety-level-old)) "Malseraph loses interest in you. ") ((and (= piety-level 1) (> piety-level piety-level-old)) "Malseraph becomes slightly interested in you. ") ((and (= piety-level 2) (< piety-level piety-level-old)) "Malseraph's peak of interest is over. ") ((and (= piety-level 2) (> piety-level piety-level-old)) "Malseraph becomes mildly interested in you. ") ((and (= piety-level 3) (< piety-level piety-level-old)) "Malseraph wants you to continue. ") ((and (= piety-level 3) (> piety-level piety-level-old)) "Malseraph is intrigued. ") (t "Malseraph is amazed! ")))) :piety-tick-func #'(lambda (god mob) (let* ((new-piety (- (get-worshiped-god-piety (worshiped-god mob)) (+ 2 (random 3)))) (piety-level (funcall (piety-level-func god) god new-piety)) (card-played nil) (bad-chance (cond ((= piety-level 2) 1) ((= piety-level 1) 5) ((= piety-level 0) 20) (t 0))) (deck-of-damnation (list (list +item-card-polymorph-self+ 120) (list +item-card-irradiate-self+ 60) (list +item-card-teleport+ 80) (list +item-card-confuse-self+ 70) (list +item-card-silence-self+ 70) (list +item-card-slow-self+ 70) (list +item-card-fear-self+ 50) (list +item-card-blindness-self+ 70) (list +item-card-curse-self+ 50) (list +item-card-lignify-self+ 120))) (good-chance (cond ((= piety-level 1) 1) ((= piety-level 2) 5) ((= piety-level 3) 10) (t 0))) (deck-of-boons (list (list +item-card-polymorph-other+ t t) (list +item-card-irradiate-other+ t t) (list +item-card-confuse-other+ t t) (list +item-card-silence-other+ t t) (list +item-card-slow-other+ t t) (list +item-card-fear-other+ t t) (list +item-card-blindness-other+ t t) (list +item-card-curse-other+ t t) (list +item-card-give-deck+ nil nil) (list +item-card-cure-mutation+ nil nil) (list +item-card-lignify-other+ t t))) (neutral-chance (cond ((= piety-level 1) 3) ((= piety-level 2) 5) ((= piety-level 3) 3) (t 1))) (deck-of-neutrality (list (list +item-card-glowing-all+) (list +item-card-disguise+)))) ;; Malseraph is not interested and something bad is about to happen (when (and (not card-played) (not (zerop bad-chance)) (< (random 100) bad-chance)) (setf card-played t) (let* ((r (random (length deck-of-damnation))) (card-type-id (first (nth r deck-of-damnation))) (piety-gain (second (nth r deck-of-damnation)))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Malseraph draws the ~A. " (name (get-card-type-by-id card-type-id))) :color sdl:*magenta* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind))) (funcall (on-use (get-card-type-by-id card-type-id)) (get-card-type-by-id card-type-id) mob) (incf new-piety piety-gain) (when (= card-type-id +item-card-teleport+) (update-visible-mobs mob) (when (eq mob *player*) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*)) (update-map-area *start-map-x* 0))) (loop for mob-id in (visible-mobs mob) for vmob = (get-mob-by-id mob-id) with enemy-strength = 0 when (and (not (check-dead vmob)) (not (is-merged vmob)) (null (get-faction-relation (faction mob) (get-visible-faction vmob :viewer mob)))) do (incf enemy-strength (strength vmob)) finally (when (>= enemy-strength (strength mob)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Malseraph bursts with laughter. ") :color sdl:*magenta* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind))) (incf new-piety 40))))) ;; Malseraph is interested and something good is about to happen (when (and (not card-played) (not (zerop good-chance)) (< (random 100) good-chance)) (setf card-played t) (let* ((r (random (length deck-of-boons))) (card-type-id (first (nth r deck-of-boons))) (needs-enemies (second (nth r deck-of-boons))) (print-msg (third (nth r deck-of-boons))) (nearest-enemy (loop for mob-id in (visible-mobs mob) for vmob = (get-mob-by-id mob-id) when (and (not (check-dead vmob)) (not (is-merged vmob)) (null (get-faction-relation (faction mob) (get-visible-faction vmob :viewer mob)))) do (return vmob)))) (when (or (and needs-enemies nearest-enemy) (not needs-enemies)) (when (or print-msg (and (not print-msg) (eq mob *player*))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Malseraph draws the ~A. " (name (get-card-type-by-id card-type-id))) :color sdl:*magenta* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind)))) (funcall (on-use (get-card-type-by-id card-type-id)) (get-card-type-by-id card-type-id) mob)) )) ;; Malseraph is mildly interested and something neutral is about to happen (when (and (not card-played) (not (zerop neutral-chance)) (< (random 100) neutral-chance)) (setf card-played t) (let* ((r (random (length deck-of-neutrality))) (card-type-id (first (nth r deck-of-neutrality)))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Malseraph draws the ~A. " (name (get-card-type-by-id card-type-id))) :color sdl:*magenta* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind))) (funcall (on-use (get-card-type-by-id card-type-id)) (get-card-type-by-id card-type-id) mob) )) ;; check if strength of enemies around of you is more than the previous turn (loop for mob-id in (visible-mobs mob) for vmob = (get-mob-by-id mob-id) with enemy-strength = 0 when (and (not (check-dead vmob)) (not (is-merged vmob)) (null (get-faction-relation (faction mob) (get-visible-faction vmob :viewer mob)))) do (incf enemy-strength (strength vmob)) finally (when (> enemy-strength (+ (get-worshiped-god-param1 (worshiped-god mob)) (strength mob))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Malseraph giggles. ") :color sdl:*magenta* :tags (list (when (and (find (id mob) (shared-visible-mobs *player*)) (not (find (id mob) (proper-visible-mobs *player*)))) :singlemind))) (incf new-piety 40) (set-mob-worshiped-god-param1 mob enemy-strength)) (when (<= enemy-strength (+ (get-worshiped-god-param1 (worshiped-god mob)) (strength mob))) (set-mob-worshiped-god-param2 mob (1+ (get-worshiped-god-param2 (worshiped-god mob))))) (when (> (get-worshiped-god-param2 (worshiped-god mob)) 5) (set-mob-worshiped-god-param1 mob enemy-strength) (set-mob-worshiped-god-param2 mob 0))) (set-mob-piety mob new-piety)))))
19,096
Common Lisp
.lisp
165
43.866667
234
0.270454
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
78745bd9b172559530ce357bfdbb448d035dcce80ad1c328fec1c175e8f7321a
2,885
[ -1 ]
2,886
init-animation-types.lisp
gwathlobal_CotD/src/init-animation-types.lisp
(in-package :cotd) (set-anim-type (make-animation-type :id +anim-type-fire-dot+ :func #'(lambda (animation) (let ((x (anim-x animation)) (y (anim-y animation)) (z (anim-z animation)) (glyph-idx 10) (glyph-color (sdl:color :r 255 :g 140 :b 0)) (back-color sdl:*black*)) (multiple-value-bind (sx sy) (calculate-start-coord (x *player*) (y *player*) (memo (level *world*)) *max-x-view* *max-y-view*) (when (and (check-tile-on-map x y z sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) x y z))) (display-animation-on-map x y z glyph-idx glyph-color back-color))) )) )) (set-anim-type (make-animation-type :id +anim-type-severed-body-part+ :func #'(lambda (animation) (let ((tx) (ty) (tz) (rx) (ry) (item) (mob (first (anim-params animation))) (body-part-str (second (anim-params animation))) (body-part-type (third (anim-params animation)))) (setf rx (- (random 7) 3)) (setf ry (- (random 7) 3)) (setf tx rx ty ry tz (z mob)) (line-of-sight (x mob) (y mob) (z mob) (+ (x mob) rx) (+ (y mob) ry) (z mob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let ((exit-result t)) (block nil (unless (check-LOS-propagate dx dy dz prev-cell :check-move t) (setf exit-result 'exit) (return)) (setf tx dx ty dy tz dz) ;; display a severed flying body part (multiple-value-bind (sx sy) (calculate-start-coord (x *player*) (y *player*) (memo (level *world*)) *max-x-view* *max-y-view*) (when (and (check-tile-on-map dx dy dz sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) dx dy dz))) (display-animation-on-map dx dy dz 5 sdl:*red* sdl:*black*) (sdl:update-display) (sdl-cffi::sdl-delay 100)) ;; place a blood stain along the path of the head (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-fresh+ :x dx :y dy :z dz)) (when (and (check-tile-on-map dx dy dz sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) dx dy dz))) (reveal-cell-on-map (level *world*) dx dy dz) (display-cell-on-map dx dy dz))) ) exit-result))) (setf item (make-instance 'item :item-type body-part-type :x tx :y ty :z tz)) (setf (name item) (format nil "~A's ~A" (alive-name mob) body-part-str)) (setf (alive-name item) (format nil "~A" (alive-name mob))) (add-item-to-level-list (level *world*) item) (multiple-value-bind (sx sy) (calculate-start-coord (x *player*) (y *player*) (memo (level *world*)) *max-x-view* *max-y-view*) (when (and (check-tile-on-map tx ty tz sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) tx ty tz))) (reveal-cell-on-map (level *world*) tx ty tz) (display-cell-on-map tx ty tz))) (log:info (format nil "ANIMATION-FUNC: ~A [~A] leaves ~A [~A] at (~A ~A)~%" (name mob) (id mob) (name item) (id item) tx ty)) ) ) )) (set-anim-type (make-animation-type :id +anim-type-rain-dot+ :func #'(lambda (animation) (let ((x (anim-x animation)) (y (anim-y animation)) (z (anim-z animation)) (glyph-idx 99) (glyph-color sdl:*blue*) (back-color sdl:*black*)) (multiple-value-bind (sx sy) (calculate-start-coord (x *player*) (y *player*) (memo (level *world*)) *max-x-view* *max-y-view*) (when (and (check-tile-on-map x y z sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) x y z))) (display-animation-on-map x y z glyph-idx glyph-color back-color))) )) )) (set-anim-type (make-animation-type :id +anim-type-acid-dot+ :func #'(lambda (animation) (let ((x (anim-x animation)) (y (anim-y animation)) (z (anim-z animation)) (glyph-idx 10) (glyph-color (if (zerop (random 2)) (sdl:color :r 0 :g 150 :b 0) (sdl:color :r 0 :g 255 :b 0))) (back-color sdl:*black*)) (multiple-value-bind (sx sy) (calculate-start-coord (x *player*) (y *player*) (memo (level *world*)) *max-x-view* *max-y-view*) (when (and (check-tile-on-map x y z sx sy *max-x-view* *max-y-view* (view-z *player*)) (get-single-memo-visibility (get-memo-* (level *world*) x y z))) (display-animation-on-map x y z glyph-idx glyph-color back-color))) )) ))
9,496
Common Lisp
.lisp
92
43.902174
199
0.302364
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
b990436bb0815a5d170118a6302095bc626281b39af753c835303415d9fdcc46
2,886
[ -1 ]
2,887
factions.lisp
gwathlobal_CotD/src/factions.lisp
(in-package :cotd) (defclass faction-type () ((id :initarg :id :accessor id) (name :initarg :name :accessor name) (faction-relations :initarg :faction-relations :accessor faction-relations) (specific-faction-list :initform () :initarg :specific-faction-list :accessor specific-faction-list))) (defmethod initialize-instance :after ((faction-type faction-type) &key) (let ((faction-table (make-hash-table))) (loop for (faction . rel) in (faction-relations faction-type) do (setf (gethash faction faction-table) rel)) (setf (faction-relations faction-type) faction-table) )) (defun set-faction-type (faction-type) (when (>= (id faction-type) (length *faction-types*)) (adjust-array *faction-types* (list (1+ (id faction-type))) :initial-element nil)) (setf (aref *faction-types* (id faction-type)) faction-type)) (defun get-faction-type-by-id (faction-type-id) (aref *faction-types* faction-type-id)) ;; values should be (faction . relation) (defun set-faction-relations (faction-type &rest values) (let ((faction-table (make-hash-table))) (loop for (faction . rel) in values do (setf (gethash faction faction-table) rel)) (setf (faction-relations faction-type) faction-table) )) (defun get-faction-relation (faction-type-id-1 faction-type-id-2) (if (null (faction-relations (get-faction-type-by-id faction-type-id-1))) ;; no relation set for faction-type-id-1, which means they are enemies to everybody (return-from get-faction-relation nil) ;; return the relation for faction-type-id-2, if not set - then they are enemies (gethash faction-type-id-2 (faction-relations (get-faction-type-by-id faction-type-id-1)))) ) (defun get-general-faction-from-specific (specific-faction-id) (loop for faction-type across *faction-types* when (and faction-type (find specific-faction-id (specific-faction-list faction-type))) do (return-from get-general-faction-from-specific (id faction-type))) nil) (defun set-specific-faction-name (specific-faction-id name-string) (setf (gethash specific-faction-id *specific-faction-names*) name-string)) (defun get-specific-faction-name (specific-faction-id) (gethash specific-faction-id *specific-faction-names*))
2,322
Common Lisp
.lisp
47
44.553191
105
0.712014
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
3b4d76071bc10fe9dcd674f423bfc5fe717ca5e50a178fdb305e48ea07f04127
2,887
[ -1 ]
2,888
generate-level.lisp
gwathlobal_CotD/src/generate-level.lisp
(in-package :cotd) ;; the level generation function takes the following parameters: ;; sector-level-gen-func - main funcation to generate a level from template (for example, city level) ;; takes: (template-level set-max-buildings-func set-reserved-buildings-func) ;; returns: (real-terrain mob-template-list item-template-list feature-template-list) ;; item-process-func-list - list of functions that generate items on the level ;; takes: (item-template-list) ;; returns: (list of items) ;; feature-process-func-list - list of functions that generate features on the level ;; takes: (feature-template-list) ;; returns: (list of features) ;; mob-process-func-list - list of functions that generate mobs on the level ;; takes: (mob-template-list) ;; returns: (list of mobs) ;; level-template-pre-process-func-list - list of functions that modify the template level before the sector-level-gen-func ;; takes: (template-level) ;; returns: (template-level (list of buildings)) ;; terrain-level-post-process-func-list - list of functions that modify the real terrain on the level after the sector-level-gen-func ;; takes: (real-terrain) ;; returns: (real-terrain) ;; (defun generate-level-from-sector (sector-level-gen-func &key (max-x *max-x-level*) (max-y *max-y-level*) (max-z *max-z-level*) (overall-post-process-func-list ()) (level-template-pre-process-func-list ()) (terrain-level-post-process-func-list ()) (world-sector nil) (mission nil) (world nil) ) (unless world-sector (error ":WORLD-SECTOR is an obligatory parameter!")) (unless mission (error ":MISSION is an obligatory parameter!")) (unless world (error ":WORLD is an obligatory parameter!")) ;; create a template level (let* ((level nil) (terrain-level nil) (feature-template-result nil) (mob-template-result nil) (item-template-result nil)) (let* ((template-max-x (truncate max-x *level-grid-size*)) (template-max-y (truncate max-y *level-grid-size*)) (template-max-z max-z) (template-level (make-array (list template-max-x template-max-y template-max-z) :initial-element t)) ;; the values in template-level are as follows: ;; t - reserved ;; nil - free ;; list of (+building-type-<id>+ x y z) ) (setf *max-progress-bar* 11) (setf *cur-progress-bar* 0) (funcall *update-screen-closure* "Generating map") ;; all grid cells along the borders are reserved, while everything inside is free for claiming (loop for y from 1 below (1- template-max-y) do (loop for x from 1 below (1- template-max-x) do (loop for z from 0 below template-max-z do (setf (aref template-level x y z) nil)))) ;; use level template pre-process functions to place reserved buildings from sector features, factions, etc (loop for level-template-pre-process-func in level-template-pre-process-func-list do (funcall level-template-pre-process-func template-level world-sector mission world)) ;; adjusting the progress bar : 1 (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) ;; produce terrain level from template using the supplied function (multiple-value-setq (terrain-level mob-template-result item-template-result feature-template-result) (funcall sector-level-gen-func template-level max-x max-y max-z)) ;; create level with dimenision based on terrain-level dimensions (setf level (create-level :max-x (array-dimension terrain-level 0) :max-y (array-dimension terrain-level 1) :max-z (array-dimension terrain-level 2))) (setf (terrain level) terrain-level) (setf (level world) level) ;; adjusting the progress bar : 2 (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (setf (mob-quadrant-map level) (make-array (list (ceiling (array-dimension (terrain level) 0) 10) (ceiling (array-dimension (terrain level) 1) 10)) :initial-element ())) (setf (item-quadrant-map level) (make-array (list (ceiling (array-dimension (terrain level) 0) 10) (ceiling (array-dimension (terrain level) 1) 10)) :initial-element ())) (setf (light-quadrant-map level) (make-array (list (ceiling (array-dimension (terrain level) 0) 10) (ceiling (array-dimension (terrain level) 1) 10)) :initial-element ())) (setf (mission level) mission) (setf (world-sector level) world-sector) ;; populate world with items (log:info "Placing standard items") (loop for (item-type-id x y z qty) in item-template-result do (add-item-to-level-list level (make-instance 'item :item-type item-type-id :x x :y y :z z :qty qty))) ;; populate world with features (log:info "Placing standard features") (loop for (feature-type-id x y z) in feature-template-result do (add-feature-to-level-list level (make-instance 'feature :feature-type feature-type-id :x x :y y :z z))) ;; adjusting the progress bar : 3 (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) ;; post process actual level (demonic portals, blood spatter, irradiated spots, etc) (loop for terrain-post-process-func in terrain-level-post-process-func-list do (setf terrain-level (funcall terrain-post-process-func level world-sector mission world))) ) ;; check map for connectivity : 4 (incf *cur-progress-bar*) (funcall *update-screen-closure* "Creating connectivity maps") (setf *time-at-end-of-player-turn* (get-internal-real-time)) ;; generate connectivity maps (let* ((size-1-thread (bt:make-thread #'(lambda () (let ((start-time (get-internal-real-time))) (create-connect-map-walk level 1) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER WALK 1: ~A" (- (get-internal-real-time) start-time)) ) (let ((start-time (get-internal-real-time))) (create-connect-map-climb level 1) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER CLIMB 1: ~A" (- (get-internal-real-time) start-time)) ) (let ((start-time (get-internal-real-time))) (create-connect-map-fly level 1) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER FLY 1: ~A" (- (get-internal-real-time) start-time)) ) (let ((start-time (get-internal-real-time))) (create-connect-map-aux level) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER CLIMB 1: ~A" (- (get-internal-real-time) start-time)) ) ) :name "Connectivity map (size 1) thread")) (size-3-thread (bt:make-thread #'(lambda () (let ((start-time (get-internal-real-time))) (create-connect-map-walk level 3) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER WALK 3: ~A" (- (get-internal-real-time) start-time)) ) (let ((start-time (get-internal-real-time))) (create-connect-map-climb level 3) (incf *cur-progress-bar*) (funcall *update-screen-closure* nil) (log:info "TIME-ELAPSED AFTER CLIMB 3: ~A" (- (get-internal-real-time) start-time)) ) ;;(let ((start-time (get-internal-real-time))) ;; (create-connect-map-fly (level world) 3) ;; (incf *cur-progress-bar*) ;; (funcall *update-screen-closure* nil) ;; (format out "TIME-ELAPSED AFTER FLY 3: ~A~%" (- (get-internal-real-time) start-time)) ;; ) ) :name "Connectivity map (size 3) thread")) ) (bt:join-thread size-1-thread) (log:info "SIZE 1 CREATION FINISHED") (bt:join-thread size-3-thread) (log:info "SIZE 3 CREATION FINISHED") ) ;; adjusting the progress bar : 10 (incf *cur-progress-bar*) (funcall *update-screen-closure* "Finalizing") (push +game-event-adjust-outdoor-light+ (game-events level)) ;; populate world with standard mobs (from actual level template) (log:info "Placing standard mobs") (loop for (mob-type-id x y z) in mob-template-result when (null (get-mob-* level x y z)) do (add-mob-to-level-list level (make-instance 'mob :mob-type mob-type-id :x x :y y :z z))) ;; populate the world with special mobs (military in outposts, demons around portals, etc) depending on present factions (loop for overall-post-process-func in overall-post-process-func-list do (funcall overall-post-process-func level world-sector mission world)) ;; setting up demonic portals so that mobs could access them directly without iterating through the whole list of features (loop for feature-id in (feature-id-list (level world)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-demonic-portal+) do (push feature-id (demonic-portals level))) ) ) (defun create-level (&key (max-x *max-x-level*) (max-y *max-y-level*) (max-z *max-z-level*)) (let ((level)) (setf level (make-instance 'level)) (setf (terrain level) (make-array (list max-x max-y max-z) :initial-element +terrain-floor-stone+)) (setf (mobs level) (make-array (list max-x max-y max-z) :initial-element nil)) (setf (items level) (make-array (list max-x max-y max-z) :initial-element nil)) (setf (features level) (make-array (list max-x max-y max-z) :initial-element nil)) (setf (memo level) (make-array (list max-x max-y max-z))) (setf (light-map level) (make-array (list max-x max-y max-z) :initial-element 0)) (loop for x from 0 below max-x do (loop for y from 0 below max-y do (loop for z from 0 below max-z do (set-memo-* level x y z (create-single-memo 0 sdl:*white* sdl:*black* nil nil 0 nil))))) level)) (defun reserve-build-on-grid (template-building-id gx gy gz template-level) (destructuring-bind (dx . dy) (building-grid-dim (get-building-type template-building-id)) (let ((building (list template-building-id gx gy gz))) (loop for y1 from 0 below dy do (loop for x1 from 0 below dx do (setf (aref template-level (+ gx x1) (+ gy y1) gz) building))) building))) (defun can-place-build-on-grid (template-building-id gx gy gz template-level) (destructuring-bind (dx . dy) (building-grid-dim (get-building-type template-building-id)) ;; if the staring point of the building + its dimensions) is more than level dimensions - fail (when (or (> (+ gx dx) (array-dimension template-level 0)) (> (+ gy dy) (array-dimension template-level 1))) (return-from can-place-build-on-grid nil)) ;; if any of the grid tiles that the building is going to occupy are already reserved - fail (loop for y1 from 0 below dy do (loop for x1 from 0 below dx do (unless (eq (aref template-level (+ gx x1) (+ gy y1) gz) nil) (return-from can-place-build-on-grid nil)) )) ;; all checks done - success t )) (defun prepare-gen-build-id-list (max-building-types &optional increased-build-type-id) ;; a hack to make houses appear 3 times more frequently (append (loop repeat 3 collect (prepare-spec-build-id-list increased-build-type-id)) (loop for gen-build-type-id being the hash-key in max-building-types collect (prepare-spec-build-id-list gen-build-type-id)))) (defun prepare-spec-build-id-list (gen-build-type-id) (loop for spec-build-type being the hash-value in *building-types* when (= (building-type spec-build-type) gen-build-type-id) collect (building-id spec-build-type))) (defun flood-fill (first-cell &key (max-x *max-x-level*) (max-y *max-y-level*) (max-z *max-z-level*) check-func make-func) (declare (optimize (speed 3) (safety 0)) (type function check-func make-func) (type fixnum max-x max-y max-z)) (let ((open-list nil)) (push first-cell open-list) (loop while open-list for c-cell of-type list = (pop open-list) for cx of-type fixnum = (first c-cell) for cy of-type fixnum = (second c-cell) for cz of-type fixnum = (third c-cell) do (funcall make-func cx cy cz) (loop for y-offset of-type fixnum from -1 to 1 for y of-type fixnum = (+ cy y-offset) do (loop for x-offset of-type fixnum from -1 to 1 for x of-type fixnum = (+ cx x-offset) do (loop for z-offset of-type fixnum from -1 to 1 for z of-type fixnum = (+ cz z-offset) when (and (>= x 0) (>= y 0) (>= z 0) (< x max-x) (< y max-y) (< z max-z) (not (and (zerop x-offset) (zerop y-offset) (zerop z-offset))) (funcall check-func x y z cx cy cz)) do (push (list x y z) open-list)))) ) )) (defun create-connect-map-walk (level mob-size) (declare (optimize (speed 3)) (type fixnum mob-size)) (let* ((max-x (array-dimension (terrain level) 0)) (max-y (array-dimension (terrain level) 1)) (max-z (array-dimension (terrain level) 2)) (connect-map (if (aref (connect-map level) mob-size) (aref (connect-map level) mob-size) (make-array (list max-x max-y max-z) :initial-element nil))) (room-id 0) (check-func #'(lambda (x y z cx cy cz) (let* ((connect-id (get-connect-map-value connect-map x y z +connect-map-move-walk+)) (half-size (truncate (1- mob-size) 2))) (declare (type fixnum connect-id half-size cx cy cz x y z)) (if (and (= connect-id +connect-room-none+) (funcall #'(lambda (sx sy) (let ((result t)) (block from-result (loop for off-x of-type fixnum from (- half-size) to (+ half-size) for nx of-type fixnum = (+ sx off-x) do (loop for off-y of-type fixnum from (- half-size) to (+ half-size) for ny of-type fixnum = (+ sy off-y) do (when (or (< nx 0) (< ny 0) (>= nx max-x) (>= ny max-y) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-openable-door+)) (setf result nil) (return-from from-result)) ;; magic starts here (setf result nil) (when (and (or (= (- cz z) 0) (and (/= (- cz z) 0) (= nx cx) (= ny cy)) ) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | |p| | ;; floor z = 1 -> | |.| | ;; on floor z = 0 -> | |x| | ;; floor z = 0 -> | |w| | ;; where ;; w - water ;; . - air (no floor, no wall, no water) ;; p - starting cell ;; x - current cell (when (and (not result) (< (- z cz) 0) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (and (= cx nx) (= cy ny)) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | | |x| ;; floor z = 1 -> | | |#| ;; on floor z = 0 -> | |p| | ;; floor z = 0 -> | |w| | ;; where ;; # - floor ;; . - air ;; w - water ;; p - starting cell ;; x - current cell (when (and (> (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+) (not (and (= cx nx) (= cy ny))) (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+)) (or (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+))) ;(format t "FLOOD FILL HERE~%") (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | | |x| ;; floor z = 1 -> | | |#| ;; on floor z = 0 -> | |p| | ;; floor z = 0 -> | |u| | ;; where ;; # - floor ;; . - air ;; u - slope up (with floor) ;; p - starting cell ;; x - current cell (when (and (> (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-slope-up+) (not (and (= cx nx) (= cy ny))) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+)) ;(format t "FLOOD FILL HERE~%") (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | |p| | ;; floor z = 1 -> | |d| | ;; on floor z = 0 -> | |x| | ;; floor z = 0 -> | |u| | ;; where ;; u - slope up (with floor) ;; d - slope down (with air) ;; p - starting cell ;; x - current cell (when (and (not result) (< (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-slope-down+) (and (= cx nx) (= cy ny)) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-slope-up+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+)) (setf result t)) ;; the following case is connected ;; on floor z = 0 -> | |x|p| ;; floor z = 0 -> | |?|#| ;; where ;; # - floor ;; ? - not important ;; p - starting cell ;; x - current cell (when (and (not result) (= (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+) ;(not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+)) ) (setf result t)) ;; if you are large, you can move only if all you tiles have opaque floor (when (and (> mob-size 1) (= (- z cz) 0) (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+))) (setf result nil)) ;; all other cases are disconnected (unless result (return-from from-result)) ))) result)) x y)) t nil)))) (make-func #'(lambda (x y z) (set-connect-map-value connect-map x y z +connect-map-move-walk+ room-id) ))) (declare (type fixnum max-x max-y max-z room-id)) (loop for x of-type fixnum from 0 below max-x do (loop for y of-type fixnum from 0 below max-y do (loop for z of-type fixnum from 0 below max-z do (when (funcall check-func x y z x y z) (flood-fill (list x y z) :max-x max-x :max-y max-y :max-z max-z :check-func check-func :make-func make-func) (incf room-id)) ))) (setf (aref (connect-map level) mob-size) connect-map) )) (defun create-connect-map-climb (level mob-size) (declare (optimize (speed 3)) (type fixnum mob-size)) (let* ((max-x (array-dimension (terrain level) 0)) (max-y (array-dimension (terrain level) 1)) (max-z (array-dimension (terrain level) 2)) (connect-map (if (aref (connect-map level) mob-size) (aref (connect-map level) mob-size) (make-array (list max-x max-y max-z) :initial-element nil))) (room-id 0) (check-func #'(lambda (x y z cx cy cz) (let* ((connect-id (get-connect-map-value connect-map x y z +connect-map-move-climb+)) (half-size (truncate (1- mob-size) 2))) (declare (type fixnum connect-id half-size cx cy cz x y z)) (if (and (= connect-id +connect-room-none+) (funcall #'(lambda (sx sy) (let ((result t)) (block from-result (loop for off-x of-type fixnum from (- half-size) to (+ half-size) for nx of-type fixnum = (+ sx off-x) do (loop for off-y of-type fixnum from (- half-size) to (+ half-size) for ny of-type fixnum = (+ sy off-y) do (when (or (< nx 0) (< ny 0) (>= nx max-x) (>= ny max-y) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-openable-door+)) (setf result nil) (return-from from-result)) ;; magic starts here (setf result nil) (when (and (or (= (- cz z) 0) (and (/= (- cz z) 0) (= nx cx) (= ny cy)) ) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | |p| | ;; floor z = 1 -> | |.| | ;; on floor z = 0 -> | |x| | ;; floor z = 0 -> | |w| | ;; where ;; w - water ;; . - air (no floor, no wall, no water) ;; p - starting cell ;; x - current cell (when (and (not result) (< (- z cz) 0) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (and (= cx nx) (= cy ny)) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | | |x| ;; floor z = 1 -> | | |#| ;; on floor z = 0 -> | |p| | ;; floor z = 0 -> | |w| | ;; where ;; # - floor ;; . - air ;; w - water ;; p - starting cell ;; x - current cell (when (and (> (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+) (not (and (= cx nx) (= cy ny))) (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+)) (or (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+))) ;(format t "FLOOD FILL HERE~%") (setf result t)) ;; the following case is connected ;; on floor z = 0 -> | |x|p| ;; floor z = 0 -> | |?|#| ;; where ;; # - floor ;; ? - not important ;; p - starting cell ;; x - current cell (when (and (= (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+) ) (setf result t)) (when (and (not result) (or (= (- cz z) 0) (and (/= (- cz z) 0) (= nx cx) (= ny cy))) (check-move-along-z cx cy cz nx ny z) (funcall #'(lambda () (let ((result nil)) (block surround (check-surroundings nx ny nil #'(lambda (mx my) (when (and (get-terrain-* (level *world*) mx my z) (not (get-terrain-type-trait (get-terrain-* (level *world*) mx my z) +terrain-trait-not-climable+)) (or (get-terrain-type-trait (get-terrain-* (level *world*) mx my z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) mx my z) +terrain-trait-blocks-move+))) (setf result t) (return-from surround))))) result)))) (setf result t)) ;; if you are large, you can move only if all you tiles have opaque floor (when (and (> mob-size 1) (= (- z cz) 0) (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+))) (setf result nil)) ;; all other cases are disconnected (unless result (return-from from-result)) ))) result)) x y)) t nil)))) (make-func #'(lambda (x y z) (set-connect-map-value connect-map x y z +connect-map-move-climb+ room-id) ))) (declare (type fixnum max-x max-y max-z room-id)) (loop for x of-type fixnum from 0 below max-x do (loop for y of-type fixnum from 0 below max-y do (loop for z of-type fixnum from 0 below max-z do (when (funcall check-func x y z x y z) (flood-fill (list x y z) :max-x max-x :max-y max-y :max-z max-z :check-func check-func :make-func make-func) (incf room-id)) ))) (setf (aref (connect-map level) mob-size) connect-map))) (defun create-connect-map-fly (level mob-size) (declare (optimize (speed 3)) (type fixnum mob-size)) (let* ((max-x (array-dimension (terrain level) 0)) (max-y (array-dimension (terrain level) 1)) (max-z (array-dimension (terrain level) 2)) (connect-map (if (aref (connect-map level) mob-size) (aref (connect-map level) mob-size) (make-array (list max-x max-y max-z) :initial-element nil))) (room-id 0) (check-func #'(lambda (x y z cx cy cz) (let* ((connect-id (get-connect-map-value connect-map x y z +connect-map-move-fly+)) (half-size (truncate (1- mob-size) 2))) (declare (type fixnum connect-id half-size cx cy cz x y z)) (if (and (= connect-id +connect-room-none+) (funcall #'(lambda (sx sy) (let ((result t)) (block from-result (loop for off-x of-type fixnum from (- half-size) to (+ half-size) for nx of-type fixnum = (+ sx off-x) do (loop for off-y of-type fixnum from (- half-size) to (+ half-size) for ny of-type fixnum = (+ sy off-y) do (when (or (< nx 0) (< ny 0) (>= nx max-x) (>= ny max-y) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-openable-door+)) (setf result nil) (return-from from-result)) ;; magic starts here (setf result nil) (when (and (or (= (- cz z) 0) (and (/= (- cz z) 0) (= nx cx) (= ny cy)) ) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | |p| | ;; floor z = 1 -> | |.| | ;; on floor z = 0 -> | |x| | ;; floor z = 0 -> | |w| | ;; where ;; w - water ;; . - air (no floor, no wall, no water) ;; p - starting cell ;; x - current cell (when (and (not result) (< (- z cz) 0) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+)) (and (= cx nx) (= cy ny)) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+)) (setf result t)) ;; the following case is connected ;; on floor z = 1 -> | | |x| ;; floor z = 1 -> | | |#| ;; on floor z = 0 -> | |p| | ;; floor z = 0 -> | |w| | ;; where ;; # - floor ;; . - air ;; w - water ;; p - starting cell ;; x - current cell (when (and (> (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-water+) (not (and (= cx nx) (= cy ny))) (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move+)) (or (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-water+))) ;(format t "FLOOD FILL HERE~%") (setf result t)) ;; the following case is connected ;; on floor z = 0 -> | |x|p| ;; floor z = 0 -> | |?|#| ;; where ;; # - floor ;; ? - not important ;; p - starting cell ;; x - current cell (when (and (= (- z cz) 0) (get-terrain-type-trait (get-terrain-* level cx cy cz) +terrain-trait-blocks-move-floor+) ) (setf result t)) ;; check small mobs connectivity via flight (when (and (not result) (or (= (- cz z) 0) (and (/= (- cz z) 0) (= nx cx) (= ny cy)) ) (check-move-along-z cx cy cz nx ny z) ) (setf result t)) ;; check large mobs connectivity via flight (when (and (not result) (> mob-size 1) (/= (- cz z) 0) (check-move-along-z nx ny cz nx ny z)) (setf result t)) ;; if you are large, you can move only if all you tiles have opaque floor ;(when (and (> mob-size 1) ; (= (- z cz) 0) ; (not (get-terrain-type-trait (get-terrain-* level nx ny z) +terrain-trait-blocks-move-floor+))) ; (setf result nil)) ;; all other cases are disconnected (unless result (return-from from-result)) ))) result)) x y)) t nil)))) (make-func #'(lambda (x y z) (set-connect-map-value connect-map x y z +connect-map-move-fly+ room-id) ))) (declare (type fixnum max-x max-y max-z room-id)) (loop for x of-type fixnum from 0 below max-x do (loop for y of-type fixnum from 0 below max-y do (loop for z of-type fixnum from 0 below max-z do (when (funcall check-func x y z x y z) (flood-fill (list x y z) :max-x max-x :max-y max-y :max-z max-z :check-func check-func :make-func make-func) (incf room-id)) ))) (setf (aref (connect-map level) mob-size) connect-map))) (defun create-connect-map-aux (level) ;; make auxiliary links (let ((max-x (array-dimension (terrain level) 0)) (max-y (array-dimension (terrain level) 1)) (max-z (array-dimension (terrain level) 2))) (loop for x of-type fixnum from 1 below (1- max-x) do (loop for y of-type fixnum from 1 below (1- max-y) do (loop for z of-type fixnum from 0 below max-z do (when (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-openable-door+) (let ((func #'(lambda (&key map-size move-mode) (let ((room-id-list nil) ;; increase actual connection depending on door being open/close (delta-actual (if (get-terrain-type-trait (get-terrain-* level x y z) +terrain-trait-blocks-move+) 0 1))) (check-surroundings x y nil #'(lambda (dx dy) (when (/= (get-level-connect-map-value level dx dy z map-size move-mode) +connect-room-none+) (pushnew (get-level-connect-map-value level dx dy z map-size move-mode) room-id-list)))) (loop for room-id-start in room-id-list do (loop for room-id-end in room-id-list do (when (/= room-id-start room-id-end) (set-aux-map-connection level room-id-start room-id-end map-size move-mode :delta-potential 1 :delta-actual delta-actual)))))))) (funcall func :map-size 1 :move-mode +connect-map-move-walk+) (funcall func :map-size 1 :move-mode +connect-map-move-climb+) (funcall func :map-size 1 :move-mode +connect-map-move-fly+) )))))))
59,474
Common Lisp
.lisp
692
39.050578
234
0.324467
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
c33fde8736124ff122f92dfebf5f69b299805f128c7831d0a7cc8d731a64b025
2,888
[ -1 ]
2,889
game-state.lisp
gwathlobal_CotD/src/game-state.lisp
(in-package :cotd) (defenum:defenum game-state-enum (:game-state-start :game-state-init :game-state-main-menu :game-state-custom-scenario :game-state-campaign-init :game-state-campaign-map :game-state-campaign-scenario :game-state-post-scenario :game-state-quit)) (defclass game-manager () ((game-state :initform :game-state-start :accessor game-manager/game-state :type game-state-enum) (game-slot-id :initform nil :initarg :game-slot-id :accessor game-manager/game-slot-id :type (or null fixnum)))) (defun game-state-start->init () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-start)) (error (format nil "GAME-STATE-START->INIT: Game state is ~A, not GAME-STATE-START" game-state))) (setf game-state :game-state-init))) (defun game-state-init->menu () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-init)) (error (format nil "GAME-STATE-INIT->MENU: Game state is ~A, not GAME-STATE-INIT" game-state))) (setf game-state :game-state-main-menu))) (defun game-state-menu->quit () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-main-menu)) (error (format nil "GAME-STATE-MENU->QUIT: Game state is ~A, not GAME-STATE-MAIN-MENU" game-state))) (setf game-state :game-state-quit))) (defun game-state-menu->custom-scenario () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-main-menu)) (error (format nil "GAME-STATE-MENU->CUSTOM-SCENARIO: Game state is ~A, not GAME-STATE-MAIN-MENU" game-state))) (setf game-state :game-state-custom-scenario))) (defun game-state-custom-scenario->menu () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-custom-scenario)) (error (format nil "GAME-STATE-CUSTOM-SCENARIO->MENU: Game state is ~A, not GAME-STATE-CUSTOM-SCENARIO" game-state))) (setf game-state :game-state-main-menu))) (defun game-state-menu->campaign-init () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-main-menu)) (error (format nil "GAME-STATE-MENU->CAMPAIGN-INIT: Game state is ~A, not GAME-STATE-MAIN-MENU" game-state))) (setf game-state :game-state-campaign-init))) (defun game-state-campaign-init->campaign-map () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-init)) (error (format nil "GAME-STATE-CAMPAIGN-INIT->CAMPAIGN-MAP: Game state is ~A, not GAME-STATE-CAMPAIGN-INIT" game-state))) (setf game-state :game-state-campaign-map))) (defun game-state-menu->campaign-map () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-main-menu)) (error (format nil "GAME-STATE-MENU->CAMPAIGN-MAP: Game state is ~A, not GAME-STATE-MAIN-MENU" game-state))) (setf game-state :game-state-campaign-map))) (defun game-state-menu->campaign-scenario () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-main-menu)) (error (format nil "GAME-STATE-MENU->CAMPAIGN-SCENARIO: Game state is ~A, not GAME-STATE-MAIN-MENU" game-state))) (setf game-state :game-state-campaign-scenario))) (defun game-state-campaign-scenario->menu () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-scenario)) (error (format nil "GAME-STATE-CAMPAIGN-SCENARIO->MENU: Game state is ~A, not GAME-STATE-CAMPAIGN-SCENARIO" game-state))) (setf game-state :game-state-main-menu))) (defun game-state-campaign-map->campaign-scenario () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-map)) (error (format nil "GAME-STATE-CAMPAIGN-MAP->CAMPAIGN-SCENARIO: Game state is ~A, not GAME-STATE-CAMPAIGN-MAP" game-state))) (setf game-state :game-state-campaign-scenario))) (defun game-state-campaign-map->post-scenario () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-map)) (error (format nil "GAME-STATE-CAMPAIGN-MAP->POST-SCENARIO: Game state is ~A, not GAME-STATE-CAMPAIGN-MAP" game-state))) (setf game-state :game-state-post-scenario))) (defun game-state-campaign-map->menu () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-map)) (error (format nil "GAME-STATE-CAMPAIGN-MAP->MENU: Game state is ~A, not GAME-STATE-CAMPAIGN-MAP" game-state))) (setf game-state :game-state-main-menu))) (defun game-state-campaign-scenario->post-scenario () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-campaign-scenario)) (error (format nil "GAME-STATE-CAMPAIGN-SCENARIO->POST-SCENARIO: Game state is ~A, not GAME-STATE-CAMPAIGN-SCENARIO" game-state))) (setf game-state :game-state-post-scenario))) (defun game-state-post-scenario->campaign-map () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-post-scenario)) (error (format nil "GAME-STATE-POST-SCENARIO->CAMPAIGN-MAP: Game state is ~A, not GAME-STATE-POST-SCENARIO" game-state))) (setf game-state :game-state-campaign-map))) (defun game-state-post-scenario->menu () (with-slots (game-state) *game-manager* (when (not (eq game-state :game-state-post-scenario)) (error (format nil "GAME-STATE-POST-SCENARIO->MENU: Game state is ~A, not GAME-STATE-POST-SCENARIO" game-state))) (setf game-state :game-state-main-menu)))
5,747
Common Lisp
.lisp
93
54.870968
136
0.677431
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
4039b1f4b907655942b85a92589da7a019f2f2c8930468437f4d70affbc9452d
2,889
[ -1 ]
2,890
init-ability-types.lisp
gwathlobal_CotD/src/init-ability-types.lisp
(in-package :cotd) (set-ability-type (make-instance 'ability-type :id +mob-abil-heal-self+ :name "Heal self" :descr "Invoke divine powers to heal yourself." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (let ((heal-pwr (+ (* 4 (mob-ability-value actor +mob-abil-heal-self+)) (random (* 3 (mob-ability-value actor +mob-abil-heal-self+)))))) (when (> (+ (cur-hp actor) heal-pwr) (max-hp actor)) (setf heal-pwr (- (max-hp actor) (cur-hp actor)))) (incf (cur-hp actor) heal-pwr) (decf (cur-fp actor) (cost ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes divine powers to heal itself for ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) heal-pwr) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if able to heal and less than 50% hp - heal (if (and (or (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.5)) (and (not nearest-enemy) (< (/ (cur-hp actor) (max-hp actor)) 0.9))) (mob-ability-p actor +mob-abil-heal-self+) (can-invoke-ability actor actor +mob-abil-heal-self+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-conceal-divine+ :name "Conceal divinity" :descr "Disguise yourself as a human. Divine abilities do not work while in human form." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 25 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (set-mob-effect actor :effect-type-id +mob-effect-divine-concealed+ :actor-id (id actor) :cd t) (generate-sound actor (x actor) (y actor) (z actor) 30 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (when (check-mob-visible actor :observer *player*) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes divine powers to disguise itself as a human. " (capitalize-name (prepend-article +article-the+ (name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-reveal-true-form+)) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if the dst is more than 3 tiles away - stealth, if possible (if (and (path actor) (> (length (path actor)) 3) (or (not nearest-enemy) (and nearest-enemy (> (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2))) (mob-ability-p actor +mob-abil-conceal-divine+) (can-invoke-ability actor actor +mob-abil-conceal-divine+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-reveal-divine+ :name "Reveal divinity" :descr "Invoke to reveal you divinity." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 25 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (rem-mob-effect actor +mob-effect-divine-concealed+) (generate-sound actor (x actor) (y actor) (z actor) 30 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (when (check-mob-visible actor :observer *player*) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals its true divine form. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-effect-p actor +mob-effect-divine-concealed+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if able to heal and need to reveal itself - do it ;; if the enemy is near and the dst tile is less than 2 tiles away - unstealth, if possible (if (or (and (<= (length (path actor)) 1) (mob-ability-p actor +mob-abil-reveal-divine+) (can-invoke-ability actor actor +mob-abil-reveal-divine+) nearest-enemy (< (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2)) (and (< (/ (cur-hp actor) (max-hp actor)) 0.5) (mob-ability-p actor +mob-abil-heal-self+) (mob-effect-p actor +mob-effect-divine-concealed+) (mob-ability-p actor +mob-abil-reveal-divine+) (can-invoke-ability actor actor +mob-abil-reveal-divine+) (abil-applic-cost-p +mob-abil-heal-self+ actor))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-detect-good+ :name "Detect good" :descr "You are able to reveal the true form of divine beings when you touch them. You can also sense the general direction to the nearest diving being." :passive t :cost 0 :spd 0 :final nil :on-touch t :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (rem-mob-effect target +mob-effect-divine-concealed+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-detect-good+) (mob-effect-p target +mob-effect-divine-concealed+)) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-detect-evil+ :name "Detect evil" :descr "You are able to reveal the true form of demonic beings when you touch them. You can also sense the general direction to the nearest demonic being." :passive t :cost 0 :spd 0 :final nil :on-touch t :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (unless (mob-effect-p target +mob-effect-reveal-true-form+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5)) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-detect-evil+) (mob-effect-p target +mob-effect-possessed+) (not (mob-ability-p target +mob-abil-ghost-possess+))) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-possessable+ :name "Can be possessed" :descr "Your body can be possessed by demonic forces." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-nameless+ :name "Nameless" :descr "You are one of may and have no name." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-strength-in-numbers+ :name "Strength in numbers" :descr "You get +10% max damage for each attack for every friendly demon in your line of sight." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-coward+ :name "Coward" :descr "You are a coward and feel safe only when demonic allies are nearby. You get twice as much bonus from the Strength in numbers ability." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-can-possess+ :name "Can possess" :descr "You are able to possess bodies of mortal creatures. Possessed creatures may sometimes revolt. Higher-ranking demons are better at supressing the victim's willpower. You need to be in the \"Ready to possess\" mode (see \"Toggle possession mode\" ability). You can not possess mortals while mounted." :passive t :cost 0 :spd +normal-ap+ :final t :on-touch t :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-POSSESS-TARGET: ~A [~A] possesses ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (rem-mob-effect actor +mob-effect-ready-to-possess+) (mob-possess-target actor target) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A possesses ~A. " (capitalize-name (prepend-article +article-the+ (name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-can-possess+) (mob-ability-p target +mob-abil-possessable+) (mob-effect-p actor +mob-effect-ready-to-possess+) (not (mob-effect-p target +mob-effect-blessed+)) (not (mob-effect-p target +mob-effect-divine-shield+)) (not (mob-effect-p actor +mob-effect-possessed+)) (not (mob-effect-p target +mob-effect-possessed+)) (not (riding-mob-id actor)) ) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-purging-touch+ :name "Purging touch" :descr "You are able to destroy demons who possess humans without harming the mortal bodies of the latter." :passive t :cost 0 :spd 0 :final t :on-touch t :motion 10 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (melee-target actor target :kill-possessed nil) (log:info (format nil "INSIDE PURGING TOUCH: ~A, (check-dead target) ~A~%" (name target) (check-dead target))) (when (and (check-dead target) (slave-mob-id target)) (incf (cur-fp actor)) (mob-depossess-target target)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-purging-touch+) (mob-effect-p target +mob-effect-possessed+) (not (mob-ability-p target +mob-abil-ghost-possess+)) (not (mob-effect-p actor +mob-effect-divine-concealed+))) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-purge-rune+ :name "Purge rune" :descr "Purge a demonic rune and gain 4 power for it. You must stand next to a rune to purge it." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-rune :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is a feature (demonic rune) to be purged (log:info (format nil "MOB-PURGE-RUNE: ~A [~A] purges ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A purges ~A and gains power. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-a+ (name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (remove-feature-from-level-list (level *world*) target) (remove-feature-from-world target) (incf (cur-fp actor) 4) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((rune nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (loop for feature-id in (get-features-* (level *world*) dx dy (z actor)) for feature = (get-feature-by-id feature-id) when (get-feature-type-trait feature +feature-trait-demonic-rune+) do (setf rune feature) (loop-finish)))) (if (and rune (mob-ability-p actor +mob-abil-purge-rune+)) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((rune nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (loop for feature-id in (get-features-* (level *world*) dx dy (z actor)) for feature = (get-feature-by-id feature-id) when (get-feature-type-trait feature +feature-trait-demonic-rune+) do (setf rune feature) (loop-finish)))) (if (and (mob-ability-p actor +mob-abil-purge-rune+) (can-invoke-ability actor actor +mob-abil-purge-rune+) (not nearest-enemy) rune ) rune nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((features (remove-if #'(lambda (a) (if (get-feature-type-trait (get-feature-by-id a) +feature-trait-demonic-rune+) nil t)) (get-features-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (exit-result nil)) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (> (length features) 1)) (progn (let ((feature-line-list nil) (feature-prompt-list) (feature-list (copy-list features))) (setf feature-line-list (loop for feature-id in feature-list for feature = (get-feature-by-id feature-id) collect (format nil "~A" (capitalize-name (name feature))))) ;; populate the ability prompt list (setf feature-prompt-list (loop for feature-id in feature-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Purge [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a demonic rune to purge:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-feature-by-id (nth cur-sel feature-list)) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) (make-output *current-window*) (setf exit-result t)) :line-list feature-line-list :prompt-list feature-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (= (length features) 1)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-feature-by-id (first features)) ability-type-id) t)) (t (progn nil))) ) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-blessing-touch+ :name "Blessing touch" :descr "You are able to bless humans when you touch them." :passive t :cost 0 :spd +normal-ap+ :final t :on-touch t :motion 40 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-BLESS-TARGET: ~A [~A] blesses ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (set-mob-effect target :effect-type-id +mob-effect-blessed+ :actor-id (id actor)) (incf (cur-fp actor)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A blesses ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-blessing-touch+) (mob-ability-p target +mob-abil-can-be-blessed+) (get-faction-relation (faction actor) (faction target)) (not (mob-effect-p target +mob-effect-blessed+))) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-can-be-blessed+ :name "Can be blessed" :descr "You are able to receive blessings from divine beings." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-civilian+ :name "Civilian" :descr "You are a civilian, mainly the suffering side of any conflict." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-unholy+ :name "Unholy" :descr "You burn (dmg: 1-2) when touching a blessed creature." :passive t :cost 0 :spd +normal-ap+ :final t :on-touch t :motion 30 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-CONSUME-BLESSING-ON-TARGET: ~A [~A] is scorched by blessing of ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (rem-mob-effect target +mob-effect-blessed+) (mob-burn-blessing target actor) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-unholy+) (mob-effect-p target +mob-effect-blessed+)) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-angel+ :name "Angel" :descr "You belong to divine beings." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon+ :name "Demon" :descr "You belong to the forces of hell." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-human+ :name "Human" :descr "You belong to mankind." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-see-all+ :name "Omniscience" :descr "You can see everything." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-lifesteal+ :name "Lifesteal" :descr "You heal yourself with the lifeforce of your slain enemies. The more powerful creature you kill - the more health you gain." :passive t :cost 0 :spd 0 :final nil :on-kill t :motion 10 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-LIFESTEAL: ~A [~A] steals life from the dead ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (let ((heal-pwr)) (setf heal-pwr (* 2 (1+ (strength target)))) (when (> (+ (cur-hp actor) heal-pwr) (max-hp actor)) (setf heal-pwr (- (max-hp actor) (cur-hp actor)))) (incf (cur-hp actor) heal-pwr) (unless (zerop heal-pwr) (when (check-mob-visible actor :observer *player* :complete-check t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A heals for ~A with the lifeforce of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) heal-pwr (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type actor target)) t))) (set-ability-type (make-instance 'ability-type :id +mob-abil-call-for-help+ :name "Summon ally" :descr "Invoke hellish powers to summon one ally to your place. Remember that you may call but nobody is obliged to answer." :cost 1 :spd (truncate +normal-ap+ 3) :passive nil :final t :on-touch nil :removes-disguise t :motion 30 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (log:info (format nil "MOB-CALL-FOR-HELP: ~A [~A] calls for help~%" (name actor) (id actor))) (let ((allies-list)) ;; collect all allies that are able to answer the call within the 40 cell radius (setf allies-list (loop for ally-mob-id in (mob-id-list (level *world*)) when (and (not (eq actor (get-mob-by-id ally-mob-id))) (get-faction-relation (faction actor) (faction (get-mob-by-id ally-mob-id))) (mob-ability-p (get-mob-by-id ally-mob-id) +mob-abil-answer-the-call+) (<= (get-distance (x actor) (y actor) (x (get-mob-by-id ally-mob-id)) (y (get-mob-by-id ally-mob-id))) 40) ) collect ally-mob-id)) ;; remove all allies that are visible to you so that only distant ones could answer (setf allies-list (remove-if #'(lambda (e) (member e (visible-mobs actor))) allies-list)) (log:info (format nil "MOB-CALL-FOR-HELP: The following allies might answer the call ~A~%" allies-list)) ;; place the effect of "called for help" on the allies in the final list (loop for ally-mob-id in allies-list do (set-mob-effect (get-mob-by-id ally-mob-id) :effect-type-id +mob-effect-called-for-help+ :actor-id (id actor) :cd 2)) (set-mob-effect actor :effect-type-id +mob-effect-calling-for-help+ :actor-id (id actor) :cd 2) (decf (cur-fp actor) (cost ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone reciting incantations~A. " str))) (when (check-mob-visible actor :observer *player*) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A calls for reinforcements. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-calling-for-help+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; call for reinforcements if there is a threatening enemy in sight and hp < 50% and you are not the last one (if (and nearest-enemy (not (zerop (strength nearest-enemy))) (< (/ (cur-hp actor) (max-hp actor)) 0.5) (mob-ability-p actor +mob-abil-call-for-help+) (can-invoke-ability actor actor +mob-abil-call-for-help+) (> (total-demons (level *world*)) 1)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-answer-the-call+ :name "Answer the call" :descr "Invoke hellish powers to answer the summoning of your allies. If somebody has already answered the call, nothing will happen. If the teleport is successful, the ability will cost 5 time units." :cost 0 :spd 0 :passive nil :final t :on-touch nil :removes-disguise t :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-ANSWER-THE-CALL: ~A [~A] answers the call~%" (name actor) (id actor))) (let ((allies-list)) ;; find all allies that called for help with 40 cell radius (setf allies-list (loop for ally-mob-id in (mob-id-list (level *world*)) when (and (get-faction-relation (faction actor) (faction (get-mob-by-id ally-mob-id))) (mob-effect-p (get-mob-by-id ally-mob-id) +mob-effect-calling-for-help+) (<= (get-distance (x actor) (y actor) (x (get-mob-by-id ally-mob-id)) (y (get-mob-by-id ally-mob-id))) 40) ) collect ally-mob-id)) (if allies-list (progn (let ((called-ally (get-mob-by-id (first allies-list))) (fx nil) (fy nil) (fz nil)) ;; if anyone found, find a free place around the caller (log:info (format nil "MOB-ANSWER-THE-CALL: ~A [~A] finds the caller ~A [~A]~%" (name actor) (id actor) (name called-ally) (id called-ally))) (check-surroundings (x called-ally) (y called-ally) nil #'(lambda (x y) (when (and (not (get-mob-* (level *world*) x y (z called-ally))) (not (get-terrain-type-trait (get-terrain-* (level *world*) x y (z called-ally)) +terrain-trait-blocks-move+))) (setf fx x fy y fz (z called-ally))))) (if (and fx fy fz) ;; free place found (progn (log:info (format nil "MOB-ANSWER-THE-CALL: ~A [~A] finds the place to teleport (~A, ~A)~%" (name actor) (id actor) fx fy)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear crackling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A disappeares in thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; teleport the caster to the caller (set-mob-location actor fx fy fz) (if (get-faction-relation (faction called-ally) (faction *player*)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A answers the call of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name called-ally))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A appears out of thin air. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ;; remove the calling for help status from the called and the caller (rem-mob-effect called-ally +mob-effect-calling-for-help+) (rem-mob-effect actor +mob-effect-called-for-help+) (make-act actor (truncate +normal-ap+ 2)) (incf (stat-answers actor)) (incf (stat-calls called-ally)) ) (progn (log:info (format nil "MOB-ANSWER-THE-CALL: ~A [~A] unable to the place to teleport~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear crackling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A blinks for a second, but remains in place. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; no free place found - just remove the status from the called and the caller (rem-mob-effect called-ally +mob-effect-calling-for-help+) (rem-mob-effect actor +mob-effect-called-for-help+) )) )) (progn ;; if none found, simply remove the "answer the call" status (log:info (format nil "MOB-ANSWER-THE-CALL: ~A [~A] is unable to find the caller ~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear crackling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A blinks for a second, but remains in place. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect actor +mob-effect-called-for-help+) )) )) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-effect-p actor +mob-effect-called-for-help+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; answer the call if there is no enemy in sight (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-answer-the-call+) (can-invoke-ability actor actor +mob-abil-answer-the-call+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-loves-infighting+ :name "Loves infighting" :descr "You do not mind attacking your own kin." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-prayer-bless+ :name "Pray for righteousness" :descr "Pray to reveal unholy creatures (1/3rd chance only) and burn them for 1-2 dmg, as well as to grant divine protection (1/3rd chance only) to all humans & angels. Affected humans in the area will also start to follow you. Divine protection prevents one harmful action from affecting the shielded target." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 20 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-PRAYER-RIGHTEOUSNESS: ~A [~A] prays for righteousness~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A prays for righteousness. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((enemy-list nil) (ally-list nil)) (when (zerop (random 3)) ;; 1/3th chance to do anything ;; collect all unholy enemies in sight (setf enemy-list (loop for enemy-mob-id in (visible-mobs actor) when (and (not (get-faction-relation (faction actor) (faction (get-mob-by-id enemy-mob-id)))) (mob-ability-p (get-mob-by-id enemy-mob-id) +mob-abil-unholy+)) collect enemy-mob-id)) (log:info (format nil "MOB-PRAYER-RIGHTEOUSNESS: ~A [~A] affects the following enemies ~A with the prayer~%" (name actor) (id actor) enemy-list)) ;; reveal all enemies and burn them like they are blessed (loop for enemy-mob-id in enemy-list do (log:info (format nil "MOB-PRAYER-RIGHTEOUSNESS: ~A [~A] affects the enemy ~A~%" (name actor) (id actor) (get-mob-by-id enemy-mob-id))) (when (mob-effect-p (get-mob-by-id enemy-mob-id) +mob-effect-possessed+) (unless (mob-effect-p (get-mob-by-id enemy-mob-id) +mob-effect-reveal-true-form+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (get-qualified-name (get-mob-by-id enemy-mob-id)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (set-mob-effect (get-mob-by-id enemy-mob-id) :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5)) (incf (brightness actor) 50) (mob-burn-blessing actor (get-mob-by-id enemy-mob-id))) ) (when (zerop (random 3)) ;; 1/3th chance to do anything ;; collect all allies in sight (setf ally-list (loop for ally-mob-id in (visible-mobs actor) when (or (mob-ability-p (get-mob-by-id ally-mob-id) +mob-abil-human+) (mob-ability-p (get-mob-by-id ally-mob-id) +mob-abil-angel+)) collect ally-mob-id)) ;; do not forget self (pushnew (id actor) ally-list) (log:info (format nil "MOB-PRAYER-RIGHTEOUSNESS: ~A [~A] affects the following allies ~A with the prayer~%" (name actor) (id actor) ally-list)) ;; grant all allies invulnerability for 99 turns (loop for ally-mob-id in ally-list for mob = (get-mob-by-id ally-mob-id) do (log:info (format nil "MOB-PRAYER-RIGHTEOUSNESS: ~A [~A] affects the ally ~A~%" (name actor) (id actor) mob)) (set-mob-effect mob :effect-type-id +mob-effect-divine-shield+ :actor-id (id actor) :cd 99) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is granted divine shield" (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (and (not (eq mob actor)) (mob-ability-p mob +mob-abil-human+) (not (mob-ability-p mob +mob-abil-independent+)) (or (not (order mob)) (and (order mob) (= (first (order mob)) +mob-order-follow+) (/= (second (order mob)) (id actor)) (zerop (random 2))) (and (order mob) (/= (first (order mob)) +mob-order-follow+)))) (setf (order mob) (list +mob-order-follow+ (id actor))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil " and starts to follow ~A" (visible-name actor)) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil ". ") :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) )) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-prayer-bless+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; if able to pray - do it (if (and (mob-ability-p actor +mob-abil-prayer-bless+) (can-invoke-ability actor actor +mob-abil-prayer-bless+) (or (not (mob-effect-p actor +mob-effect-divine-shield+)) (and (not (zerop (length (visible-mobs actor)))) (zerop (random 4))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-free-call+ :name "Summon ally" :descr "Invoke hellish powers to summon one ally to your place. Remember that you may call but nobody is obliged to answer." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :cd 3 :motion 30 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (log:info (format nil "MOB-FREE-CALL-FOR-HELP: ~A [~A] calls for help~%" (name actor) (id actor))) (let ((allies-list)) ;; collect all allies that are able to answer the call within the 40 cell radius (setf allies-list (loop for ally-mob-id in (mob-id-list (level *world*)) when (and (not (eq actor (get-mob-by-id ally-mob-id))) (get-faction-relation (faction actor) (faction (get-mob-by-id ally-mob-id))) (mob-ability-p (get-mob-by-id ally-mob-id) +mob-abil-answer-the-call+) (<= (get-distance (x actor) (y actor) (x (get-mob-by-id ally-mob-id)) (y (get-mob-by-id ally-mob-id))) 40) ) collect ally-mob-id)) ;; remove all allies that are visible to you so that only distant ones could answer (setf allies-list (remove-if #'(lambda (e) (member e (visible-mobs actor))) allies-list)) (log:info (format nil "MOB-FREE-CALL-FOR-HELP: The following allies might answer the call ~A~%" allies-list)) ;; place the effect of "called for help" on the allies in the final list (loop for ally-mob-id in allies-list do (set-mob-effect (get-mob-by-id ally-mob-id) :effect-type-id +mob-effect-called-for-help+ :actor-id (id actor) :cd 2)) (set-mob-effect actor :effect-type-id +mob-effect-calling-for-help+ :actor-id (id actor) :cd 2) (decf (cur-fp actor) (cost ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone reciting incantations~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A calls for reinforcements. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-calling-for-help+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; for satanists: call for reinforcements whenever there is a threatening enemy in sight and there still demons out there (if (and nearest-enemy (not (zerop (strength nearest-enemy))) (mob-ability-p actor +mob-abil-free-call+) (can-invoke-ability actor actor +mob-abil-free-call+) (> (total-demons (level *world*)) 0)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-prayer-shield+ :name "Pray for protection" :descr "Pray to grant divine protection (1/3rd chance only) to all allies in the area. Divine protection prevents one harmful action from affecting the shielded target." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 20 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-PRAYER-SHIELD: ~A [~A] prays for shielding~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A prays for protection. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((ally-list nil)) (when (zerop (random 3)) ;; 1/3th chance to do anything ;; collect all allies in sight (setf ally-list (loop for ally-mob-id in (visible-mobs actor) when (get-faction-relation (faction actor) (faction (get-mob-by-id ally-mob-id))) collect ally-mob-id)) ;; do not forget self (pushnew (id actor) ally-list) (log:info (format nil "MOB-PRAYER-SHIELD: ~A [~A] affects the following allies ~A with the prayer~%" (name actor) (id actor) ally-list)) ;; grant all allies invulnerability for 99 turns (loop for ally-mob-id in ally-list do (log:info (format nil "MOB-PRAYER-SHIELD: ~A [~A] affects the ally ~A~%" (name actor) (id actor) (get-mob-by-id ally-mob-id))) (set-mob-effect (get-mob-by-id ally-mob-id) :effect-type-id +mob-effect-divine-shield+ :actor-id (id actor) :cd 99) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is granted divine shield. " (capitalize-name (prepend-article +article-the+ (visible-name (get-mob-by-id ally-mob-id))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) )) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-prayer-shield+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; if able to pray - do it (if (and (mob-ability-p actor +mob-abil-prayer-shield+) (can-invoke-ability actor actor +mob-abil-prayer-shield+) (zerop (random 4))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-curse+ :name "Curse" :descr "Curse all visible enemies with diabolical incantations. The cursed individuals will have a 25% chance to miss. You only have 1/2 chance to successfully invoke the curse." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 40 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-CURSE: ~A [~A] incants the curses~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone laughing and cursing~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A laughs and curses maniacally. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (invoke-curse actor) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-curse+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; for satanists: if able to curse - do it (if (and (mob-ability-p actor +mob-abil-curse+) (can-invoke-ability actor actor +mob-abil-curse+) nearest-enemy (zerop (random 3))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-keen-senses+ :name "Keen senses" :descr "When confronted by the supernatural, you can see through its illusions." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-prayer-reveal+ :name "Pray for revelation" :descr "Pray to reveal supernatural beings in the area (1/2nd chance) and prevent them from being disguised for a while." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 20 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-PRAYER-REVEAL: ~A [~A] prays for revealing supernatural beings~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A prays for revelation. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; reveal true form of all mobs in line of sight, 1/3rd chance (when (zerop (random 2)) (loop for mob-id in (visible-mobs actor) for target = (get-mob-by-id mob-id) do (when (mob-effect-p target +mob-effect-divine-concealed+) (rem-mob-effect target +mob-effect-divine-concealed+) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5) (print-visible-message (x target) (y target) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (when (mob-effect-p target +mob-effect-possessed+) (unless (mob-effect-p target +mob-effect-reveal-true-form+) (print-visible-message (x target) (y target) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5)))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-prayer-reveal+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; if able to pray - do it (if (and (mob-ability-p actor +mob-abil-prayer-reveal+) (can-invoke-ability actor actor +mob-abil-prayer-reveal+) (not (zerop (length (visible-mobs actor)))) (zerop (random 4))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-military-follow-me+ :name "Follow me!" :descr "Order nearby subordinates to follow you. Up to five people may obey this order. Troops that are already following others, may be reluctant to follow you." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 20 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (generate-sound actor (x actor) (y actor) (z actor) 10 #'(lambda (str) (format nil "You hear someone shouting orders~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A orders nearby allies to follow him. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; set order to up to six nearby units without orders (loop for i from 0 below (length (visible-mobs actor)) for mob = (get-mob-by-id (nth i (visible-mobs actor))) with follower-num = 0 when (and (= (faction actor) (faction mob)) (not (mob-ability-p mob +mob-abil-independent+)) (or (not (order mob)) (and (order mob) (= (first (order mob)) +mob-order-follow+) (/= (second (order mob)) (id actor)) (zerop (random 2))) (and (order mob) (/= (first (order mob)) +mob-order-follow+)))) do (setf (order mob) (list +mob-order-follow+ (id actor))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A obeys. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (incf follower-num) (when (>= follower-num 5) (loop-finish))) (log:info (format nil "MOB-ORDER-FOLLOW-ME: ~A [~A] orders to follow him. Followers ~A~%" (name actor) (id actor) (get-followers-list actor))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-military-follow-me+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; if able to order - do it (if (and (mob-ability-p actor +mob-abil-military-follow-me+) (can-invoke-ability actor actor +mob-abil-military-follow-me+) (zerop (count-follower-list actor)) (not (zerop (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (and (= (faction actor) (faction mob)) (not (mob-ability-p mob +mob-abil-independent+))) count mob-id))) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-blindness+ :name "Blindness" :descr "A flash of light that blinds nearby enemies for 2 turns." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A channels the heavenly light. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (log:info (format nil "MOB-BLIND: ~A [~A] casts blindness.~%" (name actor) (id actor))) ;; blind nearby non-angel mobs (loop for i from 0 below (length (proper-visible-mobs actor)) for mob = (get-mob-by-id (nth i (proper-visible-mobs actor))) when (not (mob-ability-p mob +mob-abil-angel+)) do (set-mob-effect mob :effect-type-id +mob-effect-blind+ :actor-id (id actor) :cd 2) (if (eq *player* mob) (update-visible-area (level *world*) (x *player*) (y *player*) (z *player*)) (setf (visible-mobs mob) nil)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A is blind. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-blindness+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; cast blindness when your power is less than the power of enemies around you ;; or you have <= than 25% of max hp (if (and (mob-ability-p actor +mob-abil-blindness+) (can-invoke-ability actor actor +mob-abil-blindness+) (not (zerop (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (not (mob-effect-p mob +mob-effect-blind+)) count mob-id))) (or (and (<= (cur-hp actor) (truncate (max-hp actor) 4)) nearest-enemy ) (< (strength actor) (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (not (get-faction-relation (faction actor) (get-visible-faction mob))) sum (strength mob))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-instill-fear+ :name "Instill fear" :descr "Fear visible enemies around your for 3 turns. More powerfull characters may resist fear." :cost 1 :spd (truncate +normal-ap+ 1.3) :passive nil :final t :on-touch nil :motion 30 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "You hear a roar~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A roars to fear its enemies. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (invoke-fear actor (mob-ability-value actor +mob-abil-instill-fear+)) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-instill-fear+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; cast fear when you are revealed (or they won't understand that they need to fear you) and ;; your power is less than the power of enemies around you ;; or you have <= than 25% of max hp (if (and (mob-ability-p actor +mob-abil-instill-fear+) (can-invoke-ability actor actor +mob-abil-instill-fear+) (= (face-mob-type-id actor) (mob-type actor)) (not (zerop (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (and (not (get-faction-relation (faction actor) (faction mob))) (not (mob-effect-p mob +mob-effect-fear+))) count mob-id))) (or (<= (cur-hp actor) (truncate (max-hp actor) 4)) (< (strength actor) (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (not (get-faction-relation (faction actor) (faction mob))) sum (strength mob))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-charge+ :name "Charge" :descr "Move up to 3 tiles to the specified place. Anybody on your way will be pushed back (if possible) and attacked." :cd 4 :cost 0 :spd (truncate (* +normal-ap+ 1.5)) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; here the target is not a mob, but a (cons x y) (log:info (format nil "MOB-CHARGE: ~A [~A] charges to ~A.~%" (name actor) (id actor) target)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A charges. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((path-line nil) (cur-ap) (game-time) (dx1) (dy1) (target1 (cons (car target) (cdr target)))) (setf dx1 (- (car target) (x actor))) (setf dy1 (- (cdr target) (y actor))) (when (or (< (abs dx1) 3) (< (abs dy1) 3)) (setf (car target1) (+ (car target1) (* 3 dx1))) (setf (cdr target1) (+ (cdr target1) (* 3 dy1)))) (line-of-sight (x actor) (y actor) (z actor) (car target1) (cdr target1) (z actor) #'(lambda (dx dy dz prev-cell) (declare (ignore dz prev-cell)) (let ((exit-result t)) (block nil (push (cons dx dy) path-line) exit-result)))) (setf path-line (nreverse path-line)) (pop path-line) (setf game-time (world-game-time *world*)) (setf cur-ap (cur-ap actor)) (loop for (nx . ny) in path-line for dx = (- nx (x actor)) for dy = (- ny (y actor)) with charge-distance = 3 with charge-result = nil while (not (zerop charge-distance)) do (decf charge-distance) (setf charge-result (move-mob actor (x-y-into-dir dx dy) :push t)) (when (or (eq charge-result nil) (and (typep charge-result 'list) (eq (first charge-result) :obstacles))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits an obstacle. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (unless (eq charge-result t) (loop-finish)) ) (setf (cur-ap actor) cur-ap) (setf (world-game-time *world*) game-time) )) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-charge+) (not (mob-ability-p actor +mob-abil-immobile+)) (not (riding-mob-id actor))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if there is unobstructed direct path towards the enemy - charge (block nil (unless nearest-enemy (return nil)) (let ((blocked nil)) (line-of-sight (x actor) (y actor) (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy)) (let ((exit-result t)) (block nil (unless (check-LOS-propagate dx dy dz prev-cell :check-move t) (setf exit-result 'exit) (setf blocked t) (return)) ) exit-result))) (if (and (mob-ability-p actor +mob-abil-charge+) (can-invoke-ability actor actor +mob-abil-charge+) (not blocked)) t nil)))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor (cons (x nearest-enemy) (y nearest-enemy)) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (eq *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (progn nil) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (cons (view-x *player*) (view-y *player*)) ability-type-id) t)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-momentum+ :name "Momentum" :descr "You can move quicker than most but it is difficult for you to change direction." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-animal+ :name "Animal" :descr "You are an animal." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-horseback-riding+ :name "Horseback riding" :descr "You can ride horses. To mount a horse, you must stand next to it." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-nearest-ally-next :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-HORSEBACK-RIDING: ~A [~A] mounts ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (setf (mounted-by-mob-id target) (id actor)) (setf (riding-mob-id actor) (id target)) (set-mob-location actor (x target) (y target) (z target)) (when (or (check-mob-visible actor :observer *player*) (check-mob-visible target :observer *player*)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A mounts ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (adjust-dodge actor) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (get-faction-relation (faction actor) (faction mob)) (mob-ability-p mob +mob-abil-horse-can-be-ridden+) (not (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (mob-ability-p actor +mob-abil-horseback-riding+) (not (riding-mob-id actor))) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy nearest-ally)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (get-faction-relation (faction actor) (faction mob)) (mob-ability-p mob +mob-abil-horse-can-be-ridden+) (not (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (can-invoke-ability actor actor (id ability-type))) mount nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (and (not (eq *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (< (get-distance (x *player*) (y *player*) (view-x *player*) (view-y *player*)) 2) (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) (get-faction-relation (faction *player*) (faction (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (mob-ability-p (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) +mob-abil-horse-can-be-ridden+) (not (mounted-by-mob-id (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (find (id (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-horse-can-be-ridden+ :name "Can be ridden" :descr "If somebody has the 'Horseback riding' ability, he/she can mount you." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-dismount+ :name "Dismount" :descr "Get off your mount, if you are riding one." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; here the target is not a mob, but a (cons x y) (let ((mount (get-mob-by-id (riding-mob-id actor)))) (log:info (format nil "MOB-DISMOUNT: ~A [~A] dismounts ~A [~A].~%" (name actor) (id actor) (name mount) (id mount))) (setf (mounted-by-mob-id mount) nil) (setf (riding-mob-id actor) nil) (set-mob-location actor (car target) (cdr target) (z actor)) (set-mob-location mount (x mount) (y mount) (z mount)) (when (or (check-mob-visible actor :observer *player*) (check-mob-visible mount :observer *player*)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A dismounts ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name mount))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-dismount+) (riding-mob-id actor)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore actor nearest-enemy ability-type nearest-ally)) nil ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy check-result)) (mob-invoke-ability actor nearest-ally (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((cell-list nil) (half-size (truncate (1- (map-size (get-mob-by-id (riding-mob-id *player*)))) 2))) ;; collect all cells around the mount (loop for off of-type fixnum from (1- (- half-size)) to (1+ (+ half-size)) for x of-type fixnum = (+ (x *player*) off) for y of-type fixnum = (+ (y *player*) off) for y-up of-type fixnum = (- (y *player*) half-size 1) for y-down of-type fixnum = (+ (y *player*) half-size 1) for x-up of-type fixnum = (- (x *player*) half-size 1) for x-down of-type fixnum = (+ (x *player*) half-size 1) do (push (cons x y-up) cell-list) (push (cons x y-down) cell-list) (push (cons x-up y) cell-list) (push (cons x-down y) cell-list)) ;; remove all duplicate cells (setf cell-list (remove-duplicates cell-list :test #'(lambda (a b) (let ((x1 (car a)) (x2 (car b)) (y1 (cdr a)) (y2 (cdr b))) (declare (type fixnum x1 x2 y1 y2)) (if (and (= x1 x2) (= y1 y2)) t nil))))) (if (and (eq (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (z *player*)) nil) (eq (check-move-on-level *player* (view-x *player*) (view-y *player*) (z *player*)) t) (find (cons (view-x *player*) (view-y *player*)) cell-list :test #'(lambda (a b) (let ((x1 (car a)) (x2 (car b)) (y1 (cdr a)) (y2 (cdr b))) (declare (type fixnum x1 x2 y1 y2)) (if (and (= x1 x2) (= y1 y2)) t nil))))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (cons (view-x *player*) (view-y *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-dominate-fiend+ :name "Dominate fiend" :descr "You can mount a fiend, if you stand next to it. Riding a fiend will reveal your true form." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :removes-disguise t :motion 50 :start-map-select-func #'player-start-map-select-nearest-hostile-next :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-DOMINATE-FIEND: ~A [~A] mounts ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) (when (or (check-mob-visible actor :observer *player*) (check-mob-visible target :observer *player*)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A mounts ~A" (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; reveal the true form of those who ride fiends (when (and (slave-mob-id actor) (not (mob-effect-p actor +mob-effect-reveal-true-form+))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil " and reveals itself as ~A" (prepend-article +article-the+ (get-qualified-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil ". ") :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (setf (mounted-by-mob-id target) (id actor)) (setf (riding-mob-id actor) (id target)) (set-mob-location actor (x target) (y target) (z target)) (adjust-dodge actor) (set-mob-effect actor :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 4) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (mob-ability-p mob +mob-abil-fiend-can-be-ridden+) (not (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (mob-ability-p actor +mob-abil-dominate-fiend+) (not (riding-mob-id actor))) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy nearest-ally)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (mob-ability-p mob +mob-abil-fiend-can-be-ridden+) (not (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (can-invoke-ability actor mount (id ability-type))) mount nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (and (not (eq *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (< (get-distance (x *player*) (y *player*) (view-x *player*) (view-y *player*)) 2) (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) (mob-ability-p (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) +mob-abil-fiend-can-be-ridden+) (not (mounted-by-mob-id (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (find (id (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-fiend-can-be-ridden+ :name "Can be ridden" :descr "If somebody has the 'Dominate fiend' ability, he/she can mount you." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-starts-with-horse+ :name "Starts with a horse" :descr "You start your mission riding a horse." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-independent+ :name "Independent" :descr "You do not take orders from anyone." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-eagle-eye+ :name "Eagle eye" :descr "You can inspect an enemy unit to reveal its true form." :cd 4 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-ally :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-EAGLE-EYE: ~A [~A] uses eagle eye to reveal ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (if (or (mob-effect-p target +mob-effect-divine-concealed+) (and (mob-effect-p target +mob-effect-possessed+) (not (mob-effect-p target +mob-effect-reveal-true-form+)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A reveals the true form of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect target +mob-effect-divine-concealed+) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "It is ~A. " (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to reveal the true form of ~A. But ~A does not conceal anything. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-eagle-eye+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy)) ;; a little bit of cheating here (if (and (can-invoke-ability actor actor (id ability-type)) nearest-ally (or (mob-effect-p nearest-ally +mob-effect-divine-concealed+) (and (mob-effect-p nearest-ally +mob-effect-possessed+) (not (mob-effect-p nearest-ally +mob-effect-reveal-true-form+)))) (zerop (random 4))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy check-result)) (mob-invoke-ability actor nearest-ally (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (not (mob-effect-p mob +mob-effect-reveal-true-form+)) (not (and (mob-ability-p mob +mob-abil-demon+) (not (mob-effect-p mob +mob-effect-possessed+)))) (not (and (mob-ability-p mob +mob-abil-angel+) (not (mob-effect-p mob +mob-effect-divine-concealed+)))) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-facing+ :name "Facing" :descr "You can not change the direction of your movement easily. You must first face the place where you go." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-immovable+ :name "Immovable" :descr "You won't let anybody push you around." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mind-burn+ :name "Mind burn" :descr "Burn the mind of an enemy in your line of sight for 2-4 dmg." :cd 4 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-MIND-BURN: ~A [~A] uses mind burn on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes mind burn on ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (inflict-damage target :min-dmg 2 :max-dmg 4 :dmg-type +weapon-dmg-mind+ :att-spd nil :weapon-aux () :acc 100 :add-blood nil :no-dodge t :actor actor :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A has its mind burned for ~A dmg. " (capitalize-name (prepend-article +article-the+ (name target))) cur-dmg))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-mind-burn+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor actor (id ability-type)) nearest-enemy) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-gargantaur-teleport+ :name "Teleport self" :descr "Teleport yourself somewhere else." :cd 20 :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (invoke-teleport-self actor 80 (z actor)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-gargantaur-teleport+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; teleport if there is no enemy in sight or if HP < 50% (if (and (mob-ability-p actor +mob-abil-gargantaur-teleport+) (can-invoke-ability actor actor +mob-abil-gargantaur-teleport+) (or (not nearest-enemy) (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.5)))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-dominate-gargantaur+ :name "Dominate Gargantaur" :descr "You can mount a Gargantaur, if you stand next to it, but at a cost of inflicting yourself the amount of damage equal to the half of your maximum HP. Riding one will reveal your true form." :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-nearest-hostile-next :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-DOMINATE-GARGANTAUR: ~A [~A] mounts ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (let ((cur-dmg (truncate (max-hp actor) 2))) (decf (cur-hp actor) cur-dmg) (if (<= (cur-hp actor) 0) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A cringes with pain, taking ~A dmg, while trying to mount ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) cur-dmg (prepend-article +article-the+ (visible-name target))) :color (if (eq *player* actor) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (eq actor *player*) (setf (killed-by *player*) "trying to dominate the gargantaur")) (make-dead actor :splatter t :msg t :msg-newline nil :killer nil :corpse t :aux-params ())) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A cringes with pain, taking ~A dmg, and mounts ~A" (capitalize-name (prepend-article +article-the+ (visible-name actor))) cur-dmg (prepend-article +article-the+ (visible-name target))) :color (if (eq *player* actor) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; reveal the true form of those who ride fiends (when (mob-effect-p actor +mob-effect-divine-concealed+) (rem-mob-effect actor +mob-effect-divine-concealed+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil " to reveal itself as ~A" (prepend-article +article-the+ (get-qualified-name actor))) :color (if (eq *player* actor) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil ". ") :color (if (eq *player* actor) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; show message for LOW HP (when (and (eq *player* actor) (< (/ (cur-hp actor) (max-hp actor)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)) (setf (mounted-by-mob-id target) (id actor)) (setf (riding-mob-id actor) (id target)) (set-mob-location actor (x target) (y target) (z target)) (adjust-dodge actor) (set-mob-effect actor :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 4) )) )) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (= (mob-type mob) +mob-type-gargantaur+) (null (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (mob-ability-p actor +mob-abil-dominate-gargantaur+) (not (riding-mob-id actor))) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy nearest-ally)) (let ((mount nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z actor)))) (when (and mob (= (mob-type mob) +mob-type-gargantaur+) (null (mounted-by-mob-id mob))) (setf mount mob))))) (if (and mount (> (/ (cur-hp actor) (max-hp actor)) 0.5) (can-invoke-ability actor mount (id ability-type))) mount nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mount-list nil)) (check-surroundings (x *player*) (y *player*) nil #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z *player*)))) (when (and mob (= (mob-type mob) +mob-type-gargantaur+) (null (mounted-by-mob-id mob))) (pushnew mob mount-list))))) (if (find (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) mount-list) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) )))) (set-ability-type (make-instance 'ability-type :id +mob-abil-gargantaurs-mind-burn+ :name "Gargantaur's mind burn" :descr "Use your Gargantuar to burn the mind of an enemy in your line of sight for 2-4 dmg. You must be riding a Gargantaur to invoke this ability." :cd 4 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-GARGANTAURS-MIND-BURN: ~A [~A] uses mind burn on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A uses its Gargantaur to burn the mind of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (inflict-damage target :min-dmg 2 :max-dmg 4 :dmg-type +weapon-dmg-mind+ :att-spd nil :weapon-aux () :acc 100 :add-blood nil :no-dodge t :actor actor :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A has its mind burned for ~A dmg. " (capitalize-name (prepend-article +article-the+ (name target))) cur-dmg))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-gargantaurs-mind-burn+) (riding-mob-id actor) (= (mob-type (get-mob-by-id (riding-mob-id actor))) +mob-type-gargantaur+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor actor (id ability-type)) nearest-enemy) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-death-from-above+ :name "Death from Above" :descr "Jump from above on your prey and land a devastating attack for 5-8 iron dmg." :cd 1 :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-death-from-above :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-DEATH-FROM-ABOVE: ~A [~A] uses death from above on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A strikes from above. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((tx (x target)) (ty (y target)) (tz (1+ (z target)))) (block surround (check-surroundings (x target) (y target) nil #'(lambda (dx dy) (when (eq (check-move-on-level actor dx dy (z target)) t) (setf tx dx ty dy tz (z target)) (when (zerop (random 4)) (return-from surround)))))) (set-mob-location actor tx ty tz)) ;; set motion (incf-mob-motion target *mob-motion-melee*) ;; generate sound (generate-sound target (x target) (y target) (z target) *mob-sound-melee* #'(lambda (str) (format nil "You hear sounds of fighting~A. " str))) (inflict-damage target :min-dmg 5 :max-dmg 8 :dmg-type +weapon-dmg-iron+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :actor actor) (when (check-dead target) (when (mob-effect-p target +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ())) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-death-from-above+) ) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor actor (id ability-type)) nearest-enemy ;; check if you are above (> (z actor) (z nearest-enemy)) ;; check if you are not too far (< (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 3) ;; check if there is unobstructed line of sight (funcall #'(lambda () (let ((result t) (x (x actor)) (y (y actor))) (when (and (<= (abs (- (x actor) (x nearest-enemy))) 1) (<= (abs (- (y actor) (y nearest-enemy))) 1)) (setf x (x nearest-enemy) y (y nearest-enemy))) (line-of-sight x y (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t)) (block nil (unless (check-LOS-propagate dx dy dz prev-cell :check-move t) (setf exit-result 'exit) (setf result nil) (return)) ) exit-result))) result))) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*)) (> (z *player*) (z mob)) (< (get-distance (x *player*) (y *player*) (x mob) (y mob)) 3) (funcall #'(lambda () (let ((result t) (x (x *player*)) (y (y *player*))) (when (and (<= (abs (- (x *player*) (x mob))) 1) (<= (abs (- (y *player*) (y mob))) 1)) (setf x (x mob) y (y mob))) (line-of-sight x y (z *player*) (x mob) (y mob) (z mob) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let* ((exit-result t)) (block nil (unless (check-LOS-propagate dx dy dz prev-cell :check-move t) (setf exit-result 'exit) (setf result nil) (return)) ) exit-result))) result))) ) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-climbing+ :name "Climbing" :descr "Toggle the climbing mode. While in the climbing mode you are able to scale walls up and down and will not fall as long as you remain next to a solid wall or a floor. You can toggle the climbing mode at any time. However, you are unable to climb while sprinting." :cost 0 :spd 0 :passive nil :final t :on-touch nil :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (if (mob-effect-p actor +mob-effect-climbing-mode+) (progn (when (eq actor *player*) (add-message "You toggle off the climbing mode. ")) (rem-mob-effect actor +mob-effect-climbing-mode+)) (progn (when (eq actor *player*) (add-message "You toggle on the climbing mode. ")) (set-mob-effect actor :effect-type-id +mob-effect-climbing-mode+ :actor-id (id actor) :cd t)))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-climbing+) (not (mob-effect-p actor +mob-effect-sprint+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-climbing+) (can-invoke-ability actor actor +mob-abil-climbing+) (not (mob-effect-p actor +mob-effect-climbing-mode+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-no-breathe+ :name "Does not breathe" :descr "Your do not require oxygen to sustain your life." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-open-close-door+ :name "Open/close door" :descr "Open or close door (depending on the current status of the door in question). You can also open a closed door by walking into it." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :start-map-select-func #'player-start-map-select-door :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the tile to be toggled (multiple-value-bind (x y z) (values-list target) (when (get-terrain-on-use (get-terrain-* (level *world*) x y z)) (funcall (get-terrain-on-use (get-terrain-* (level *world*) x y z)) actor x y z)) (if (= (get-terrain-* (level *world*) x y z) +terrain-door-open+) (print-visible-message x y z (level *world*) (format nil "~A opens the door. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message x y z (level *world*) (format nil "~A closes the door. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-open-close-door+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-open-close-door+) (can-invoke-ability actor actor +mob-abil-open-close-door+) (path actor) (= (get-terrain-* (level *world*) (first (first (path actor))) (second (first (path actor))) (third (first (path actor)))) +terrain-door-closed+) (null (get-mob-* (level *world*) (first (first (path actor))) (second (first (path actor))) (third (first (path actor)))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor (first (path actor)) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (= terrain +terrain-door-closed+) (= terrain +terrain-door-open+))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-toggle-light+ :name "Toggle light" :descr "Switch a light on or off (depending on the current status of the light source in question). You can also toggle a light by walking into it." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-light :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the tile to be toggled (multiple-value-bind (x y z) (values-list target) (when (get-terrain-on-use (get-terrain-* (level *world*) x y z)) (funcall (get-terrain-on-use (get-terrain-* (level *world*) x y z)) actor x y z)) (if (or (null (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-light-source+)) (eq 0 (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-light-source+))) (print-visible-message x y z (level *world*) (format nil "~A switches off the light. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message x y z (level *world*) (format nil "~A switches on the light. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-toggle-light+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if you can toggle lights and you happen to be nearby, and you do not radiate light yourself - switch it off ;; if you can toggle lights and you happen to be nearby, and you do radiate light yourself - switch it on (let ((light-source nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-can-switch-light+) (or (and (<= (cur-light actor) 0) (get-terrain-type-trait terrain +terrain-trait-light-source+) (not (zerop (get-terrain-type-trait terrain +terrain-trait-light-source+)))) (and (> (cur-light actor) 0) (get-terrain-type-trait terrain +terrain-trait-light-source+) (zerop (get-terrain-type-trait terrain +terrain-trait-light-source+))))) (setf light-source (list dx dy (z actor))))))) (if (and (mob-ability-p actor +mob-abil-toggle-light+) (can-invoke-ability actor actor +mob-abil-toggle-light+) light-source (or (not nearest-enemy) (and nearest-enemy (>= (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 4)))) light-source nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type)) ) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (get-terrain-type-trait terrain +terrain-trait-light-source+) (get-terrain-type-trait terrain +terrain-trait-can-switch-light+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-open-close-window+ :name "Open/close window" :descr "Open or close window (depending on the current status of the door in question). You can also open a closed window by walking into it." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :start-map-select-func #'player-start-map-select-window :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the tile to be toggled (multiple-value-bind (x y z) (values-list target) (when (get-terrain-on-use (get-terrain-* (level *world*) x y z)) (funcall (get-terrain-on-use (get-terrain-* (level *world*) x y z)) actor x y z)) (if (= (get-terrain-* (level *world*) x y z) +terrain-wall-window-opened+) (print-visible-message x y z (level *world*) (format nil "~A opens the window. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message x y z (level *world*) (format nil "~A closes the window. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-open-close-window+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-open-close-window+) (can-invoke-ability actor actor +mob-abil-open-close-window+) (path actor) (= (get-terrain-* (level *world*) (first (first (path actor))) (second (first (path actor))) (third (first (path actor)))) +terrain-wall-window+) (null (get-mob-* (level *world*) (first (first (path actor))) (second (first (path actor))) (third (first (path actor)))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor (first (path actor)) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (= terrain +terrain-wall-window+) (= terrain +terrain-wall-window-opened+))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-can-possess-toggle+ :name "Toggle possession mode" :descr "Toggle your ability to possess other creatures. If switched off, you will attack a possessable target instead of possessing it. You can toggle the possession mode at any time." :cost 0 :spd 0 :passive nil :final t :on-touch nil :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (if (mob-effect-p actor +mob-effect-ready-to-possess+) (progn (when (eq actor *player*) (add-message "You toggle off the possession mode. ")) (rem-mob-effect actor +mob-effect-ready-to-possess+)) (progn (when (eq actor *player*) (add-message "You toggle on the possession mode. ")) (set-mob-effect actor :effect-type-id +mob-effect-ready-to-possess+ :actor-id (id actor) :cd t)))) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-can-possess-toggle+) (null (slave-mob-id actor)) (null (riding-mob-id actor))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-can-possess-toggle+) (can-invoke-ability actor actor +mob-abil-can-possess-toggle+) (not (mob-effect-p actor +mob-effect-ready-to-possess+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-sacrifice-host+ :name "Sacrifice host" :descr "Sacrifice the human you are currently possessing to gain health and power. However, killing the human host will (obviously) show your true face." :cost 0 :spd 5 :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((target (get-mob-by-id (slave-mob-id actor)))) ;; target here is the slave mob (setf (x target) (x actor) (y target) (y actor) (z target) (z actor)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A destroys its host. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf (cur-hp target) 0) (make-dead target :splatter t :msg nil :killer actor :corpse nil :aux-params ()) (loop repeat 8 for (dx dy) = (multiple-value-list (x-y-dir (1+ (random 9)))) do (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-fresh+ :x (+ dx (x actor)) :y (+ dy (y actor)) :z (z actor)))) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-stain+ :x (x actor) :y (y actor) :z (z actor))) (rem-mob-effect actor +mob-effect-possessed+) (setf (face-mob-type-id actor) (mob-type actor)) (setf (master-mob-id target) nil) (setf (slave-mob-id actor) nil) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear a scream and ripping of flesh~A." str))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-sacrifice-host+) (slave-mob-id actor)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-sacrifice-host+) (can-invoke-ability actor actor +mob-abil-sacrifice-host+) (< (/ (cur-hp actor) (max-hp actor)) 0.25)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor (get-mob-by-id (slave-mob-id actor)) (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-reanimate-corpse+ :name "Reanimate body" :descr "Invite an outworldly demon to enter a dead body (or a severed body part) and reanimate it. The strength of the reanimated corpse depends on its completeness - missing parts will reduce it." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :cd 4 :motion 60 :start-map-select-func #'player-start-map-select-corpse :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-REANIMATE-BODY: ~A [~A] reanimates ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) ;; target here is the item to be reanimated (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A raises his hands and intones an incantation. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear somebody chanting~A. " str))) (invoke-reanimate-body target) (incf (stat-raised-dead actor)) (when (eq actor *player*) (incf (cur-score *player*) 10)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-reanimate-corpse+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (let ((item-id (funcall #'(lambda () (let ((visible-items (copy-list (visible-items actor)))) (setf visible-items (remove-if #'(lambda (a) (if (item-ability-p (get-item-by-id a) +item-abil-corpse+) nil t)) visible-items)) (setf visible-items (remove-if #'(lambda (a) (if (get-mob-* (level *world*) (x a) (y a) (z a)) t nil)) visible-items :key #'get-item-by-id)) (setf visible-items (stable-sort visible-items #'(lambda (a b) (if (> (get-distance-3d (x actor) (y actor) (z actor) (x a) (y a) (z a)) (get-distance-3d (x actor) (y actor) (z actor) (x b) (y b) (z b))) t nil)) :key #'get-item-by-id)) (if visible-items (first visible-items) nil)))))) (if (and (mob-ability-p actor +mob-abil-reanimate-corpse+) (can-invoke-ability actor actor +mob-abil-reanimate-corpse+) item-id) item-id nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor (get-item-by-id check-result) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((items (get-items-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (item-ability-p (get-item-by-id a) +item-abil-corpse+) nil t)) items)) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (> (length items) 1)) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A~A" (capitalize-name (name item)) (if (> (qty item) 1) (format nil " x~A" (qty item)) "")))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Reanimate [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body part to reanimate:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) ;(set-idle-calcing win) (make-output *current-window*) ;(show-time-label (idle-calcing win) (+ 20 (* *glyph-w* *max-x-view*)) (+ 10 237) t) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (length items) 1) (item-ability-p (get-item-by-id (first items)) +item-abil-corpse+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) (t (progn nil)))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-undead+ :name "Undead" :descr "Your existance defies all logic - you are dead, yet you live. However, fire may burn your body to ashes." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-shared-minds+ :name "Shared minds" :descr "You share a single mind with your kind - you see what they see, they see what you see." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-empower-undead+ :name "Empower undead" :descr "Link the demon inside a dead body with your own life force, enhancing its strength and making it follow you. You can only have one undead unit empowered at the same time." :cd 5 :cost 0 :spd 5 :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-empower-undead :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A raises his hands and intones an incantation. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear somebody chanting~A. " str))) ;; if the actor has already empowered a mob, remove the empower effect from it (when (mob-effect-p actor +mob-effect-necrolink+) (let ((effect (get-effect-by-id (mob-effect-p actor +mob-effect-necrolink+)))) (rem-mob-effect (get-mob-by-id (param1 effect)) +mob-effect-empowered-undead+))) ;; target here is an undead mob (set-mob-effect target :effect-type-id +mob-effect-empowered-undead+ :actor-id (id actor) :cd t :param1 (id actor)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-empower-undead+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-empower-undead+) (can-invoke-ability actor actor +mob-abil-empower-undead+) (not (mob-effect-p actor +mob-effect-necrolink+)) nearest-ally (mob-ability-p nearest-ally +mob-abil-undead+) (not (mob-ability-p nearest-ally +mob-abil-ghost-possess+)) (not (mob-effect-p nearest-ally +mob-effect-empowered-undead+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy check-result)) (mob-invoke-ability actor nearest-ally (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((target (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) target (get-faction-relation (faction *player*) (faction target)) (mob-ability-p target +mob-abil-undead+) (not (mob-effect-p target +mob-effect-empowered-undead+)) (find (id target) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* target ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-ignite-the-fire+ :name "Ignite the fire" :descr "Set flammable furniture or grass on fire. Fire may damage those standing in it and produces smoke." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the tile to be ignited (multiple-value-bind (x y z) (values-list target) (print-visible-message x y z (level *world*) (format nil "~A sets the ~A on fire. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-terrain-name (get-terrain-* (level *world*) x y z))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (ignite-tile (level *world*) x y z (x actor) (y actor) (z actor)) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-ignite-the-fire+) (get-melee-weapon-aux-param actor :is-fire) (not (mob-effect-p actor +mob-effect-divine-concealed+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((flammable-tile nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-flammable+) nearest-enemy (= dx (x nearest-enemy)) (= dy (y nearest-enemy)) (= (z actor) (z nearest-enemy)) ) (setf flammable-tile (list dx dy (z actor))))))) (if (and (mob-ability-p actor +mob-abil-ignite-the-fire+) (can-invoke-ability actor actor +mob-abil-ignite-the-fire+) flammable-tile (< (/ (cur-hp actor) (max-hp actor)) 0.6)) flammable-tile nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (get-terrain-type-trait terrain +terrain-trait-flammable+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-avatar-of-brilliance+ :name "Avatar of Brilliance" :descr "Transform yourself into an Avatar of Brilliance for 6 turns, significantly boosting your combat prowess." :cost 4 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-avatar-of-brilliance+ :actor-id (id actor) :cd 6) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-avatar-of-brilliance+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-avatar-of-brilliance+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if able to heal and less than 50% hp - heal (if (and (or (and nearest-enemy (> (strength nearest-enemy) (strength actor))) (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.3))) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-avatar-of-brilliance+) (can-invoke-ability actor actor +mob-abil-avatar-of-brilliance+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-gravity-chains+ :name "Gravity chains" :descr "Make your chains grab a target and inflict 2-4 vorpal dmg. If the target is flying or climbing, it is forced to the ground and will not be able to use respective abilities for 3 turns. Divine protection will nullify the damage but not the secondary effects." :cd 4 :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-GRAVITY-CHAINS: ~A [~A] uses gravity chains on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes gravity chains on ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x target) (y target) (z target) 80 #'(lambda (str) (format nil "You hear metal clanking~A. " str))) (set-mob-effect target :effect-type-id +mob-effect-gravity-pull+ :actor-id (id actor) :cd 3) (inflict-damage target :min-dmg 2 :max-dmg 4 :dmg-type +weapon-dmg-vorpal+ :att-spd nil :weapon-aux () :acc 100 :add-blood nil :no-dodge t :actor actor :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A dmg. " (capitalize-name (prepend-article +article-the+ (name target))) cur-dmg))) (rem-mob-effect target +mob-effect-climbing-mode+) (rem-mob-effect target +mob-effect-flying+) (when (apply-gravity target) (set-mob-location target (x target) (y target) (z target))) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-gravity-chains+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (mob-ability-p actor +mob-abil-gravity-chains+) (can-invoke-ability actor actor +mob-abil-gravity-chains+) nearest-enemy (not (mob-effect-p nearest-enemy +mob-effect-gravity-pull+)) (or (and (= (z actor) (z nearest-enemy)) (> (get-distance-3d (x actor) (y actor) (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) 1.5)) (and (/= (z actor) (z nearest-enemy)) (not (and (= (x actor) (x nearest-enemy)) (= (y actor) (y nearest-enemy))))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((target (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) target (not (eq *player* target)) (find (id target) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* target ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-flying+ :name "Can fly" :descr "You can fly permanently." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-no-corpse+ :name "No corpse" :descr "Your body does not leave a corpse when you die." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-smite+ :name "Smite" :descr "Pray to cast down celestial retribution onto an unholy enemy inflicting 1-2 dmg for each visible human character around." :cd 5 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-hostile-unholy :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-SMITE: ~A [~A] uses smite on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (if (mob-ability-p target +mob-abil-unholy+) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A smites ~A" (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (mob-effect-p target +mob-effect-possessed+) (unless (mob-effect-p target +mob-effect-reveal-true-form+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil " and reveals it to be ~A" (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5) ) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil ". ") :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop for mob-id in (append (list (id actor)) (visible-mobs actor)) for mob = (get-mob-by-id mob-id) with cur-dmg = 0 when (and (not (check-dead mob)) (mob-ability-p mob +mob-abil-human+)) do (incf cur-dmg (1+ (random 2))) finally (when (not (zerop cur-dmg)) (let ((dir (1+ (random 9)))) (multiple-value-bind (dx dy) (x-y-dir dir) (when (> 50 (random 100)) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-blood-fresh+ :x (+ (x target) dx) :y (+ (y target) dy) :z (z target)))))) (decf (cur-hp target) cur-dmg) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is hit for ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name target))) cur-dmg) :color (if (eq *player* target) (sdl:color :r 255 :g 140 :b 0) sdl:*yellow*) :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; show message for LOW HP (when (and (eq *player* target) (< (/ (cur-hp target) (max-hp target)) 0.3)) (add-message "LOW HP!!! " sdl:*red*)) (when (check-dead target) (when (mob-effect-p target +mob-effect-possessed+) (mob-depossess-target target)) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params (list :is-fire))) (generate-sound target (x target) (y target) (z target) 80 #'(lambda (str) (format nil "You hear gasps~A. " str))))) ) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A prays, but nothing happens. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-smite+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) ;; a little bit of cheating here (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (or (and (mob-effect-p nearest-enemy +mob-effect-possessed+) (mob-effect-p nearest-enemy +mob-effect-reveal-true-form+) (mob-ability-p nearest-enemy +mob-abil-unholy+)) (and (not (mob-effect-p nearest-enemy +mob-effect-possessed+)) (mob-ability-p nearest-enemy +mob-abil-unholy+)))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-slow+ :name "Slow" :descr "Pray to slow down one enemy causing it to take 50% more time when attempting any action." :cd 5 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-SLOW: ~A [~A] uses slow on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A slows ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-slow+ :actor-id (id actor) :cd 4) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-slow+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) ;; a little bit of cheating here (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (not (mob-effect-p nearest-enemy +mob-effect-slow+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-prayer-wrath+ :name "Pray for wrath" :descr "Pray to grant your followers holy touch for 3 turns. Holy touch is a melee fire based attack." :cd 5 :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 20 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-PRAYER-WRATH: ~A [~A] prays for wrath~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone praying~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A prays for wrath. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop for ally-mob-id in (append (visible-mobs actor) (list (id actor))) for mob = (get-mob-by-id ally-mob-id) when (or (eq mob actor) (and (order mob) (= (first (order mob)) +mob-order-follow+) (= (second (order mob)) (id actor)))) do (log:info (format nil "MOB-PRAYER-WRATH: ~A [~A] affects the ally ~A~%" (name actor) (id actor) mob)) (set-mob-effect mob :effect-type-id +mob-effect-holy-touch+ :actor-id (id actor) :cd 3) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is granted holy touch. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-prayer-wrath+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if able to pray - do it (if (and (mob-ability-p actor +mob-abil-prayer-wrath+) (can-invoke-ability actor actor +mob-abil-prayer-wrath+) nearest-enemy) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-shadow-step+ :name "Shadow step" :descr "Dissolve into shadows and reform yourself at a destination tile. Can only be usable if both your origin tile and your destination tile are not lit." :cd 10 :cost 0 :spd (truncate (* +normal-ap+ 0.8)) :passive nil :final t :on-touch nil :motion 30 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the destination tile (log:info (format nil "MOB-SHADOW-STEP: ~A [~A] shadow steps to ~A~%" (name actor) (id actor) target)) (multiple-value-bind (x y z) (values-list target) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A steps into the shadows and disappears. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location actor x y z :apply-gravity t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A steps out of the shadows. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-shadow-step+) (< (brightness actor) *mob-visibility-threshold*)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((free-tile-around nil)) (when nearest-enemy (check-surroundings (x nearest-enemy) (y nearest-enemy) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z nearest-enemy)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) dx dy (z nearest-enemy))) (< (calculate-single-tile-brightness (level *world*) dx dy (z nearest-enemy)) *mob-visibility-threshold*)) (setf free-tile-around (list dx dy (z nearest-enemy)))))))) (if (and (mob-ability-p actor +mob-abil-shadow-step+) (can-invoke-ability actor actor +mob-abil-shadow-step+) nearest-enemy (or ;; offensive shadow step (and (> (/ (cur-hp actor) (max-hp actor)) 0.7) (> (strength actor) (strength nearest-enemy)) free-tile-around) ) ) free-tile-around nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (< (calculate-single-tile-brightness (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) *mob-visibility-threshold*) ) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-extinguish-light+ :name "Extinguish light" :descr "Pronounce an incantation to reduce a character's light radius to 0 for 4 turns or to switch off a stationary light source at range." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 30 :start-map-select-func #'player-start-map-select-extinguish-light :on-invoke #'(lambda (ability-type actor target) ;; target here is list of (x y z) coordinates for the tile to be toggled (log:info (format nil "MOB-EXTINGUISH-LIGHT: ~A [~A] extinguishes light at ~A~%" (name actor) (id actor) target)) (multiple-value-bind (x y z) (values-list target) (if (get-mob-* (level *world*) x y z) (progn (setf target (get-mob-* (level *world*) x y z)) (log:info (format nil "MOB-EXTINGUISH-LIGHT: ~A [~A] extinguishes light of ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (set-mob-effect target :effect-type-id +mob-effect-extinguished-light+ :actor-id (id actor) :cd 4) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A intones an incantation and darkness falls onto ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (when (and (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-light-source+) (> (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-light-source+) 0) (get-terrain-on-use (get-terrain-* (level *world*) x y z))) (funcall (get-terrain-on-use (get-terrain-* (level *world*) x y z)) actor x y z) (print-visible-message x y z (level *world*) (format nil "~A intones an incantation and the light switches off. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ) )) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear somebody chanting~A. " str))) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-extinguish-light+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (mob-ability-p actor +mob-abil-extinguish-light+) (can-invoke-ability actor actor +mob-abil-extinguish-light+) nearest-enemy (> (cur-light nearest-enemy) 0) (not (mob-ability-p nearest-enemy +mob-abil-casts-light+)) (< (get-outdoor-light-* (level *world*) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) *mob-visibility-threshold*)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor (list (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) (id ability-type)) ) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (and (get-terrain-type-trait terrain +terrain-trait-light-source+) (not (zerop (get-terrain-type-trait terrain +terrain-trait-light-source+)))) (and (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) (> (cur-light (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) 0) (find (id (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (visible-mobs *player*))))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-umbral-aura+ :name "Umbral aura" :descr "You emit darkness around you." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-trinity-mimic+ :name "Trinity mimic" :descr "You are not linked to the singlemind of the angelkind, but you have even tighter bonds with the select few of them." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-merge+ :name "Merge" :descr "Cause your bonded trinity mimic standing nearby to merge into you. Melding is allowed only if the target is standing on the solid ground. The act of melding clears all effects from the target. While being merged you will have your HP redistributed each turn with other merged mimics so that all of you have the same amount of HP. Killing the amalgamated entity means killing all angels merged into it." :cost 0 :spd (truncate +normal-ap+ 1.2) :passive nil :final t :on-touch nil :motion 100 :start-map-select-func #'player-start-map-select-merge :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-MERGE: ~A [~A] merges with ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "You hear some eerie sounds~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A merges with ~A. " (capitalize-name (prepend-article +article-the+ (visible-name target))) (prepend-article +article-the+ (visible-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (remove-mob-from-level-list (level *world*) target) ;; merging inventories (loop for item-id in (inv target) for item = (get-item-by-id item-id) do (remove-from-inv item (inv target)) (setf (inv actor) (add-to-inv item (inv actor) (id actor)))) (setf (inv target) nil) (loop for effect-type-id being the hash-key in (effects target) do (rem-mob-effect target effect-type-id)) (when (mob-effect-p actor +mob-effect-merged+) (rem-mob-effect actor +mob-effect-merged+)) (setf (merged-id-list actor) (append (merged-id-list actor) (list (id target)) (merged-id-list target))) (setf (merged-id-list target) nil) (incf (cur-fp actor) (cur-fp target)) (setf (cur-fp target) 0) (set-mob-effect actor :effect-type-id +mob-effect-merged+ :actor-id (id actor) :param1 (mob-type actor)) (when (zerop (random 20)) (if (check-mob-visible actor :observer *player* :complete-check t) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "~A says: \"Power overwhelming!\"~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) str)) :force-sound t) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "Somebody says: \"Power overwhelming!\"~A. " str)) :force-sound t)) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((ally nil) (check-func #'(lambda (mob) (if (and mob (find (id mob) (mimic-id-list actor)) (not (mob-effect-p mob +mob-effect-possessed+)) (not (riding-mob-id mob)) (get-terrain-type-trait (get-terrain-* (level *world*) (x mob) (y mob) (z mob)) +terrain-trait-blocks-move-floor+)) mob nil)))) (setf ally (block nil (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let* ((mob (get-mob-* (level *world*) dx dy (z actor))) (res (funcall check-func mob))) (when res (return res))))) (when (< (1+ (z actor)) (array-dimension (terrain (level *world*)) 2)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let* ((mob (get-mob-* (level *world*) dx dy (1+ (z actor)))) (res (funcall check-func mob))) (when res (return res)))))) (when (>= (1- (z actor)) 0) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let* ((mob (get-mob-* (level *world*) dx dy (1- (z actor)))) (res (funcall check-func mob))) (when res (return res)))))))) (if (and ally (mob-ability-p actor +mob-abil-merge+) (not (mob-effect-p actor +mob-effect-possessed+)) (not (mob-effect-p actor +mob-effect-divine-concealed+))) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-merge+) (can-invoke-ability actor actor +mob-abil-merge+) (not nearest-enemy) nearest-ally (find (id nearest-ally) (mimic-id-list actor)) (not (mob-effect-p nearest-ally +mob-effect-possessed+)) (not (riding-mob-id nearest-ally)) (get-terrain-type-trait (get-terrain-* (level *world*) (x nearest-ally) (y nearest-ally) (z nearest-ally)) +terrain-trait-blocks-move-floor+) (< (get-distance-3d (x actor) (y actor) (z actor) (x nearest-ally) (y nearest-ally) (z nearest-ally)) 2)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy check-result)) (mob-invoke-ability actor nearest-ally (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((target (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (< (get-distance-3d (view-x *player*) (view-y *player*) (view-z *player*) (x *player*) (y *player*) (z *player*)) 2) target (not (eq target *player*)) (find (id target) (visible-mobs *player*)) (find (id target) (mimic-id-list *player*)) (not (mob-effect-p target +mob-effect-possessed+)) (not (riding-mob-id target)) (get-terrain-type-trait (get-terrain-* (level *world*) (x target) (y target) (z target)) +terrain-trait-blocks-move-floor+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* target ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-unmerge+ :name "Unmerge" :descr "Cause all merged trinity mimics to unmerge into nearby tiles." :cost 0 :spd (truncate +normal-ap+ 1.4) :passive nil :final t :on-touch nil :motion 60 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (log:info (format nil "MOB-UNMERGE: ~A [~A] unmerges ~A.~%" (name actor) (id actor) (loop for mimic-id in (merged-id-list actor) for mimic = (get-mob-by-id mimic-id) for i from 0 with str = (create-string) do (when (> i 0) (format str ", ")) (format str "~A [~A]" (name mimic) (id mimic)) finally (return str)))) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "You hear some eerie sounds~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A unmerges all trinity mimics. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect actor +mob-effect-merged+) (let ((tile-list)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) dx dy (z actor))) ) (push (list dx dy (z actor)) tile-list))))) (loop for mimic-id in (merged-id-list actor) for mimic = (get-mob-by-id mimic-id) for random-tile = (random (length tile-list)) for (x y z) = (nth random-tile tile-list) with fp-per-mimic = (floor (cur-fp actor) (1+ (length (merged-id-list actor)))) do (setf (is-merged mimic) nil) (setf tile-list (remove (nth random-tile tile-list) tile-list)) (incf (cur-fp mimic) fp-per-mimic) (decf (cur-fp actor) fp-per-mimic) (setf (x mimic) x (y mimic) y (z mimic) z) (rem-mob-effect mimic +mob-effect-merged+) (add-mob-to-level-list (level *world*) mimic)) (setf (merged-id-list actor) nil) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((tile-list)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) dx dy (z actor))) ) (push (list dx dy (z actor)) tile-list))))) (if (and (mob-ability-p actor +mob-abil-unmerge+) (merged-id-list actor) (>= (length tile-list) 2) (not (mob-effect-p actor +mob-effect-divine-concealed+))) t nil))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (mob-ability-p actor +mob-abil-unmerge+) (can-invoke-ability actor actor +mob-abil-unmerge+) nearest-enemy) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-heal-other+ :name "Heal other" :descr "Invoke divine powers to heal one ally (including yourself)." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-nearest-ally :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-HEAL-OTHER: ~A [~A] heals ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (let ((heal-pwr (+ (* 4 (mob-ability-value actor +mob-abil-heal-other+)) (random (* 3 (mob-ability-value actor +mob-abil-heal-other+)))))) (when (> (+ (cur-hp target) heal-pwr) (max-hp target)) (setf heal-pwr (- (max-hp target) (cur-hp target)))) (incf (cur-hp target) heal-pwr) (decf (cur-fp actor) (cost ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes divine powers to heal ~A for ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) heal-pwr) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-heal-other+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy)) (let ((heal-self (if (< (/ (cur-hp actor) (max-hp actor)) 0.6) actor nil)) (heal-ally (if (and nearest-ally (< (get-distance-3d (x actor) (y actor) (z actor) (x nearest-ally) (y nearest-ally) (z nearest-ally)) (cur-sight actor)) (< (/ (cur-hp nearest-ally) (max-hp nearest-ally)) 0.6)) nearest-ally nil))) (if (and (mob-ability-p actor +mob-abil-heal-other+) (can-invoke-ability actor actor +mob-abil-heal-other+) (or heal-self heal-ally) ) (if heal-ally heal-ally heal-self) nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((target (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and target (get-faction-relation (faction *player*) (faction target)) (check-mob-visible target :observer *player* :complete-check t) (find (id target) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* target ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-righteous-fury+ :name "Righteous fury" :descr "Feel the rage of the righteous. You will hit harder and faster for 5 turns but after the fury subsides you will be slowed for 3 turns." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear someone roaring~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-righteous-fury+ :actor-id (id actor) :cd 5) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-righteous-fury+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-slow+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (> (strength nearest-enemy) (strength actor))) (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.3))) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-righteous-fury+) (can-invoke-ability actor actor +mob-abil-righteous-fury+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-pain-link+ :name "Pain link" :descr "Link yourself with one of the enemies causing it to inflict 30% more damage to you for 10 turns, but 30% damage less to everyone else. Only one link may be present at a time." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 20 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-PAIN-LINK: ~A [~A] uses pain link on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A applies pain link to ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect actor +mob-effect-pain-link-source+) (set-mob-effect target :effect-type-id +mob-effect-pain-link-target+ :actor-id (id actor) :cd 10) (set-mob-effect actor :effect-type-id +mob-effect-pain-link-source+ :actor-id (id actor) :cd 10 :param1 (id target)) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-pain-link+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (not (mob-effect-p nearest-enemy +mob-effect-pain-link-target+)) (not (mob-effect-p actor +mob-effect-pain-link-source+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-soul-reinforcement+ :name "Soul reinforcement" :descr "Invoke divine powers to reinforce the soul of an ally (inclduing yourself) for 3 turns. The reinforced soul will allow the target to remain in this world for a bit longer thus preventing the next fatal blow. In that case, the effect will be cancelled and the target will be left with 1 HP." :cost 3 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 30 :start-map-select-func #'player-start-map-select-nearest-ally :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-SOUL-REINFORCEMENT: ~A [~A] reinforces sould of ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some eerie noises~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A invokes divine powers to reinforce the soul of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-soul-reinforcement+ :actor-id (id actor) :cd 3) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-soul-reinforcement+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy)) (let ((reinforce-self (if (< (/ (cur-hp actor) (max-hp actor)) 0.2) actor nil)) (reinforce-ally (if (and nearest-ally (< (get-distance-3d (x actor) (y actor) (z actor) (x nearest-ally) (y nearest-ally) (z nearest-ally)) (cur-sight actor)) (< (/ (cur-hp nearest-ally) (max-hp nearest-ally)) 0.2)) nearest-ally nil))) (if (and (mob-ability-p actor +mob-abil-soul-reinforcement+) (can-invoke-ability actor actor +mob-abil-soul-reinforcement+) (or reinforce-self reinforce-ally)) (if reinforce-ally reinforce-ally reinforce-self) nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((target (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and target (get-faction-relation (faction *player*) (faction target)) (check-mob-visible target :observer *player* :complete-check t)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* target ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-silence+ :name "Silence" :descr "Channel divine powers to silence an opponent for 3 turns. Silenced characters are not able to use abilities that require voice." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 30 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-SILENCE: ~A [~A] uses silence on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A silences ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-silence+ :actor-id (id actor) :cd 3) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-silence+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (not (mob-effect-p nearest-enemy +mob-effect-silence+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-confuse+ :name "Confuse" :descr "Channel divine powers to confuse an opponent for 4 turns. More powerful creatures may resist confusion. Confused characters have a 50% chance to make a random move instead of an intended action." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 40 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-CONFUSE: ~A [~A] uses confuse on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (if (> (1+ (random 6)) (strength target)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A confuses ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-confuse+ :actor-id (id actor) :cd 4)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to confuse ~A, but ~A resists. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target)) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-confuse+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (not (mob-effect-p nearest-enemy +mob-effect-confuse+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-split-soul+ :name "Split soul" :descr "Split your soul to create an image of yourself next to you. The image will last for 6 turns. You will be able to control the image and transfer yourself to your image's place. You can have only one image created at a time." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) ;; target here is list of (x y z) coordinates for the tile to be placed an image (multiple-value-bind (x y z) (values-list target) (print-visible-message x y z (level *world*) (format nil "~A splits its soul. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some eerie sounds~A." str))) (let ((image (make-instance (if (eq actor *player*) 'player 'mob) :mob-type +mob-type-angel-image+ :x (first target) :y (second target) :z (third target)))) (setf (name image) (format nil "~A's image" (name actor))) (setf (alive-name image) (name image)) (set-mob-effect image :effect-type-id +mob-effect-split-soul-target+ :actor-id (id actor) :cd 6) (set-mob-effect actor :effect-type-id +mob-effect-split-soul-source+ :actor-id (id actor) :cd 6 :param1 (id image)) (add-mob-to-level-list (level *world*) image)) ) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-split-soul+) (not (mob-effect-p actor +mob-effect-split-soul-source+)) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((farthest-tile nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (or (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (get-terrain-type-trait terrain +terrain-trait-water+)) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) dx dy (z actor))) nearest-enemy) (unless farthest-tile (setf farthest-tile (list dx dy (z actor)))) (when (> (get-distance dx dy (x nearest-enemy) (y nearest-enemy)) (get-distance (first farthest-tile) (second farthest-tile) (x nearest-enemy) (y nearest-enemy))) (setf farthest-tile (list dx dy (z actor)))))))) (if (and (mob-ability-p actor +mob-abil-split-soul+) (can-invoke-ability actor actor +mob-abil-split-soul+) farthest-tile nearest-enemy (<= (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2) (> (strength nearest-enemy) (strength actor))) farthest-tile nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (get-terrain-type-trait terrain +terrain-trait-water+)) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-restore-soul+ :name "Restore soul" :descr "Transfer the rest of your soul to the location of your image, destroying the image in the process. You can not restore your soul if your soul source is riding a gargantaur." :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (let ((source (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-split-soul-target+))))) (x (x actor)) (y (y actor)) (z (z actor))) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (get-single-memo-visibility (get-memo-* (level *world*) (x source) (y source) (z source))) (check-mob-visible actor :observer *player*) (check-mob-visible source :observer *player*)) (progn (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some eerie sounds~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A restores its soul to the location of its image. " (capitalize-name (prepend-article +article-the+ (visible-name source)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ((and (get-single-memo-visibility (get-memo-* (level *world*) (x source) (y source) (z source))) (check-mob-visible source :observer *player*)) (progn (generate-sound actor (x source) (y source) (z source) 60 #'(lambda (str) (format nil "You hear some eerie sounds~A. " str))) (print-visible-message (x source) (y source) (z source) (level *world*) (format nil "~A restores its soul to the location of its image. " (capitalize-name (prepend-article +article-the+ (visible-name source)))) :observed-mob source :color (if (and (find (id source) (shared-visible-mobs *player*)) (not (find (id source) (proper-visible-mobs *player*)))) *shared-mind-msg-color* sdl:*white*) :tags (list (when (and (find (id source) (shared-visible-mobs *player*)) (not (find (id source) (proper-visible-mobs *player*)))) :singlemind))))) ((and (get-single-memo-visibility (get-memo-* (level *world*) (x actor) (y actor) (z actor))) (check-mob-visible actor :observer *player*)) (progn (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear some eerie sounds~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A restores its soul to the location of its image. " (capitalize-name (prepend-article +article-the+ (visible-name source)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))) (rem-mob-effect actor +mob-effect-split-soul-target+) (set-mob-location source x y z :apply-gravity nil) (when (eq actor *player*) (setf *player* source)) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-restore-soul+) (mob-effect-p actor +mob-effect-split-soul-target+) (mob-effect-p (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-split-soul-target+)))) +mob-effect-split-soul-source+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+)) (null (riding-mob-id (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-split-soul-target+))))))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (mob-effect-p actor +mob-effect-split-soul-target+) (progn (let ((source (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-split-soul-target+)))))) (log:info (format nil "CHECK-AI-RESTORE-SOUL: ~A [~A], source ~A, cur-hp ~A, ratio ~A, nearest-enemy ~A, can-invoke ~A~%" (name actor) (id actor) (name source) (cur-hp source) (/ (cur-hp source) (max-hp source)) (or (null nearest-enemy) (>= (get-distance (x actor) (x actor) (x nearest-enemy) (y nearest-enemy)) 2)) (can-invoke-ability actor actor +mob-abil-restore-soul+))) (if (and (mob-ability-p actor +mob-abil-restore-soul+) (can-invoke-ability actor actor +mob-abil-restore-soul+) (< (/ (cur-hp source) (max-hp source)) 0.3) (null (riding-mob-id source)) (or (null nearest-enemy) (>= (get-distance (x actor) (x actor) (x nearest-enemy) (y nearest-enemy)) 2)) ) t nil))) nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-resurrection+ :name "Resurrection" :descr "Restore the original soul to the body and make it alive again. The resurrection is only possible for bodies that are not mangled or corrupted by demonic reanimations." :cost 6 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-resurrect :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-RESURRECTION: ~A [~A] resurrects ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) ;; target here is the item to be reanimated (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A channels divine energy. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear somebody chanting~A. " str))) (let ((mob-corpse)) (setf mob-corpse (get-mob-by-id (dead-mob target))) (setf (x mob-corpse) (x target) (y mob-corpse) (y target) (z mob-corpse) (z target)) (setf (dead= mob-corpse) nil) (setf (cur-hp mob-corpse) (max-hp mob-corpse)) (setf (cur-fp mob-corpse) 0) (setf (cur-ap mob-corpse) (max-ap mob-corpse)) (when (merged-id-list mob-corpse) (loop for mob-id in (merged-id-list mob-corpse) for mob = (get-mob-by-id mob-id) do (setf (dead= mob) nil) (setf (cur-hp mob) (max-hp mob)) (setf (cur-fp mob) 0) (when (and (mob-ability-p mob +mob-abil-angel+) (not (mob-ability-p mob +mob-abil-animal+))) (incf (total-angels (level *world*)))) (when (mob-ability-p mob +mob-abil-human+) (incf (total-humans (level *world*)))) (incf (nth (loyal-faction mob) (total-faction-list (level *world*))))) (set-mob-effect mob-corpse :effect-type-id +mob-effect-merged+ :actor-id (id mob-corpse) :param1 (mob-type mob-corpse))) (add-mob-to-level-list (level *world*) mob-corpse) (remove-item-from-level-list (level *world*) target) (when (eq mob-corpse *player*) (setf (dead-message-displayed *player*) nil)) (print-visible-message (x mob-corpse) (y mob-corpse) (z mob-corpse) (level *world*) (format nil "~A stands up and walks. " (capitalize-name (prepend-article +article-the+ (visible-name mob-corpse)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (log:info (format nil "MOB-RESURRECTION: ~A [~A] is resurrected at (~A ~A ~A).~%" (name mob-corpse) (id mob-corpse) (x mob-corpse) (y mob-corpse) (z mob-corpse))) (remove-item-from-world target) (incf (stat-raised-dead actor)) (when (eq actor *player*) (incf (cur-score *player*) 10))) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-resurrection+) (not (mob-effect-p actor +mob-effect-divine-concealed+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (let ((item-id (funcall #'(lambda () (let ((visible-items (copy-list (visible-items actor)))) (setf visible-items (remove-if #'(lambda (a) (if (= (item-type a) +item-type-body-part-full+) nil t)) visible-items :key #'get-item-by-id)) (setf visible-items (remove-if #'(lambda (a) (if (get-mob-* (level *world*) (x a) (y a) (z a)) t nil)) visible-items :key #'get-item-by-id)) (setf visible-items (remove-if #'(lambda (a) (if (and (dead-mob a) (mob-ability-p (get-mob-by-id (dead-mob a)) +mob-abil-angel+)) nil t)) visible-items :key #'get-item-by-id)) (setf visible-items (stable-sort visible-items #'(lambda (a b) (if (> (get-distance-3d (x actor) (y actor) (z actor) (x a) (y a) (z a)) (get-distance-3d (x actor) (y actor) (z actor) (x b) (y b) (z b))) t nil)) :key #'get-item-by-id)) (if visible-items (first visible-items) nil)))))) (if (and (mob-ability-p actor +mob-abil-resurrection+) (can-invoke-ability actor actor +mob-abil-resurrection+) item-id) item-id nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor (get-item-by-id check-result) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((items (get-items-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (= (item-type a) +item-type-body-part-full+) nil t)) items :key #'get-item-by-id)) (setf items (remove-if #'(lambda (a) (if (and (dead-mob a) (not (mob-ability-p (get-mob-by-id (dead-mob a)) +mob-abil-demon+))) nil t)) items :key #'get-item-by-id)) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (> (length items) 1)) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A" (capitalize-name (prepend-article +article-a+ (visible-name item))) ))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Resurrect [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body to resurrect:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) ;(set-idle-calcing win) (make-output *current-window*) ;(show-time-label (idle-calcing win) (+ 20 (* *glyph-w* *max-x-view*)) (+ 10 237) t) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (length items) 1) (item-ability-p (get-item-by-id (first items)) +item-abil-corpse+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) (t (progn nil)))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-sprint+ :name "Sprint" :descr "Concenrate all your physical efforts, making yourself move 25% faster for 4 turns. You are unable to sprint while riding another creature." :cd 10 :spd 0 :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (set-mob-effect actor :effect-type-id +mob-effect-sprint+ :actor-id (id actor) :cd 4) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-sprint+) (not (mob-effect-p actor +mob-effect-exerted+)) (not (riding-mob-id actor))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (> (strength nearest-enemy) (strength actor))) (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.3))) (mob-ability-p actor +mob-abil-sprint+) (can-invoke-ability actor actor +mob-abil-sprint+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-jump+ :name "Jump" :descr "Jump to a specified location up to 3 tiles away. Jumping lets you cling to walls if you are able to and the destination allows it. Sprinting lets you jump 1 tile farther and you will still be able to cling to a wall after the jump. You are able to jump over small obstacles like tables and fences." :cd 0 :cost 0 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; here the target is not a mob, but a (cons x y) (log:info (format nil "MOB-JUMP: ~A [~A] jumps to ~A.~%" (name actor) (id actor) target)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A jumps. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((path-line nil)) (line-of-sight (x actor) (y actor) (z actor) (car target) (cdr target) (z actor) #'(lambda (dx dy dz prev-cell) (declare (ignore dz prev-cell)) (let ((exit-result t)) (block nil (push (cons dx dy) path-line) exit-result)))) (setf path-line (nreverse path-line)) (pop path-line) (loop for (dx . dy) in path-line with charge-distance = (if (mob-effect-p actor +mob-effect-sprint+) 3 2) with charge-result = nil with sdx = (x actor) with sdy = (y actor) with prev-dx = (x actor) with prev-dy = (y actor) with hit-obstacle = nil with can-jump-over = nil while (not (zerop charge-distance)) do (decf charge-distance) (setf charge-result (check-move-on-level actor dx dy (z actor))) (if (not (eq charge-result t)) (setf hit-obstacle t) (setf hit-obstacle nil)) (if (and charge-result (typep charge-result 'list) (eq (first charge-result) :obstacles) (get-terrain-type-trait (get-terrain-* (level *world*) (first (first (second charge-result))) (second (first (second charge-result))) (third (first (second charge-result)))) +terrain-trait-can-jump-over+)) (setf can-jump-over t) (setf can-jump-over nil)) (setf sdx dx sdy dy) (when (and hit-obstacle (null can-jump-over)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A hits an obstacle. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf sdx prev-dx sdy prev-dy) (loop-finish)) (when (null hit-obstacle) (setf prev-dx sdx prev-dy sdy)) (when (and (zerop charge-distance) hit-obstacle can-jump-over) (setf sdx prev-dx sdy prev-dy)) finally (rem-mob-effect actor +mob-effect-sprint+) (when (mob-ability-p actor +mob-abil-climbing+) (set-mob-effect actor :effect-type-id +mob-effect-climbing-mode+ :actor-id (id actor) :cd t)) (when (or (/= (x actor) sdx) (/= (y actor) sdy)) (set-mob-location actor sdx sdy (z actor) :apply-gravity t))) (set-mob-effect actor :effect-type-id +mob-effect-exerted+ :actor-id (id actor) :cd 6) )) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-jump+) (not (riding-mob-id actor)) (not (mob-effect-p actor +mob-effect-exerted+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (mob-ability-p actor +mob-abil-jump+) (can-invoke-ability actor actor +mob-abil-jump+)) nil nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor (cons (x nearest-enemy) (y nearest-enemy)) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (eq *player* (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (progn nil) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (cons (view-x *player*) (view-y *player*)) ability-type-id) t)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-bend-space+ :name "Bend space" :descr "Bend space around yourself instantly warping to some other place up to 6 tiles away." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (invoke-bend-space actor) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.5)) (mob-ability-p actor +mob-abil-bend-space+) (can-invoke-ability actor actor +mob-abil-bend-space+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-cast-shadow+ :name "Cast shadow" :descr "Cause a character to cast unnatural shadows on an adjacent tile for 6 turns. These shadows are valid for the Shadow Step ability." :cd 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 40 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-CAST-SHADOW: ~A [~A] uses cast shadow on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A causes ~A to cast unnatural shadows. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect target +mob-effect-casting-shadow+) (set-mob-effect target :effect-type-id +mob-effect-casting-shadow+ :actor-id (id actor) :cd 6 :param1 (let ((dx (x target)) (dy (y target))) (loop for r = (1+ (random 9)) while (= r 5) finally (multiple-value-setq (dx dy) (x-y-dir r))) (list dx dy))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-cast-shadow+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (not (mob-effect-p nearest-enemy +mob-effect-casting-shadow+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-cannibalize+ :name "Cannibalize" :descr "Eat the corpse you are standing on to gain 3 HP and 1 power. If your HP are at the maximum, also gain 1 maximum HP." :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info "MOB-CANNIBALIZE: ~A [~A] invokes cannibalize on ~A [~A].~%" (name actor) (id actor) (name target) (id target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone munching~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A devours ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-a+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ;; for +game-event-win-for-eater-consume+ win event (when (eq actor *player*) (incf (eater-corpses-consumed actor))) (let ((already-mutated nil) (mutation-chance 20)) (when (dead-mob target) (cond ((mob-ability-p (get-mob-by-id (dead-mob target)) +mob-abil-human+) (progn (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-toggle-light+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A can now toggle lights. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t)) (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-vulnerable-to-vorpal+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now vulnerable to vorpal. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t)))) ((mob-ability-p (get-mob-by-id (dead-mob target)) +mob-abil-demon+) (progn (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-bend-space+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A can now bend space. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t)) (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-vulnerable-to-fire+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now vulnerable to fire. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t)))) ((mob-ability-p (get-mob-by-id (dead-mob target)) +mob-abil-angel+) (progn (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-regenerate+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A can now regenerate. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t)) (when (and (null already-mutated) (zerop (random mutation-chance))) (mob-set-mutation actor +mob-abil-casts-light+) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A is now casting light. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*yellow* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (setf already-mutated t))))))) (remove-item-from-level-list (level *world*) target) (remove-item-from-world target) (incf (cur-hp actor) 3) (when (> (cur-hp actor) (max-hp actor)) (incf (max-hp actor)) (setf (cur-hp actor) (max-hp actor))) (if (mob-effect-p actor +mob-effect-primordial-transfer+) (let ((transfer-target (get-mob-by-id (actor-id (get-effect-by-id (mob-effect-p actor +mob-effect-primordial-transfer+)))))) (when (eq transfer-target *player*) (add-message (format nil "Your larva transfers power to you. "))) (incf (cur-fp transfer-target)) (when (> (cur-fp transfer-target) (max-fp transfer-target)) (setf (cur-fp transfer-target) (max-fp transfer-target)))) (progn (incf (cur-fp actor)) (when (> (cur-fp actor) (max-fp actor)) (setf (cur-fp actor) (max-fp actor))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (loop for item-id in (get-items-* (level *world*) (x actor) (y actor) (z actor)) for item = (get-item-by-id item-id) with corpses = nil when (item-ability-p item +item-abil-corpse+) do (push item corpses) finally (return (if corpses t nil)))) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-cannibalize+) (can-invoke-ability actor actor +mob-abil-cannibalize+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (let ((target (loop for item-id in (get-items-* (level *world*) (x actor) (y actor) (z actor)) for item = (get-item-by-id item-id) with corpses = nil when (item-ability-p item +item-abil-corpse+) do (push item corpses) finally (return (first corpses))))) (mob-invoke-ability actor target (id ability-type)))) :obj-select-func #'(lambda (ability-type-id) (let ((items (get-items-* (level *world*) (x *player*) (y *player*) (z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (item-ability-p (get-item-by-id a) +item-abil-corpse+) nil t)) items)) (cond ((> (length items) 1) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A~A" (capitalize-name (name item)) (if (> (qty item) 1) (format nil " x~A" (qty item)) "")))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Devour [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body part to devour:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) ;(set-idle-calcing win) (make-output *current-window*) ;(show-time-label (idle-calcing win) (+ 20 (* *glyph-w* *max-x-view*)) (+ 10 237) t) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((= (length items) 1) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) (t (progn nil))))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-primordial+ :name "Primordial" :descr "You dwelt on Earth before the advent of humankind. You will dwell on Earth after its inevitable demise." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-make-disguise+ :name "Make a disguise" :descr "Create a disguise out of two costumes. The disguise lets you conceal your true nature and present yourself as an ordinary man or a woman." :spd (* +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone working~A. " str))) (setf (inv actor) (remove-from-inv-by-type +item-type-clothing+ (inv actor) 2)) (mob-pick-item actor (make-instance 'item :item-type +item-type-disguise+ :x (x actor) :y (y actor) :z (z actor) :qty 1) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A creates a disguise. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-make-disguise+) (>= (loop for item in (get-inv-items-by-type (inv actor) +item-type-clothing+) sum (qty item)) 2)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-make-disguise+) (can-invoke-ability actor actor +mob-abil-make-disguise+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-remove-disguise+ :name "Remove a disguise" :descr "Remove a man-made disguise from yourself." :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear clothes rustling~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A removes its disguise. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect actor +mob-effect-disguised+) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-remove-disguise+) (mob-effect-p actor +mob-effect-disguised+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-remove-disguise+) (can-invoke-ability actor actor +mob-abil-remove-disguise+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-constriction+ :name "Constriction" :descr "When you attack a character in melee, you are able to grab and constrict around them. When constricting, you continue to deal damage to the constricted character even if you are already attacking another character. Constriction is broken when you or the constricted character move to another tile." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-deep-breath+ :name "Deep breath" :descr "Make a deep breath. On the next turn, Malseraph transforms your exhale into sickly rays irradiating everybody around you. The power of the irradiation increases with the number of times the target is affected by the rays. Heavy irradiation may sometimes make the target unable to act. The amount of irradiation depends on your favor with Malseraph." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :removes-disguise t :motion 40 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (log:info (format nil "MOB-DEEP-BREATH: ~A [~A] uses deep breath.~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 40 #'(lambda (str) (format nil "You hear someone breathing~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A takes a deep breath. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect actor :effect-type-id +mob-effect-deep-breath+ :actor-id (id actor) :cd 2) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-deep-breath+) (not (mob-effect-p actor +mob-effect-deep-breath+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (< (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2) (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor)))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-irradiate+ :name "Irradiate" :descr "Channel hellish powers to affect the target character with sickly invisible rays. Exposure to them causes irradiation of the target. The power of the irradiation increases with the number of times the target is affected by the rays. Heavy irradiation may sometimes make the target unable to act. The amount of irradiation depends on your favor with Malseraph." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :removes-disguise t :motion 20 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (log:info (format nil "MOB-IRRADIATE: ~A [~A] uses irradiate on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A irradiates ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let* ((malseraph (get-god-by-id (get-worshiped-god-type (worshiped-god actor)))) (irradiate-bonus (funcall (piety-level-func malseraph) malseraph (get-worshiped-god-piety (worshiped-god actor)))) (irradiate-value (if (zerop irradiate-bonus) -1 (random irradiate-bonus)))) (if (mob-effect-p target +mob-effect-irradiated+) (progn (let ((effect (get-effect-by-id (mob-effect-p target +mob-effect-irradiated+)))) (incf (param1 effect) (+ 2 irradiate-value)))) (progn (set-mob-effect target :effect-type-id +mob-effect-irradiated+ :actor-id (id actor) :cd t :param1 (+ 2 irradiate-value))))) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-irradiate+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (or (not (mob-effect-p nearest-enemy +mob-effect-irradiated+)) (and (mob-effect-p nearest-enemy +mob-effect-irradiated+) (< (param1 (get-effect-by-id (mob-effect-p nearest-enemy +mob-effect-irradiated+))) 5) (zerop (random 2))) (and (mob-effect-p nearest-enemy +mob-effect-irradiated+) (< (param1 (get-effect-by-id (mob-effect-p nearest-enemy +mob-effect-irradiated+))) 10) (zerop (random 3))))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-fission+ :name "Fission" :descr "Cause a violent outburst of energy from all irradiated targets in sight. The damage to the target scales with the degree of irradiation. Characters that are not irradiated are not affected." :cost 1 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :removes-disguise t :motion 40 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (let ((targets)) (setf targets (loop for mob-id in (visible-mobs actor) for mob = (get-mob-by-id mob-id) when (mob-effect-p mob +mob-effect-irradiated+) collect mob)) (log:info (format nil "MOB-FISSION: ~A [~A] uses fission on ~A.~%" (name actor) (id actor) (loop with str = (create-string) for mob in targets do (format str "~A [~A], " (name mob) (id mob)) finally (return str)))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A causes fission. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop for mob in targets when (> (param1 (get-effect-by-id (mob-effect-p mob +mob-effect-irradiated+))) 0) do (inflict-damage mob :actor actor :min-dmg (param1 (get-effect-by-id (mob-effect-p mob +mob-effect-irradiated+))) :max-dmg (* 2 (param1 (get-effect-by-id (mob-effect-p mob +mob-effect-irradiated+)))) :dmg-type +weapon-dmg-radiation+ :no-dodge t :no-hit-message t :att-spd nil :weapon-aux () :acc 100 :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage. " (capitalize-name (prepend-article +article-the+ (name mob))) cur-dmg))) (rem-mob-effect mob +mob-effect-irradiated+)) (decf (cur-fp actor) (cost ability-type))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-fission+) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (not (get-faction-relation (faction actor) (get-visible-faction nearest-enemy :viewer actor))) (or (and (mob-effect-p nearest-enemy +mob-effect-irradiated+) (< (param1 (get-effect-by-id (mob-effect-p nearest-enemy +mob-effect-irradiated+))) 5) (zerop (random 3))) (and (mob-effect-p nearest-enemy +mob-effect-irradiated+) (< (param1 (get-effect-by-id (mob-effect-p nearest-enemy +mob-effect-irradiated+))) 10) (zerop (random 2))) (and (mob-effect-p nearest-enemy +mob-effect-irradiated+) (>= (param1 (get-effect-by-id (mob-effect-p nearest-enemy +mob-effect-irradiated+))) 10)))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-create-parasites+ :name "Spawn parasites" :descr "Start the scarab egg laying process. 6 parasites become ready to use in 3 turns. Parasites can infest an enemy character for a very long period of time. Parasited characters will have their direct resistances against flesh and acid damage reduced by 1. You can always see the location of parasited characters." :cost 1 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-laying-eggs+ :actor-id (id actor) :cd 3 :param1 #'(lambda () (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-parasite+ :x (x actor) :y (y actor) :z (z actor) :qty 6) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "6 parasite eggs have finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Parasite eggs start to grow inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-create-parasites+) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-laying-eggs+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-create-parasites+) (can-invoke-ability actor actor +mob-abil-create-parasites+) (< (loop for item in (get-inv-items-by-type (inv actor) +item-type-eater-parasite+) sum (qty item)) 3)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-adrenal-gland+ :name "Adrenal gland" :descr "When you attack somebody, your adrenaline level will start to increase. Increased adrenaline will make your attacks faster." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-acid-spit+ :name "Grow an acid gland" :descr "Evolve to give yourself an ability to spit acid at your enemies. The evolution process takes 10 turns. The acid spit is mutually exclusive with the clawed tentacles, corrosive sacs and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-acid-spit+ "grows an acid gland")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-acid-spit+) (not (mob-ability-p actor +mob-abil-acid-spit+)) (not (mob-ability-p actor +mob-abil-corrosive-bile+)) (not (mob-ability-p actor +mob-abil-accurate-bile+)) (not (mob-ability-p actor +mob-abil-clawed-tentacle+)) (not (mob-ability-p actor +mob-abil-piercing-needles+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-acid-spit+) (can-invoke-ability actor actor +mob-abil-mutate-acid-spit+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-acid-spit+ :name "Acid spit" :descr "You are able to spit at your enemies dealing 1-3 acid damage." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil :on-add-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (if (mob-ability-p actor +mob-abil-corroding-secretion+) (setf (weapon actor) (list "Tentacles & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) (list +weapon-dmg-acid+ 1 3 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges :corrodes)))) (setf (weapon actor) (list "Tentacles & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) (list +weapon-dmg-acid+ 1 3 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges))))) (adjust-r-acc actor) ) :on-remove-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (setf (weapon actor) (list "Tentacles" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) nil)) (adjust-r-acc actor) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-corrosive-bile+ :name "Grow corrosive sacs" :descr "Evolve to give yourself an ability to spit corrosive bile at your enemies. The evolution process takes 10 turns. Corrosive bile is shot upwards and lands to the destination tile on the next turn, dealing damage to charaters in and around it. The corrosive sacs are mutually exclusive with the clawed tentacles, acid spite and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-corrosive-bile+ "grows corrosive sacs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-corrosive-bile+) (not (mob-ability-p actor +mob-abil-acid-spit+)) (not (mob-ability-p actor +mob-abil-corroding-secretion+)) (not (mob-ability-p actor +mob-abil-corrosive-bile+)) (not (mob-ability-p actor +mob-abil-clawed-tentacle+)) (not (mob-ability-p actor +mob-abil-piercing-needles+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-corrosive-bile+) (can-invoke-ability actor actor +mob-abil-mutate-corrosive-bile+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-corrosive-bile+ :name "Corrosive bile" :descr "Spit corrosive bile at a tile. It is shot upwards and lands to the destination tile on the next turn, dealing 4-8 acid damage to charaters in and around it. Available if there are no obstacles above you up to the highest Z level. Corrosive bile is not very accurate and will sometimes land next to the targeted location." :cost 0 :cd 4 :spd +normal-ap+ :passive nil :final t :on-touch nil :removes-disguise t :motion 40 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target is (x y z) (log:info (format nil "MOB-CORROSIVE-BILE: ~A [~A] uses corrosive bile on ~A.~%" (name actor) (id actor) target)) (let ((x (+ (first target) (- (random 3) 1))) (y (+ (second target) (- (random 3) 1)))) (when (mob-ability-p actor +mob-abil-accurate-bile+) (setf x (first target) y (second target))) (loop with final-z = (third target) for z from (1- (array-dimension (terrain (level *world*)) 2)) downto final-z when (and (get-terrain-* (level *world*) x y z) (or (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-blocks-move-floor+))) do (loop-finish) when (and (get-terrain-* (level *world*) x y z) (or (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-blocks-projectiles+) (get-terrain-type-trait (get-terrain-* (level *world*) x y z) +terrain-trait-water+))) do (incf z) (loop-finish) finally (when (< z (array-dimension (terrain (level *world*)) 2)) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-corrosive-bile-target+ :x x :y y :z z :counter 2 :param1 (id actor))))) (generate-sound actor (x actor) (y actor) (z actor) 40 #'(lambda (str) (format nil "You hear someone bodily sounds~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A spits corrosive bile. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-corrosive-bile+) (loop for z from (1+ (z actor)) below (array-dimension (terrain (level *world*)) 2) with clear-path = t when (and (get-terrain-* (level *world*) (x actor) (y actor) z) (or (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) z) +terrain-trait-blocks-projectiles+) (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) z) +terrain-trait-water+))) do (setf clear-path nil) (loop-finish) finally (return clear-path))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (< (get-distance-3d (x *player*) (y *player*) (z *player*) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) 9) (loop for z from (1- (array-dimension (terrain (level *world*)) 2)) downto (1+ (z nearest-enemy)) with clear-path = t when (and (get-terrain-* (level *world*) (x nearest-enemy) (y nearest-enemy) z) (or (get-terrain-type-trait (get-terrain-* (level *world*) (x nearest-enemy) (y nearest-enemy) z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* (level *world*) (x nearest-enemy) (y nearest-enemy) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) (x nearest-enemy) (y nearest-enemy) z) +terrain-trait-blocks-projectiles+) (get-terrain-type-trait (get-terrain-* (level *world*) (x nearest-enemy) (y nearest-enemy) z) +terrain-trait-water+))) do (setf clear-path nil) (loop-finish) finally (return clear-path))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor (list (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (< (get-distance-3d (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*)) 9) (loop for z from (1- (array-dimension (terrain (level *world*)) 2)) downto (1+ (view-z *player*)) with clear-path = t when (and (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) (or (get-terrain-type-trait (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) z) +terrain-trait-blocks-move+) (get-terrain-type-trait (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) z) +terrain-trait-blocks-move-floor+) (get-terrain-type-trait (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) z) +terrain-trait-blocks-projectiles+) (get-terrain-type-trait (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) z) +terrain-trait-water+))) do (setf clear-path nil) (loop-finish) finally (return clear-path))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-clawed-tentacle+ :name "Grow clawed tentacles" :descr "Evolve to give yourself clawed tentacles which significatly increase melee damage. The evolution process takes 10 turns. The clawed tentacles are mutually exclusive with the acid spit, corrosive sacs and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-clawed-tentacle+ "grows clawed tentacles")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-clawed-tentacle+) (not (mob-ability-p actor +mob-abil-acid-spit+)) (not (mob-ability-p actor +mob-abil-corroding-secretion+)) (not (mob-ability-p actor +mob-abil-corrosive-bile+)) (not (mob-ability-p actor +mob-abil-accurate-bile+)) (not (mob-ability-p actor +mob-abil-clawed-tentacle+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-clawed-tentacle+) (can-invoke-ability actor actor +mob-abil-mutate-clawed-tentacle+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-clawed-tentacle+ :name "Clawed tentacles" :descr "Your tentacles have sharp claws." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil :on-add-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (setf (weapon actor) (list "Clawed tentacles" (list +weapon-dmg-flesh+ 3 5 (truncate (* +normal-ap+ 0.75)) 100 (list :constricts)) nil)) ) :on-remove-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (setf (weapon actor) (list "Tentacles" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-chitinous-plating+ :name "Grow chitinous plating" :descr "Evolve to increase your skin thickness which will turn it into full-scale armor. The evolution process takes 10 turns. Chitinous plating gives 2 points of direct resistance against flesh, iron, fire, vorpal and acid damage. The chitinous plating is mutually exclusive with the metabolic boost and retracting spines." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-chitinous-plating+ "gets completely covered with chitin")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-chitinous-plating+) (not (mob-ability-p actor +mob-abil-chitinous-plating+)) (not (mob-ability-p actor +mob-abil-metabolic-boost+)) (not (mob-ability-p actor +mob-abil-jump+)) (not (mob-ability-p actor +mob-abil-retracting-spines+)) (not (mob-ability-p actor +mob-abil-acidic-tips+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-chitinous-plating+) (can-invoke-ability actor actor +mob-abil-mutate-chitinous-plating+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-chitinous-plating+ :name "Chitinous plating" :descr "You are completely covered with chitin which gives you 2 points of direct resistance against flesh, iron, fire, vorpal and acid damage." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil :on-add-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (adjust-armor actor) ) :on-remove-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (adjust-armor actor) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-metabolic-boost+ :name "Increase metabolism" :descr "Evolve to give youself an ability to boost your metabolism at will. The evolution process takes 10 turns. The metabolic boost grants you increased dodging and overall speed for 4 turns. The metabolic boost is mutually exclusive with the chitinous plating and retracting spines." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-metabolic-boost+ "can now boost metabolism at will")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-metabolic-boost+) (not (mob-ability-p actor +mob-abil-chitinous-plating+)) (not (mob-ability-p actor +mob-abil-thick-carapace+)) (not (mob-ability-p actor +mob-abil-metabolic-boost+)) (not (mob-ability-p actor +mob-abil-retracting-spines+)) (not (mob-ability-p actor +mob-abil-acidic-tips+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-metabolic-boost+) (can-invoke-ability actor actor +mob-abil-mutate-metabolic-boost+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-metabolic-boost+ :name "Metabolic boost" :descr "Accelerate your metabolism which increases your dodging by 50% and overall speed by 30% for 4 turns." :cd 8 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (set-mob-effect actor :effect-type-id +mob-effect-metabolic-boost+ :actor-id (id actor) :cd 4) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A accelerates its metabolism. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-metabolic-boost+) (not (mob-effect-p actor +mob-effect-metabolic-boost+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and nearest-enemy (< (get-distance-3d (x actor) (y actor) (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) 3) (mob-ability-p actor +mob-abil-metabolic-boost+) (can-invoke-ability actor actor +mob-abil-metabolic-boost+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-retracting-spines+ :name "Grow retracting spines" :descr "Evolve to give yourself retracting spines. The evolution process takes 10 turns. The spines grant you 40% resistance against flesh, iron, fire, vorpal and acid damage for 4 turns. Additionally, characters attacking you in melee while the spines are active will take 1-3 flesh damage. The retracting spines are mutually exclusive with the metabolic boost and chitinous plating." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-retracting-spines+ "grows retracting spines")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-retracting-spines+) (not (mob-ability-p actor +mob-abil-chitinous-plating+)) (not (mob-ability-p actor +mob-abil-thick-carapace+)) (not (mob-ability-p actor +mob-abil-metabolic-boost+)) (not (mob-ability-p actor +mob-abil-jump+)) (not (mob-ability-p actor +mob-abil-retracting-spines+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-retracting-spines+) (can-invoke-ability actor actor +mob-abil-mutate-retracting-spines+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-retracting-spines+ :name "Extend spines" :descr "Extend your spines which gives you 40% resistance against flesh, iron, fire, vorpal and acid damage for 4 turns. Additionally, characters attacking you in melee while the spines are active will take 1-3 flesh damage." :cd 8 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (set-mob-effect actor :effect-type-id +mob-effect-spines+ :actor-id (id actor) :cd 4) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A extends its spines. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-retracting-spines+) (not (mob-effect-p actor +mob-effect-spines+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and nearest-enemy (< (get-distance-3d (x actor) (y actor) (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) 3) (mob-ability-p actor +mob-abil-retracting-spines+) (can-invoke-ability actor actor +mob-abil-retracting-spines+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-spawn-locusts+ :name "Grow locust spawning sacs" :descr "Evolve to let your ovipositor spawn locusts. The evolution process takes 15 turns. Locusts live for 10 turns, have 8 HP and deal 3-4 flesh dmg in melee. The locust spawning sacs are mutually exclusive with the scarab spawning sacs." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-spawn-locusts+ "grows locust spawning sacs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-spawn-locusts+) (not (mob-ability-p actor +mob-abil-spawn-locusts+)) (not (mob-ability-p actor +mob-abil-spawn-scarabs+)) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-spawn-locusts+) (can-invoke-ability actor actor +mob-abil-mutate-spawn-locusts+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-spawn-locusts+ :name "Spawn locust eggs" :descr "Start the egg laying process. 2 eggs become ready to use in 6 turns and can later quickly develop into locusts. A locust has 8 HP, deals 3-4 flesh damage in melee and lives for 10 turns." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 100 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-laying-eggs+ :actor-id (id actor) :cd 6 :param1 #'(lambda () (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-locust-egg+ :x (x actor) :y (y actor) :z (z actor) :qty 2) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "2 locust eggs have finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Locust eggs start to grow inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-spawn-locusts+) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-laying-eggs+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) (if (and (mob-ability-p actor +mob-abil-spawn-locusts+) (can-invoke-ability actor actor +mob-abil-spawn-locusts+) (< (loop for item in (get-inv-items-by-type (inv actor) +item-type-eater-locust-egg+) sum (qty item)) 2)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-ovipositor+ :name "Grow ovipositor" :descr "Evolve to get an ability to lay eggs different kind of eggs. The evolution process takes 15 turns." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-oviposit+ "grows ovipositor")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-ovipositor+) (not (mob-ability-p actor +mob-abil-oviposit+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-ovipositor+) (can-invoke-ability actor actor +mob-abil-mutate-ovipositor+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-oviposit+ :name "Ovipositor" :descr "You are able to lay different kinds of eggs." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-spawn-scarabs+ :name "Grow scarab spawning sacs" :descr "Evolve to let your ovipositor spawn scarabs. The evolution process takes 15 turns. Scarabs are living bombs that try to move to the target and explode to deal 6-10 acid damage when contacting an enemy. The scarab spawning sacs are mutually exclusive with the locust spawning sacs." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-spawn-scarabs+ "grows scarab spawning sacs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-spawn-scarabs+) (not (mob-ability-p actor +mob-abil-spawn-locusts+)) (not (mob-ability-p actor +mob-abil-spawn-scarabs+)) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-spawn-scarabs+) (can-invoke-ability actor actor +mob-abil-mutate-spawn-scarabs+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-spawn-scarabs+ :name "Spawn scarab eggs" :descr "Start the scarab egg laying process. Eggs become ready to use in 6 turns and can later quickly develop into scarabs. Scarabs are living bombs that try to move to the target and explode to deal 6-10 acid damage when contacting an enemy." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-laying-eggs+ :actor-id (id actor) :cd 6 :param1 #'(lambda () (if (mob-ability-p actor +mob-abil-oviposit-more-eggs+) (progn (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-scarab-egg+ :x (x actor) :y (y actor) :z (z actor) :qty 2) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "2 scarab eggs have finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-scarab-egg+ :x (x actor) :y (y actor) :z (z actor) :qty 1) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "A scarab egg has finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))))) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Scarab eggs start to grow inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-oviposit+) (mob-ability-p actor +mob-abil-spawn-scarabs+) (not (mob-effect-p actor +mob-effect-laying-eggs+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) (if (and (mob-ability-p actor +mob-abil-spawn-scarabs+) (can-invoke-ability actor actor +mob-abil-spawn-scarabs+) (< (loop for item in (get-inv-items-by-type (inv actor) +item-type-eater-scarab-egg+) sum (qty item)) 2)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-acid-explosion+ :name "Acid explosion" :descr "You explode when contacting allies and enemies." :passive t :cost 0 :spd +normal-ap+ :final t :on-touch t :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-ACID-EXPLOSION: ~A [~A] explodes on ~A [~A]~%" (name actor) (id actor) (name target) (id target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A explodes. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((targets nil) (max-range 1)) (draw-fov (x actor) (y actor) (z actor) max-range #'(lambda (dx dy dz prev-cell) (let ((exit-result t)) (block nil (when (> (get-distance-3d (x actor) (y actor) (z actor) dx dy dz) (1+ max-range)) (setf exit-result 'exit) (return)) (when (eq (check-LOS-propagate dx dy dz prev-cell :check-move t) nil) (setf exit-result 'exit) (return)) (place-animation dx dy dz +anim-type-acid-dot+ :params ()) (when (and (get-mob-* (level *world*) dx dy dz)) (pushnew (get-mob-* (level *world*) dx dy dz) targets)) ) exit-result))) (loop for target in targets for cur-dmg = 0 do (incf cur-dmg (inflict-damage target :min-dmg 6 :max-dmg 10 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :no-hit-message t :no-check-dead t :actor actor)) (if (zerop cur-dmg) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color (if (if-cur-mob-seen-through-shared-vision *player*) *shared-mind-msg-color* sdl:*white*)) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name target))) cur-dmg) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (when (and (not (eq target actor)) (check-dead target)) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params ()) (when (mob-effect-p target +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ())))) (setf (cur-hp actor) 0) (when (check-dead actor) (make-dead actor :splatter nil :msg t :killer nil :corpse nil :aux-params ()) (when (mob-effect-p actor +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id actor))) 0) (setf (x (get-mob-by-id (slave-mob-id actor))) (x actor) (y (get-mob-by-id (slave-mob-id actor))) (y actor) (z (get-mob-by-id (slave-mob-id actor))) (z actor)) (make-dead (get-mob-by-id (slave-mob-id actor)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ()))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type)) (if (and (mob-ability-p actor +mob-abil-acid-explosion+) (not (get-faction-relation (faction actor) (faction target)))) t nil)))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-acid-locusts+ :name "Morph acidic spawning sacs" :descr "Evolve to make your spawning sacs create locusts with acid (instead of flesh) damage. The evolution process takes 15 turns. This mutation is only available if you already have the locust spawning sacs." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-acid-locusts+ "grows acidic spawning sacs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-acid-locusts+) (mob-ability-p actor +mob-abil-spawn-locusts+) (not (mob-ability-p actor +mob-abil-acid-locusts+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-acid-locusts+) (can-invoke-ability actor actor +mob-abil-mutate-acid-locusts+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-fast-scarabs+ :name "Morph faster scarabs" :descr "Evolve to make your scarabs cover ground quicker. The evolution process takes 15 turns. This mutation is only available if you already have the scarab spawning sacs." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-fast-scarabs+ "grows adrenalized ovipositor")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-fast-scarabs+) (mob-ability-p actor +mob-abil-spawn-scarabs+) (not (mob-ability-p actor +mob-abil-fast-scarabs+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-fast-scarabs+) (can-invoke-ability actor actor +mob-abil-mutate-fast-scarabs+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-acid-locusts+ :name "Acid locusts" :descr "The locusts you spawn will have an acid attack (instead of a flesh one)." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-fast-scarabs+ :name "Fast scarabs" :descr "The scarabs you spawn will cover ground to the target quicker." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-regenerate+ :name "Regenerate" :descr "Heal 6 HP within 6 turns." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-regenerate+ :actor-id (id actor) :cd 6) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to regenerate. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-regenerate+) (not (mob-effect-p actor +mob-effect-regenerate+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) (if (and (mob-ability-p actor +mob-abil-regenerate+) (can-invoke-ability actor actor +mob-abil-regenerate+) (>= (- (max-hp actor) (cur-hp actor)) 6)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-casts-light+ :name "Casts light" :descr "You light radius is always 6. Prevails over the Extinguish light ability." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-vulnerable-to-vorpal+ :name "Vulnerable to vorpal" :descr "Your direct resistance to vorpal is always 2 points lower than usual." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-vulnerable-to-fire+ :name "Vulnerable to fire" :descr "Your direct resistance to fire is always 2 points lower than usual." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-oviposit-more-eggs+ :name "Morph multiple eggcells" :descr "Evolve to make your ovipositor lay 2 scarab eggs at once instead of one. The evolution process takes 15 turns. This mutation is only available if you already have the scarab spawning sacs." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-oviposit-more-eggs+ "can now lay more eggs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-oviposit-more-eggs+) (mob-ability-p actor +mob-abil-spawn-scarabs+) (not (mob-ability-p actor +mob-abil-oviposit-more-eggs+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-oviposit-more-eggs+) (can-invoke-ability actor actor +mob-abil-mutate-oviposit-more-eggs+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-oviposit-more-eggs+ :name "Multiple eggcells" :descr "Your ovipositor lays 2 scarab eggs at once instead of one." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-tougher-locusts+ :name "Morph chitin injection" :descr "Evolve to make your locusts last 15 turns (instead of 10) and have 14 HP (instead of 8). The evolution process takes 15 turns. This mutation is only available if you already have the locust spawning sacs." :cost 4 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 15 :param1 (list +mob-abil-tougher-locusts+ "can now spawn tougher locusts")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-tougher-locusts+) (mob-ability-p actor +mob-abil-spawn-locusts+) (not (mob-ability-p actor +mob-abil-tougher-locusts+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-tougher-locusts+) (can-invoke-ability actor actor +mob-abil-mutate-tougher-locusts+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-tougher-locusts+ :name "Chitin injection" :descr "Your locusts last 15 turns (instead of 10) and have 14 HP (instead of 8)." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-cure-mutation+ :name "Cure mutation" :descr "Cure one mutation you have gained." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) ;; target is ability-type-id (log:info (format nil "MOB-CURE-MUTATION: ~A [~A] invokes cure mutatation on ~A [~A].~%" (name actor) (id actor) (name (get-ability-type-by-id target)) (id (get-ability-type-by-id target)))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone bodily sounds~A. " str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A gets rid of ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (name (get-ability-type-by-id target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (mob-remove-mutation actor target) (decf (cur-fp actor) (cost ability-type)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (loop for ability-type-id in (get-mob-all-abilities actor) with has-mutation = nil when (mob-is-ability-mutation actor ability-type-id) do (setf has-mutation t) (loop-finish) finally (return (if has-mutation t nil))) ) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((malmutations (loop for malmutation in (list +mob-abil-vulnerable-to-fire+ +mob-abil-vulnerable-to-vorpal+ +mob-abil-casts-light+) when (and (mob-ability-p actor malmutation) (mob-is-ability-mutation actor malmutation)) collect malmutation))) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-cure-mutation+) malmutations (can-invoke-ability actor actor +mob-abil-cure-mutation+)) malmutations nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (let* ((target-mutation (nth (random (length check-result)) check-result))) (mob-invoke-ability actor target-mutation (id ability-type)))) :obj-select-func #'(lambda (ability-type-id) (let ((mutations (loop for ability-type-id being the hash-key in (abilities *player*) with mutations = () when (mob-is-ability-mutation *player* ability-type-id) do (pushnew ability-type-id mutations) finally (return mutations))) (exit-result nil)) (cond ((>= (length mutations) 1) (progn (let ((mutation-line-list nil) (mutation-prompt-list) (mutation-list (copy-list mutations))) (setf mutation-line-list (loop for mutation-id in mutation-list for mutation = (get-ability-type-by-id mutation-id) collect (format nil "~A" (name mutation)))) ;; populate the ability prompt list (setf mutation-prompt-list (loop for mutation-id in mutation-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Cure [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a mutation to cure:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (nth cur-sel mutation-list) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) (make-output *current-window*) (setf exit-result t)) :line-list mutation-line-list :prompt-list mutation-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) (t (progn nil))))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-thick-carapace+ :name "Grow thick carapace" :descr "Evolve to further increase your carapace thickness. The evolution process takes 10 turns. Thick carapace gives 1 point of direct resistance against flesh, iron, fire, vorpal and acid damage. The thick carapace is mutually exclusive with the metabolic boost, retracting spines and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-thick-carapace+ "grows an even thicker carapace")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-thick-carapace+) (mob-ability-p actor +mob-abil-chitinous-plating+) (not (mob-ability-p actor +mob-abil-thick-carapace+)) (not (mob-ability-p actor +mob-abil-metabolic-boost+)) (not (mob-ability-p actor +mob-abil-retracting-spines+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-thick-carapace+) (can-invoke-ability actor actor +mob-abil-mutate-thick-carapace+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-thick-carapace+ :name "Thick carapace" :descr "Your carapace is thicker than usual which gives you 1 point of direct resistance against flesh, iron, fire, vorpal and acid damage." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil :on-add-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (adjust-armor actor) ) :on-remove-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (adjust-armor actor) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-acidic-tips+ :name "Grow acidic tips" :descr "Evolve to give your retracting spines an acidic tip. The evolution process takes 10 turns. The spines will deal 1-3 acid (instead of flesh) damage. Acidic tips are mutually exclusive with the metabolic boost, chitinous plating and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-acidic-tips+ "now secretes acid at the tips of its spines")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-acidic-tips+) (not (mob-ability-p actor +mob-abil-chitinous-plating+)) (not (mob-ability-p actor +mob-abil-thick-carapace+)) (not (mob-ability-p actor +mob-abil-metabolic-boost+)) (mob-ability-p actor +mob-abil-retracting-spines+) (not (mob-ability-p actor +mob-abil-acidic-tips+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-acidic-tips+) (can-invoke-ability actor actor +mob-abil-mutate-acidic-tips+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-acidic-tips+ :name "Acidic tips" :descr "Your retracting spines have an acidic tip which makes them deal 1-3 acid (instead of flesh) damage." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-jump+ :name "Grow extensor muscles" :descr "Evolve to grant your extensor muscles extra force thus letting you jump. The evolution process takes 10 turns. Jumping is mutually exclusive with the retracting spines, chitinous plating and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-jump+ "can now jump")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-jump+) (not (mob-ability-p actor +mob-abil-chitinous-plating+)) (not (mob-ability-p actor +mob-abil-thick-carapace+)) (mob-ability-p actor +mob-abil-metabolic-boost+) (not (mob-ability-p actor +mob-abil-jump+)) (not (mob-ability-p actor +mob-abil-retracting-spines+)) (not (mob-ability-p actor +mob-abil-acidic-tips+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-jump+) (can-invoke-ability actor actor +mob-abil-mutate-jump+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-piercing-needles+ :name "Grow piercing needles" :descr "Evolve to give your tentacles tiny needles that stick into the constricted target and decrease its dodge chance by 40%. The evolution process takes 10 turns. The piercing needles are mutually exclusive with the acid spit, corrosive sacs and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-piercing-needles+ "grows tiny needles on its tentacles")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-piercing-needles+) (not (mob-ability-p actor +mob-abil-acid-spit+)) (not (mob-ability-p actor +mob-abil-corrosive-bile+)) (mob-ability-p actor +mob-abil-clawed-tentacle+) (not (mob-ability-p actor +mob-abil-piercing-needles+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-piercing-needles+) (can-invoke-ability actor actor +mob-abil-mutate-piercing-needles+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-piercing-needles+ :name "Piercing needles" :descr "Your tentacles have tiny needles that stick into the constricted target and decrease its dodge chance by 40%." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-corroding-secretion+ :name "Increase acid strength" :descr "Evolve to make you acid spit corrode its target reducing its direct resistance against acid and flesh damage by 1. The evolution process takes 10 turns. Increased acid strength is mutually exclusive with the clawed tentacles, corrosive sacs and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-corroding-secretion+ "now has increased acid strength")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-corroding-secretion+) (mob-ability-p actor +mob-abil-acid-spit+) (not (mob-ability-p actor +mob-abil-corroding-secretion+)) (not (mob-ability-p actor +mob-abil-corrosive-bile+)) (not (mob-ability-p actor +mob-abil-clawed-tentacle+)) (not (mob-ability-p actor +mob-abil-piercing-needles+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-corroding-secretion+) (can-invoke-ability actor actor +mob-abil-mutate-corroding-secretion+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-corroding-secretion+ :name "Corroding secretion" :descr "Your acid spit corrodes the target, decreasing its direct resistance against flesh and acid damage by 1." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil :on-add-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (when (and (mob-ability-p actor +mob-abil-corroding-secretion+) (mob-ability-p actor +mob-abil-acid-spit+)) (setf (weapon actor) (list "Tentacles & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) (list +weapon-dmg-acid+ 1 3 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges :corrodes)))) (adjust-r-acc actor) ) ) :on-remove-mutation #'(lambda (ability-type actor) (declare (ignore ability-type)) (setf (weapon actor) (list "Tentacles & Acid spit" (list +weapon-dmg-flesh+ 2 3 +normal-ap+ 100 (list :constricts)) (list +weapon-dmg-acid+ 1 3 +normal-ap+ 1 0 1 100 "spits at" (list :no-charges)))) (adjust-r-acc actor) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-accurate-bile+ :name "Increase cerebellum" :descr "Evolve to give your corrosive bile increased accuracy so that it always lands to the destination tile. The evolution process takes 10 turns. Increased cerebellum is mutually exclusive with the clawed tentacles, acid spit and their upgrades." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 10 :param1 (list +mob-abil-accurate-bile+ "grows increased cerebellum")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-accurate-bile+) (not (mob-ability-p actor +mob-abil-acid-spit+)) (not (mob-ability-p actor +mob-abil-corroding-secretion+)) (mob-ability-p actor +mob-abil-corrosive-bile+) (not (mob-ability-p actor +mob-abil-accurate-bile+)) (not (mob-ability-p actor +mob-abil-clawed-tentacle+)) (not (mob-ability-p actor +mob-abil-piercing-needles+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-accurate-bile+) (can-invoke-ability actor actor +mob-abil-mutate-accurate-bile+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-accurate-bile+ :name "Increased cerebellum" :descr "Your corrosive bile always lands to the destination tile, without any deviations." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-hooks-and-suckers+ :name "Grow hooks & sucker cups" :descr "Evolve to give your tentacles hooks and sucker cups which lets you climb walls. The evolution process takes 20 turns." :cost 2 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-climbing+ "can now climb walls")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-hooks-and-suckers+) (not (mob-ability-p actor +mob-abil-climbing+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-hooks-and-suckers+) (can-invoke-ability actor actor +mob-abil-mutate-hooks-and-suckers+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-disguise-as-human+ :name "Morph facade readjustment" :descr "Evolve to give yourself an ability to disguise as a human at will. The evolution process takes 20 turns. Requires the hooks & sucker cups mutation." :cost 4 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-disguise-as-human+ "can now disguise itself as a human")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-disguise-as-human+) (mob-ability-p actor +mob-abil-climbing+) (not (mob-ability-p actor +mob-abil-disguise-as-human+)) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-disguise-as-human+) (can-invoke-ability actor actor +mob-abil-mutate-disguise-as-human+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-disguise-as-human+ :name "Disguise as a human" :descr "Disguise yourself as a human." :cost 0 :cd 10 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 25 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (invoke-disguise actor) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (not (mob-effect-p actor +mob-effect-disguised+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) ;; if the dst is more than 3 tiles away - stealth, if possible (if (and (path actor) (> (length (path actor)) 3) (mob-ability-p actor +mob-abil-disguise-as-human+) (can-invoke-ability actor actor +mob-abil-disguise-as-human+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-spawn-larva+ :name "Grow larva spawning sacs" :descr "Evolve to let your ovipositor spawn seeker larvae. The evolution process takes 20 turns. Larvae are small fragile creatures that can not defend themselves but will eat corpses and collect power to you." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-spawn-larva+ "grows larva spawning sacs")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-spawn-larva+) (not (mob-ability-p actor +mob-abil-spawn-larva+)) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-spawn-larva+) (can-invoke-ability actor actor +mob-abil-mutate-spawn-larva+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-spawn-larva+ :name "Spawn a larva egg" :descr "Start the egg laying process. 1 egg become ready to use in 6 turns and can later quickly develop into a larva. A larva has 6 HP, can not attack and collects power from the corpses for you." :cost 2 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 100 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-laying-eggs+ :actor-id (id actor) :cd 6 :param1 #'(lambda () (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-larva-egg+ :x (x actor) :y (y actor) :z (z actor) :qty 1) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "A larva egg has finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Larva eggs start to grow inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-spawn-larva+) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-laying-eggs+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-enemy nearest-ally)) (if (and (mob-ability-p actor +mob-abil-spawn-larva+) (can-invoke-ability actor actor +mob-abil-spawn-larva+) (< (loop for item in (get-inv-items-by-type (inv actor) +item-type-eater-larva-egg+) sum (qty item)) 1)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-spore-colony+ :name "Grow spore colony eggcells" :descr "Evolve to let your ovipositor spawn spore colonies. The evolution process takes 20 turns. Spore colonies are immobile mindless creature that spit acid at enemies in their sight." :cost 4 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-spore-colony+ "grows spore colony eggcells")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-mutate-spore-colony+) (not (mob-ability-p actor +mob-abil-spore-colony+)) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-evolving+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-spore-colony+) (can-invoke-ability actor actor +mob-abil-mutate-spore-colony+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-spore-colony+ :name "Spawn a spore colony egg" :descr "Start the egg laying process. 1 egg become ready to use in 12 turns and can later quickly develop into a spore colony. Spore colonies are immobile mindless creatures that flouresce and spit for 1-4 acid damage at any enemy of the primordials in its sight." :cost 4 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 100 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (set-mob-effect actor :effect-type-id +mob-effect-laying-eggs+ :actor-id (id actor) :cd 12 :param1 #'(lambda () (mob-pick-item actor (make-instance 'item :item-type +item-type-eater-colony-egg+ :x (x actor) :y (y actor) :z (z actor) :qty 1) :spd nil :silent t) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "A spore colony egg has finished growing inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "Spore colony eggs start to grow inside ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-spore-colony+) (mob-ability-p actor +mob-abil-oviposit+) (not (mob-effect-p actor +mob-effect-laying-eggs+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (mob-ability-p actor +mob-abil-spore-colony+) (can-invoke-ability actor actor +mob-abil-spore-colony+) (not nearest-enemy) (< (loop for item in (get-inv-items-by-type (inv actor) +item-type-eater-colony-egg+) sum (qty item)) 1)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-immobile+ :name "Immobile" :descr "You are unable to move around." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-float+ :name "Floating" :descr "You float in the air and do not take any damage when falling down from any height. You do not generate any sounds or footprints while moving. Does not work when you possess a corporeal body." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-ghost-possess+ :name "Possess" :descr "You are able to possess humans or corpses from a distance. Note that you can attempt to possess anybody but the ability will fail on inappropriate targets. You can not possess a blessed or divine shielded character. While in possession of a host, you wear its body as your own, gaining all its abilities and HP as the result. When your host dies, you emerge from the body unscathed (except for cases when an angel kills your zombie host - you will burn together with your body). You can attempt to possess another host while already wearing one but this will lead to releasing control of the first host." :cd 8 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-ghost-possess :on-invoke #'(lambda (ability-type actor target) ;; target is either item or mob (declare (ignore ability-type)) (log:info (format nil "MOB-GHOST-POSSESS: ~A [~A] uses ranged possession on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (cond ;; you failed to possess a blessed target ((and (subtypep (type-of target) 'mob) (mob-ability-p target +mob-abil-possessable+) (null (master-mob-id target)) (mob-effect-p target +mob-effect-blessed+)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to possess ~A, but the blessing protects from it. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )) ;; you failed to possess a divine protected target ((and (subtypep (type-of target) 'mob) (mob-ability-p target +mob-abil-possessable+) (null (master-mob-id target)) (mob-effect-p target +mob-effect-divine-shield+)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to possess ~A, but the divine shield protects from it. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )) ;; you can not possess the target for any other reason ((and (subtypep (type-of target) 'mob) (not (and (mob-ability-p target +mob-abil-possessable+) (null (master-mob-id target)) (not (mob-effect-p target +mob-effect-blessed+)) (not (mob-effect-p target +mob-effect-divine-shield+)))) ) (progn (if (or (mob-effect-p target +mob-effect-divine-concealed+) (and (mob-effect-p target +mob-effect-possessed+) (not (mob-effect-p target +mob-effect-reveal-true-form+)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to possess ~A, but suddenly reveals its true form. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (rem-mob-effect target +mob-effect-divine-concealed+) (set-mob-effect target :effect-type-id +mob-effect-reveal-true-form+ :actor-id (id actor) :cd 5) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "It is ~A. " (prepend-article +article-the+ (get-qualified-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A tries to possess ~A, but fails. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))))) (t (progn ;; remove invisibility (when (mob-effect-p actor +mob-effect-invisibility+) (rem-mob-effect actor +mob-effect-invisibility+)) ;; you depossess your currently possessed body (when (slave-mob-id actor) (let ((slave-mob (get-mob-by-id (slave-mob-id actor)))) (cond ((mob-ability-p slave-mob +mob-abil-undead+) (progn (rem-mob-effect actor +mob-effect-life-guard+) (mob-depossess-target actor) (mob-transfer-effects actor slave-mob) (setf (cur-hp slave-mob) 0) (make-dead slave-mob :splatter nil) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A slumps to the ground. " (capitalize-name (prepend-article +article-the+ (name slave-mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) (t (progn (rem-mob-effect actor +mob-effect-life-guard+) (mob-depossess-target actor) (mob-transfer-effects actor slave-mob) ))))) (cond ((subtypep (type-of target) 'mob) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A possesses ~A. " (capitalize-name (prepend-article +article-the+ (name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (mob-possess-target actor target) (mob-transfer-effects target actor) (set-mob-effect actor :effect-type-id +mob-effect-life-guard+ :actor-id (id actor) :cd t) )) ((subtypep (type-of target) 'item) (progn (let ((mob-corpse-type) (mob-corpse)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A possesses ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (cond ((eq (item-ability-p target +item-abil-corpse+) 1) (setf mob-corpse-type +mob-type-reanimated-pwr-1+)) ((eq (item-ability-p target +item-abil-corpse+) 2) (setf mob-corpse-type +mob-type-reanimated-pwr-2+)) ((eq (item-ability-p target +item-abil-corpse+) 3) (setf mob-corpse-type +mob-type-reanimated-pwr-3+)) (t (setf mob-corpse-type +mob-type-reanimated-pwr-4+))) (setf mob-corpse (make-instance 'mob :mob-type mob-corpse-type :x (x target) :y (y target) :z (z target))) (setf (name mob-corpse) (format nil "reanimated ~A" (name target))) (setf (alive-name mob-corpse) (alive-name target)) (add-mob-to-level-list (level *world*) mob-corpse) (remove-item-from-level-list (level *world*) target) (print-visible-message (x mob-corpse) (y mob-corpse) (z mob-corpse) (level *world*) (format nil "~A starts to move. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (remove-item-from-world target) (decf (stat-raised-dead actor)) (mob-possess-target actor mob-corpse) (set-mob-effect actor :effect-type-id +mob-effect-life-guard+ :actor-id (id actor) :cd t) (incf (stat-possess actor)) ))) ) ))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-ghost-possess+) ) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) ;; a little bit of cheating here (let ((corpse-items (loop for item-id in (visible-items actor) for item = (get-item-by-id item-id) when (and (item-ability-p item +item-abil-corpse+) (not (get-mob-* (level *world*) (x item) (y item) (z item)))) collect item)) (final-result nil)) (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) (or (null (slave-mob-id actor)) (and nearest-enemy (mob-ability-p nearest-enemy +mob-abil-angel+) (mob-ability-p actor +mob-abil-undead+) (< (/ (cur-hp actor) (max-hp actor)) 0.4))) (or (and nearest-enemy (mob-ability-p nearest-enemy +mob-abil-possessable+) (null (master-mob-id nearest-enemy)) (setf final-result nearest-enemy)) (and corpse-items (setf final-result (first corpse-items))))) final-result nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (items (get-items-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (item-ability-p (get-item-by-id a) +item-abil-corpse+) nil t)) items)) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (null mob) (eq mob *player*)) (> (length items) 1)) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A~A" (capitalize-name (name item)) (if (> (qty item) 1) (format nil " x~A" (qty item)) "")))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Possess [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body part to possess:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) (make-output *current-window*) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (or (null mob) (eq mob *player*)) (= (length items) 1)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t)) (t (progn nil))) ) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-invisibility+ :name "Invisibility" :descr "Make yourself invisible to enemy's eyes." :cd 20 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 0 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (set-mob-effect actor :effect-type-id +mob-effect-invisibility+ :actor-id (id actor) :cd 6) (generate-sound actor (x actor) (y actor) (z actor) 30 #'(lambda (str) (format nil "You hear some strange noise~A. " str))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-invisibility+)) (not (mob-effect-p actor +mob-effect-silence+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) ;; if the dst is more than 3 tiles away - stealth, if possible (if (and (path actor) nearest-enemy (= (cur-hp actor) 1) (mob-ability-p actor +mob-abil-invisibility+) (can-invoke-ability actor actor +mob-abil-invisibility+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-passwall+ :name "Passwall" :descr "Pass through a row of solid, normally impassable terrain tiles. You must be next to such tile, your location relative to this tile sets the direction of your movement during passwall. You emerge on the other side of the tile row. You are also able to pass up and down through floors and ceilings. If you will not be able to emerge from the given tile row (for any reason), you will not be able to invoke the ability." :cd 6 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is list of (x y z) coordinates for the tile which is the first in the row of passwalled tiles (let* ((dx (- (first target) (x actor))) (dy (- (second target) (y actor))) (dz (- (third target) (z actor))) (passwall-result (mob-move-passwall actor dx dy dz))) (when passwall-result (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A merges into the ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-terrain-name (get-terrain-* (level *world*) (first target) (second target) (third target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location actor (first passwall-result) (second passwall-result) (third passwall-result)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A emerges from the ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (get-terrain-name (get-terrain-* (level *world*) (- (x actor) dx) (- (y actor) dy) (- (z actor) dz)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) )) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-passwall+) (not (slave-mob-id actor)) (let ((solid-tile nil)) (loop for dx from -1 to 1 do (loop for dy from -1 to 1 do (loop for dz from -1 to 1 do (when (and (>= (+ (x actor) dx) 0) (< (+ (x actor) dx) (array-dimension (terrain (level *world*)) 0)) (>= (+ (y actor) dy) 0) (< (+ (y actor) dy) (array-dimension (terrain (level *world*)) 1)) (>= (+ (z actor) dz) 0) (< (+ (z actor) dz) (array-dimension (terrain (level *world*)) 2)) (get-terrain-* (level *world*) (+ (x actor) dx) (+ (y actor) dy) (+ (z actor) dz)) (get-terrain-type-trait (get-terrain-* (level *world*) (+ (x actor) dx) (+ (y actor) dy) (+ (z actor) dz)) +terrain-trait-blocks-move+)) (setf solid-tile t))))) solid-tile)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((step-x 0) (step-y 0)) (if (and (mob-ability-p actor +mob-abil-passwall+) (can-invoke-ability actor actor +mob-abil-passwall+) nearest-enemy (setf step-x (cond ((> (x nearest-enemy) (x actor)) -1) ((< (x nearest-enemy) (x actor)) 1) (t 0))) (setf step-y (cond ((> (y nearest-enemy) (y actor)) -1) ((< (y nearest-enemy) (y actor)) 1) (t 0))) (get-terrain-* (level *world*) (+ (x actor) step-x) (+ (y actor) step-y) (z actor)) (get-terrain-type-trait (get-terrain-* (level *world*) (+ (x actor) step-x) (+ (y actor) step-y) (z actor)) +terrain-trait-blocks-move+) (mob-move-passwall actor step-x step-y 0) ) (list (+ (x actor) step-x) (+ (y actor) step-y) (z actor)) nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((terrain (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (< (get-distance-3d (view-x *player*) (view-y *player*) (view-z *player*) (x *player*) (y *player*) (z *player*)) 2) terrain (or (get-terrain-type-trait terrain +terrain-trait-blocks-move+) (and (/= (- (view-z *player*) (z *player*)) 0) (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+))) (mob-move-passwall *player* (- (view-x *player*) (x *player*)) (- (view-y *player*) (y *player*)) (- (view-z *player*) (z *player*)))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-ghost-release+ :name "Release host" :descr "Release your control of your host. Undead host slump back to the ground while alive hosts are released unharmed. Note that the inventory of remains with the host." :cd 0 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :start-map-select-func #'player-start-map-select-self :on-invoke #'(lambda (ability-type actor target) ;; target is (x y z) coordinates of where the ghost will be placed (declare (ignore ability-type)) (log:info (format nil "MOB-GHOST-RELEASE: ~A [~A] releases host ~A [~A].~%" (name actor) (id actor) (name (get-mob-by-id (slave-mob-id actor))) (id (get-mob-by-id (slave-mob-id actor))))) ;; you depossess your currently possessed body (let ((slave-mob (get-mob-by-id (slave-mob-id actor)))) (cond ((mob-ability-p slave-mob +mob-abil-undead+) (progn (rem-mob-effect actor +mob-effect-life-guard+) (mob-depossess-target actor) (mob-transfer-effects actor slave-mob) (setf (cur-hp slave-mob) 0) (make-dead slave-mob :splatter nil) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A slumps to the ground. " (capitalize-name (prepend-article +article-the+ (name slave-mob)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location actor (first target) (second target) (third target)))) (t (progn (rem-mob-effect actor +mob-effect-life-guard+) (mob-depossess-target actor) (mob-transfer-effects actor slave-mob) (set-mob-location actor (first target) (second target) (third target)) (set-mob-location slave-mob (x slave-mob) (y slave-mob) (z slave-mob)) (setf (brightness slave-mob) (brightness actor)) ))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-ghost-release+) (slave-mob-id actor)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore actor nearest-ally ability-type nearest-enemy)) ;; a little bit of cheating here nil) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy check-result)) (mob-invoke-ability actor nil (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (and (< (get-distance-3d (view-x *player*) (view-y *player*) (view-z *player*) (x *player*) (y *player*) (z *player*)) 2) (check-move-on-level *player* (view-x *player*) (view-y *player*) (view-z *player*)) (not (and (not (mob-ability-p *player* +mob-abil-undead+)) (= (get-distance-3d (view-x *player*) (view-y *player*) (view-z *player*) (x *player*) (y *player*) (z *player*)) 0)))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-decipher-rune+ :name "Decipher rune" :descr "Study a demonic rune and learn its meaning. You must stand next to a rune to study it." :cost 0 :spd (* +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 60 :start-map-select-func #'player-start-map-select-rune :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target here is a feature (demonic rune) to be deciphered (log:info (format nil "MOB-DECIPHER-RUNE: ~A [~A] deciphers ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A deciphers ~A. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-a+ (name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (mob-pick-item actor (make-instance 'item :item-type (get-feature-type-trait target +feature-trait-demonic-rune+) :x (x actor) :y (y actor) :z (z actor) :qty 1) :spd nil :silent t) (remove-feature-from-level-list (level *world*) target) (remove-feature-from-world target) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (let ((rune nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (loop for feature-id in (get-features-* (level *world*) dx dy (z actor)) for feature = (get-feature-by-id feature-id) when (get-feature-type-trait feature +feature-trait-demonic-rune+) do (setf rune feature) (loop-finish)))) (if (and (mob-ability-p actor +mob-abil-decipher-rune+) rune ) t nil)) ) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((rune nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (loop for feature-id in (get-features-* (level *world*) dx dy (z actor)) for feature = (get-feature-by-id feature-id) when (get-feature-type-trait feature +feature-trait-demonic-rune+) do (setf rune feature) (loop-finish)))) (if (and (mob-ability-p actor +mob-abil-decipher-rune+) (can-invoke-ability actor actor +mob-abil-decipher-rune+) (not nearest-enemy) rune ) rune nil))) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally nearest-enemy)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((features (remove-if #'(lambda (a) (if (get-feature-type-trait (get-feature-by-id a) +feature-trait-demonic-rune+) nil t)) (get-features-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (exit-result nil)) (cond ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (> (length features) 1)) (progn (let ((feature-line-list nil) (feature-prompt-list) (feature-list (copy-list features))) (setf feature-line-list (loop for feature-id in feature-list for feature = (get-feature-by-id feature-id) collect (format nil "~A" (capitalize-name (name feature))))) ;; populate the ability prompt list (setf feature-prompt-list (loop for feature-id in feature-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Decipher [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a demonic rune to decipher:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-feature-by-id (nth cur-sel feature-list)) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) (make-output *current-window*) (setf exit-result t)) :line-list feature-line-list :prompt-list feature-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) ) ((and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (= (view-z *player*) (z *player*)) (< (get-distance (view-x *player*) (view-y *player*) (x *player*) (y *player*)) 2) (= (length features) 1)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-feature-by-id (first features)) ability-type-id) t)) (t (progn nil))) ) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-flesh+ :name "Demon word: Flesh" :descr "Complete the demon invitation process and turn a zombie into an imp. Available only if you have deciphered demon runes Un and Ged." :cd 10 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-empower-undead :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-DEMON-WORD-FLESH: ~A [~A] uses demon word flesh on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) ;; if used on a ghost the ability will fail (if (mob-ability-p target +mob-abil-ghost-possess+) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Flesh, but nothing happens. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Flesh and ~A turns into an imp. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (mob-effect-p target +mob-effect-empowered-undead+) (rem-mob-effect target +mob-effect-empowered-undead+)) (let ((old-max-hp (max-hp target))) (setf (mob-type target) +mob-type-imp+) (setf (max-hp target) (max-hp (get-mob-type-by-id (mob-type target)))) (setf (cur-hp target) (round (* (cur-hp target) (max-hp target)) old-max-hp))) (setf (face-mob-type-id target) (mob-type target)) (setf (name target) nil) (set-name target) (set-cur-weapons target) (adjust-abilities target) (adjust-dodge target) (adjust-armor target) (adjust-m-acc target) (adjust-r-acc target) (adjust-sight target) ;; set up current abilities cooldowns (loop for ability-id being the hash-key in (abilities target) when (null (gethash ability-id (abilities-cd target))) do (setf (gethash ability-id (abilities-cd target)) 0)) )) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-flesh+) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-flesh+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-invite+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy)) ;; a little bit of cheating here (if (and (can-invoke-ability actor nearest-ally (id ability-type)) nearest-ally (mob-ability-p nearest-ally +mob-abil-undead+) (not (mob-ability-p nearest-ally +mob-abil-ghost-possess+)) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy check-result)) (mob-invoke-ability actor nearest-ally (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*)) (mob-ability-p mob +mob-abil-undead+)) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-soul+ :name "Soul" :descr "You have a soul." :passive t :cost 0 :spd 0 :final nil :on-touch nil :on-invoke nil :on-check-applic nil)) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-plague+ :name "Demon word: Plague" :descr "Infest the target with soul sickness. Soul sickness is a special demon-devised disease that affects only soulful beings (like humans and angels) for 30 turns. Each turn a character affected with soul sickness has a 25% chance to lose 1 HP. However, the disease never takes the last HP. Disease carrier will also infect soulful characters standing nearby. But beware, though you have pledged your service to demons you are still human and can be affected yourself. Available only if you have deciphered demon runes Un and Drux." :cd 10 :cost 0 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 10 :start-map-select-func #'player-start-map-select-nearest-hostile :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-DEMON-WORD-PLAGUE: ~A [~A] uses demon word plague on ~A [~A].~%" (name actor) (id actor) (name target) (id target))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) (if (mob-ability-p target +mob-abil-soul+) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Plague. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect target :effect-type-id +mob-effect-soul-sickness+ :actor-id (id actor) :cd 30)) (progn (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Plague, but ~A is not affected. " (capitalize-name (prepend-article +article-the+ (visible-name actor))) (prepend-article +article-the+ (visible-name target))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-plague+) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-flesh+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-decay+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-ally)) ;; a little bit of cheating here (if (and (can-invoke-ability actor nearest-enemy (id ability-type)) nearest-enemy (mob-ability-p nearest-enemy +mob-abil-soul+) (not (mob-effect-p nearest-enemy +mob-effect-soul-sickness+))) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-ally check-result)) (mob-invoke-ability actor nearest-enemy (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((mob (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)))) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) mob (not (eq *player* mob)) (find (id mob) (visible-mobs *player*))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* mob ability-type-id) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-power+ :name "Demon word: Power" :descr "Gain the powers of an Archdemon for 7 turns. Available only if you have deciphered demon runes Un and Med." :cd 15 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-DEMON-WORD-POWER: ~A [~A] uses demon word power.~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Power. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect actor :effect-type-id +mob-effect-demonic-power+ :actor-id (id actor) :cd 7) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-power+) (not (mob-effect-p actor +mob-effect-demonic-power+)) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-flesh+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-transform+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (> (strength nearest-enemy) (strength actor))) (and nearest-enemy (< (/ (cur-hp actor) (max-hp actor)) 0.3))) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-demon-word-power+) (can-invoke-ability actor actor +mob-abil-demon-word-power+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-darkness+ :name "Demon word: Darkness" :descr "Plead to Nephitis to blot out the sun. The sun's power will eventually prevail but while the enchantment lasts everything will be drowned in darkness. Available only if you have deciphered demon runes Gon, Drux and Tal." :cd 30 :spd (* +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-DEMON-WORD-DARKNESS: ~A [~A] uses demon word darkness.~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Darkness. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (pushnew +game-event-unnatural-darkness+ (game-events (level *world*))) (add-message "Unnatural darkness falls on the world! " sdl:*magenta*) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-darkness+) (not (find +game-event-unnatural-darkness+ (game-events (level *world*)))) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-barrier+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-decay+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-all+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-demon-word-darkness+) (can-invoke-ability actor actor +mob-abil-demon-word-darkness+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-invasion+ :name "Demon word: Invasion" :descr "Plead to Yosototh to weaken the barriers between the worlds and let evil spirits reanimate corpses in the city. This enchantment makes corpses reanimate on their own from time to time, without your interference. Available only if you have deciphered demon runes Gon, Ged and Tal." :cd 30 :spd (* +normal-ap+ 4) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-DEMON-WORD-INVASION: ~A [~A] uses demon word invasion.~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Invasion. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (pushnew +game-event-constant-reanimation+ (game-events (level *world*))) (add-message "You seem to start hearing whispers from beyond! " sdl:*magenta*) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-invasion+) (not (find +game-event-constant-reanimation+ (game-events (level *world*)))) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-barrier+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-invite+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-all+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-demon-word-invasion+) (can-invoke-ability actor actor +mob-abil-demon-word-invasion+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-demon-word-knockback+ :name "Demon word: Knockback" :descr "Push all characters around you away. Available only if you have deciphered demon runes Veh and Med." :cd 10 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-DEMON-WORD-KNOCKBACK: ~A [~A] uses demon word knockback.~%" (name actor) (id actor))) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear someone chanting~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A pronounces Demon word: Knockback. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((mobs)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (when (get-mob-* (level *world*) dx dy (z actor)) (pushnew (get-mob-* (level *world*) dx dy (z actor)) mobs)))) (loop for target in mobs for dx = (- (x target) (x actor)) for dy = (- (y target) (y actor)) when (eq (check-move-on-level target (+ (x target) dx) (+ (y target) dy) (z target)) t) do (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is pushed away from ~A. " (capitalize-name (prepend-article +article-the+ (visible-name target))) (prepend-article +article-the+ (visible-name actor))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-location target (+ (x target) dx) (+ (y target) dy) (z target)) )) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-demon-word-knockback+) (not (mob-effect-p actor +mob-effect-silence+)) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-away+) (get-inv-items-by-type (inv actor) +item-type-scroll-demonic-rune-transform+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and nearest-enemy (mob-ability-p actor +mob-abil-demon-word-knockback+) (can-invoke-ability actor actor +mob-abil-demon-word-knockback+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-detect-unnatural+ :name "Detect unnatural" :descr "You can sense the general direction to objects of power, like the sacrificial cirle or the Book of Rituals." :passive t :cost 0 :spd 0 :final nil )) (set-ability-type (make-instance 'ability-type :id +mob-abil-throw-corpse-into-portal+ :name "Throw corpses into portal" :descr "Throw all corpses you have into a demonic portal. You must be standing on top of the demonic portal and have corpses in your inventory to do that. Increases your flesh points that count towards victory during demonic raid." :spd (truncate +normal-ap+ 1.5) :passive nil :final t :on-touch nil :motion 90 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (let ((corpses-list (loop for item-id in (inv actor) for item = (get-item-by-id item-id) when (item-ability-p item +item-abil-corpse+) collect item)) (portal (loop for feature-id in (get-features-* (level *world*) (x actor) (y actor) (z actor)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-demonic-portal+) do (return feature)))) (log:info (format nil "MOB-THROW-CORPSE-INTO-PORTAL: ~A [~A] throws the following corpses ~A into portal ~A [~A].~%" (name actor) (id actor) (loop for item in corpses-list collect (format nil "[~A] " (id item))) (name portal) (id portal))) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "You hear something heavy being moved~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A throws corpses into the demonic portal. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop for corpse-item in corpses-list for pts = (item-ability-p corpse-item +item-abil-corpse+) do (if (param1 portal) (incf (param1 portal) (* (qty corpse-item) pts)) (setf (param1 portal) (* (qty corpse-item) pts))) (incf (stat-corpses-thrown actor) (* (qty corpse-item) pts)) (when (eq actor *player*) (incf (cur-score *player*) (* 3 pts (qty corpse-item)))) (setf (inv actor) (remove-from-inv corpse-item (inv actor))) (remove-item-from-world corpse-item)) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-throw-corpse-into-portal+) (eql (mission-type-id (mission (level *world*))) :mission-type-demonic-raid) (loop for item-id in (inv actor) for item = (get-item-by-id item-id) when (item-ability-p item +item-abil-corpse+) collect item) (loop for feature-id in (get-features-* (level *world*) (x actor) (y actor) (z actor)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-demonic-portal+) do (return feature))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (eq (mission-type-id (mission (level *world*))) :mission-type-demonic-raid) (mob-ability-p actor +mob-abil-throw-corpse-into-portal+) (can-invoke-ability actor actor +mob-abil-throw-corpse-into-portal+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-throw-relic-into-portal+ :name "Throw relic into portal" :descr "Throw the relic you have into a demonic portal. You must be standing on top of the demonic portal and have the relic in your inventory to do that. Usable only during the demonic thievery mission." :spd (truncate +normal-ap+ 1.5) :passive nil :final t :on-touch nil :motion 90 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (let ((relic-list (loop for item-id in (inv actor) for item = (get-item-by-id item-id) when (= (item-type item) +item-type-church-reliс+) collect item)) (portal (loop for feature-id in (get-features-* (level *world*) (x actor) (y actor) (z actor)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-demonic-portal+) do (return feature)))) (log:info (format nil "MOB-THROW-RELIC-INTO-PORTAL: ~A [~A] throws the relic ~A into portal ~A [~A].~%" (name actor) (id actor) (loop for item in relic-list collect (format nil "[~A] " (id item))) (name portal) (id portal))) (generate-sound actor (x actor) (y actor) (z actor) 100 #'(lambda (str) (format nil "You hear some buzzing sound~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A throws the relic into the demonic portal. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (loop for relic-item in relic-list do (setf (param1 portal) t) (when (eq actor *player*) (incf (cur-score *player*) (* 200 (qty relic-item)))) (setf (inv actor) (remove-from-inv relic-item (inv actor))) (remove-item-from-world relic-item)) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-throw-relic-into-portal+) (eql (mission-type-id (mission (level *world*))) :mission-type-demonic-thievery) (loop for item-id in (inv actor) for item = (get-item-by-id item-id) when (= (item-type item) +item-type-church-reliс+) collect item) (loop for feature-id in (get-features-* (level *world*) (x actor) (y actor) (z actor)) for feature = (get-feature-by-id feature-id) when (= (feature-type feature) +feature-demonic-portal+) do (return feature))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally nearest-enemy)) (if (and (eq (mission-type-id (mission (level *world*))) :mission-type-demonic-thievery) (mob-ability-p actor +mob-abil-throw-relic-into-portal+) (can-invoke-ability actor actor +mob-abil-throw-relic-into-portal+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-create-demon-sigil+ :name "Summon demonic sigil" :descr (format nil "Summon a demonic sigil next to you. You can not summon sigils closer than ~A tiles to each other. Usable only during the demonic conquest mission." *demonic-conquest-win-sigils-dist*) :spd (truncate +normal-ap+ 1.5) :passive nil :cd 50 :final t :on-touch nil :motion 100 :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) ;; target is (x y z) (log:info (format nil "MOB-CREATE-DEMON-SIGIL: ~A [~A] spawns a demon sigil at (~A ~A ~A).~%" (name actor) (id actor) (first target) (second target) (third target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A creates a demonic sigil. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :observed-mob actor :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (generate-sound actor (x actor) (y actor) (z actor) 60 #'(lambda (str) (format nil "You hear otherworldly sounds~A. " str))) (let ((sigil-mob)) (setf sigil-mob (make-instance 'mob :mob-type +mob-type-demon-sigil+ :x (first target) :y (second target) :z (third target))) (add-mob-to-level-list (level *world*) sigil-mob) (set-mob-effect sigil-mob :effect-type-id +mob-effect-demonic-sigil+ :actor-id (id sigil-mob) :cd t)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (eql (mission-type-id (mission (level *world*))) :mission-type-demonic-conquest) (mob-ability-p actor +mob-abil-create-demon-sigil+) (loop with result = t for sigil-id in (demonic-sigils (level *world*)) for sigil = (get-mob-by-id sigil-id) when (< (get-distance (x actor) (y actor) (x sigil) (y sigil)) *demonic-conquest-win-sigils-dist*) do (setf result nil) (loop-finish) finally (return result))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (let ((final-cell nil)) (check-surroundings (x actor) (y actor) nil #'(lambda (dx dy) (let ((terrain (get-terrain-* (level *world*) dx dy (z actor)))) (when (and terrain (get-terrain-type-trait terrain +terrain-trait-blocks-move-floor+) (not (get-terrain-type-trait terrain +terrain-trait-blocks-move+)) (not (get-mob-* (level *world*) dx dy (z actor)))) (when (null final-cell) (setf final-cell (list dx dy (z actor)))) (when (and nearest-enemy (> (get-distance-3d dx dy (z actor) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)) (get-distance-3d (first final-cell) (second final-cell) (third final-cell) (x nearest-enemy) (y nearest-enemy) (z nearest-enemy)))) (setf final-cell (list dx dy (z actor)))))))) (if (and (mob-ability-p actor +mob-abil-create-demon-sigil+) (can-invoke-ability actor actor +mob-abil-create-demon-sigil+) final-cell) final-cell nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (not (get-mob-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (< (get-distance-3d (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*)) 2) (not (get-terrain-type-trait (get-terrain-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*)) +terrain-trait-blocks-move+))) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (list (view-x *player*) (view-y *player*) (view-z *player*)) ability-type-id) t) (progn nil)) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-skinchange-to-melee+ :name "Skinchange to Butcher" :descr "Change your skin to become a Butcher. The Butcher is a ferocious melee warrior." :cd 15 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-SKINCHANGE-TO-MELEE: ~A [~A] uses skinchange to melee.~%" (name actor) (id actor))) (let ((old-max-hp (max-hp actor)) (was-flyer (if (= (mob-type actor) +mob-type-skinchanger-flyer+) t nil))) (setf (mob-type actor) +mob-type-skinchanger-melee+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear a sound of flesh tearing~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A turns into a Butcher. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (and was-flyer (not (mob-effect-p actor +mob-effect-flying+)) (not (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) (z actor)) +terrain-trait-water+)) (apply-gravity actor)) (set-mob-location actor (x actor) (y actor) (z actor))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-skinchange-to-melee+) ) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (= (z actor) (z nearest-enemy)) (< (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2))) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-skinchange-to-melee+) (can-invoke-ability actor actor +mob-abil-skinchange-to-melee+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-skinchange-to-ranged+ :name "Skinchange to Ravager" :descr "Change your skin to become a Ravager. The Ravager is able to attack from afar." :cd 15 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-SKINCHANGE-TO-RANGED: ~A [~A] uses skinchange to ranged.~%" (name actor) (id actor))) (let ((old-max-hp (max-hp actor)) (was-flyer (if (= (mob-type actor) +mob-type-skinchanger-flyer+) t nil))) (setf (mob-type actor) +mob-type-skinchanger-ranged+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp)) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear a sound of flesh tearing~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A turns into a Ravager. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (when (and was-flyer (not (mob-effect-p actor +mob-effect-flying+)) (not (get-terrain-type-trait (get-terrain-* (level *world*) (x actor) (y actor) (z actor)) +terrain-trait-water+)) (apply-gravity actor)) (set-mob-location actor (x actor) (y actor) (z actor))) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-skinchange-to-ranged+) ) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (/= (z actor) (z nearest-enemy))) (and nearest-enemy (>= (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2) )) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-skinchange-to-ranged+) (can-invoke-ability actor actor +mob-abil-skinchange-to-ranged+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-skinchange-to-flyer+ :name "Skinchange to Corruptor" :descr "Change your skin to become a Corruptor. The Corruptors are able to fly." :cd 15 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-SKINCHANGE-TO-FLYER: ~A [~A] uses skinchange to flyer.~%" (name actor) (id actor))) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-skinchanger-flyer+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear a sound of flesh tearing~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A turns into a Corruptor. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-skinchange-to-flyer+) ) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-skinchange-to-flyer+) (can-invoke-ability actor actor +mob-abil-skinchange-to-flyer+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-skin-ranged-to-turret+ :name "Grow roots and spores" :descr "Evolve to give yourself an ability to skinchange into a Spore colony. The evolution process takes 20 turns. The Spore colony is an immobile creature with a strong ranged attack." :cost 5 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-skinchange-to-turret+ "grows roots and spores")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-evolving+)) (not (mob-ability-p actor +mob-abil-skinchange-to-turret+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-skin-ranged-to-turret+) (can-invoke-ability actor actor +mob-abil-mutate-skin-ranged-to-turret+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-skinchange-to-turret+ :name "Skinchange to Spore colony" :descr "Change your skin to become a Spore colony. The Spore colony is immobile, but has a strong ranged attack." :cd 15 :spd (truncate +normal-ap+ 2) :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target ability-type)) (log:info (format nil "MOB-SKIN-TO-TURRET: ~A [~A] uses skinchange to spore colony.~%" (name actor) (id actor))) (let ((old-max-hp (max-hp actor))) (setf (mob-type actor) +mob-type-skinchanger-turret+) (setf (max-hp actor) (max-hp (get-mob-type-by-id (mob-type actor)))) (setf (cur-hp actor) (round (* (cur-hp actor) (max-hp actor)) old-max-hp))) (setf (face-mob-type-id actor) (mob-type actor)) (set-cur-weapons actor) (adjust-abilities actor) (adjust-dodge actor) (adjust-armor actor) (adjust-m-acc actor) (adjust-r-acc actor) (adjust-sight actor) ;; set up current abilities cooldowns (loop for ability-id in (get-mob-all-abilities actor) when (null (gethash ability-id (abilities-cd actor))) do (setf (gethash ability-id (abilities-cd actor)) 0)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear a sound of flesh tearing~A." str))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A turns into a Spore colony. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (mob-ability-p actor +mob-abil-skinchange-to-turret+) (not (= (mob-type actor) +mob-type-skinchanger-turret+)) (= (mob-type actor) +mob-type-skinchanger-ranged+)) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (or (and nearest-enemy (> (strength nearest-enemy) (strength actor)) (or (/= (z actor) (z nearest-enemy)) (>= (get-distance (x actor) (y actor) (x nearest-enemy) (y nearest-enemy)) 2)))) (null (riding-mob-id actor)) (mob-ability-p actor +mob-abil-skinchange-to-turret+) (can-invoke-ability actor actor +mob-abil-skinchange-to-turret+)) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-charge+ :name "Grow contracting muscles" :descr "Evolve to give yourself an ability to charge to the enemy. The evolution process takes 20 turns." :cost 5 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-charge+ "grows contracting muscles")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-evolving+)) (not (mob-ability-p actor +mob-abil-charge+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-charge+) (can-invoke-ability actor actor +mob-abil-mutate-charge+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-explosive-glands+ :name "Grow exploding glands" :descr "Evolve to give yourself an ability to explode corpses for 6-10 acid dmg. The evolution process takes 20 turns." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-explosive-glands+ "grows exploding glands")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-evolving+)) (not (mob-ability-p actor +mob-abil-explosive-glands+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-explosive-glands+) (can-invoke-ability actor actor +mob-abil-mutate-explosive-glands+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-explosive-glands+ :name "Spit explosive parasite" :descr "You spit a parasite into a corpse. The parasite explodes the corpse to deal 6-10 acid dmg tp everybody nearby. The ability is only available in the Corruptor skin." :cost 0 :cd 7 :spd +normal-ap+ :passive nil :final t :on-touch nil :removes-disguise t :motion 50 :start-map-select-func #'player-start-map-select-corpse :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-SPIT-EXPLOSIVE-PARASITE: ~A [~A] spits parasite at ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A spits an explosive parasite. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A explodes. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((targets nil) (max-range 1)) (draw-fov (x target) (y target) (z target) max-range #'(lambda (dx dy dz prev-cell) (let ((exit-result t)) (block nil (when (> (get-distance-3d (x target) (y target) (z target) dx dy dz) (1+ max-range)) (setf exit-result 'exit) (return)) (when (eq (check-LOS-propagate dx dy dz prev-cell :check-move t) nil) (setf exit-result 'exit) (return)) (place-animation dx dy dz +anim-type-acid-dot+ :params ()) (when (and (get-mob-* (level *world*) dx dy dz)) (pushnew (get-mob-* (level *world*) dx dy dz) targets)) ) exit-result))) (loop for target in targets for cur-dmg = 0 do (incf cur-dmg (inflict-damage target :min-dmg 6 :max-dmg 10 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :no-hit-message t :no-check-dead t :actor actor)) (if (zerop cur-dmg) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A is not hurt. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A takes ~A damage. " (capitalize-name (prepend-article +article-the+ (visible-name target))) cur-dmg) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (when (and (not (eq target actor)) (check-dead target)) (make-dead target :splatter t :msg t :msg-newline nil :killer actor :corpse t :aux-params ()) (when (mob-effect-p target +mob-effect-possessed+) (setf (cur-hp (get-mob-by-id (slave-mob-id target))) 0) (setf (x (get-mob-by-id (slave-mob-id target))) (x target) (y (get-mob-by-id (slave-mob-id target))) (y target) (z (get-mob-by-id (slave-mob-id target))) (z target)) (make-dead (get-mob-by-id (slave-mob-id target)) :splatter nil :msg nil :msg-newline nil :corpse nil :aux-params ())))) (remove-item-from-level-list (level *world*) target) (remove-item-from-world target) ) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-explosive-glands+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy ability-type nearest-ally)) (let ((corpse-item (funcall #'(lambda () (let ((visible-items (copy-list (visible-items actor))) (best-item nil)) ;; find all corpses (setf visible-items (remove-if #'(lambda (a) (if (item-ability-p a +item-abil-corpse+) nil t)) visible-items :key #'get-item-by-id)) ;; find corpse with maximum enemies (and not you) near it (loop for item-id in visible-items for item = (get-item-by-id item-id) for mob-count = 0 for found-self = nil with best-count = 0 do (check-surroundings (x item) (y item) t #'(lambda (dx dy) (let ((mob (get-mob-* (level *world*) dx dy (z item)))) (when (and mob (find (id mob) (visible-mobs actor)) (not (get-faction-relation (faction actor) (get-visible-faction mob :viewer actor)))) (incf mob-count)) (when (eq mob actor) (setf found-self t))))) (when (and (> mob-count best-count) (not found-self)) (setf best-item item) (setf best-count mob-count))) best-item))))) (if (and (mob-ability-p actor +mob-abil-explosive-glands+) (can-invoke-ability actor actor +mob-abil-explosive-glands+) corpse-item) corpse-item nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((items (get-items-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (item-ability-p a +item-abil-corpse+) nil t)) items :key #'get-item-by-id)) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) items (<= (get-distance-3d (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*)) 8) (let ((tx 0) (ty 0) (tz 0) (ex (view-x *player*)) (ey (view-y *player*)) (ez (view-z *player*))) (declare (type fixnum tx ty tz ex ey ez)) (line-of-sight (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let ((exit-result t)) (block nil (setf tx dx ty dy tz dz) (unless (check-LOS-propagate dx dy dz prev-cell :check-projectile t) (setf exit-result 'exit) (return)) ) exit-result))) (if (and (= tx ex) (= ty ey) (= tz ez)) t nil))) (progn (if (> (length items) 1) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A" (capitalize-name (prepend-article +article-a+ (visible-name item))) ))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Explode [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body to explode:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) ;(set-idle-calcing win) (make-output *current-window*) ;(show-time-label (idle-calcing win) (+ 20 (* *glyph-w* *max-x-view*)) (+ 10 237) t) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) t) (progn nil))) ))) (set-ability-type (make-instance 'ability-type :id +mob-abil-mutate-poisoning-glands+ :name "Grow poisoning glands" :descr "Evolve to give yourself an ability to poison corpses. The evolution process takes 20 turns." :cost 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :motion 50 :on-invoke #'(lambda (ability-type actor target) (declare (ignore target)) (generate-sound actor (x actor) (y actor) (z actor) 80 #'(lambda (str) (format nil "You hear some burping~A. " str))) (set-mob-effect actor :effect-type-id +mob-effect-evolving+ :actor-id (id actor) :cd 20 :param1 (list +mob-abil-poisoning-glands+ "grows poisoning glands")) (decf (cur-fp actor) (cost ability-type)) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A starts to evolve. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (and (not (mob-effect-p actor +mob-effect-evolving+)) (not (mob-ability-p actor +mob-abil-poisoning-glands+))) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore ability-type nearest-ally)) (if (and (not nearest-enemy) (mob-ability-p actor +mob-abil-mutate-poisoning-glands+) (can-invoke-ability actor actor +mob-abil-mutate-poisoning-glands+) ) t nil)) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally check-result)) (mob-invoke-ability actor actor (id ability-type))))) (set-ability-type (make-instance 'ability-type :id +mob-abil-poisoning-glands+ :name "Spit poisoning parasite" :descr "You spit a parasite into a corpse. The parasite poisons the corpse and make it emit gas that deals 3-6 acid dmg to that steps into it. The ability is only available in the Corruptor skin." :cost 0 :cd 3 :spd +normal-ap+ :passive nil :final t :on-touch nil :removes-disguise t :motion 50 :start-map-select-func #'player-start-map-select-corpse :on-invoke #'(lambda (ability-type actor target) (declare (ignore ability-type)) (log:info (format nil "MOB-SPIT-POISONING-PARASITE: ~A [~A] spits parasite at ~A [~A] at (~A ~A ~A).~%" (name actor) (id actor) (name target) (id target) (x target) (y target) (z target))) (print-visible-message (x actor) (y actor) (z actor) (level *world*) (format nil "~A spits a poisoning parasite. " (capitalize-name (prepend-article +article-the+ (visible-name actor)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (print-visible-message (x target) (y target) (z target) (level *world*) (format nil "~A starts to emit gas. " (capitalize-name (prepend-article +article-the+ (visible-name target)))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-smoke-acid-gas+ :x (x target) :y (y target) :z (z target) :counter 10)) ) :on-check-applic #'(lambda (ability-type actor target) (declare (ignore ability-type target)) (if (mob-ability-p actor +mob-abil-poisoning-glands+) t nil)) :on-check-ai #'(lambda (ability-type actor nearest-enemy nearest-ally) (declare (ignore nearest-enemy ability-type nearest-ally)) (let ((corpse-item (funcall #'(lambda () (let ((visible-items (copy-list (visible-items actor))) (best-item nil)) ;; find all corpses (setf visible-items (remove-if #'(lambda (a) (if (item-ability-p a +item-abil-corpse+) nil t)) visible-items :key #'get-item-by-id)) ;; find corpse with an enemy (and not you) above it (loop for item-id in visible-items for item = (get-item-by-id item-id) for mob = (get-mob-* (level *world*) (x item) (y item) (z item)) for found-self = nil do (when (and mob (find (id mob) (visible-mobs actor)) (not (get-faction-relation (faction actor) (get-visible-faction mob :viewer actor))) (not (eq mob actor))) (setf best-item item)) ) best-item))))) (if (and (mob-ability-p actor +mob-abil-poisoning-glands+) (can-invoke-ability actor actor +mob-abil-poisoning-glands+) corpse-item) corpse-item nil)) ) :on-invoke-ai #'(lambda (ability-type actor nearest-enemy nearest-ally check-result) (declare (ignore nearest-enemy nearest-ally)) (mob-invoke-ability actor check-result (id ability-type))) :map-select-func #'(lambda (ability-type-id) (let ((items (get-items-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) (exit-result nil)) (setf items (remove-if #'(lambda (a) (if (item-ability-p a +item-abil-corpse+) nil t)) items :key #'get-item-by-id)) (if (and (get-single-memo-visibility (get-memo-* (level *world*) (view-x *player*) (view-y *player*) (view-z *player*))) items (<= (get-distance-3d (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*)) 8) (let ((tx 0) (ty 0) (tz 0) (ex (view-x *player*)) (ey (view-y *player*)) (ez (view-z *player*))) (declare (type fixnum tx ty tz ex ey ez)) (line-of-sight (x *player*) (y *player*) (z *player*) (view-x *player*) (view-y *player*) (view-z *player*) #'(lambda (dx dy dz prev-cell) (declare (type fixnum dx dy dz)) (let ((exit-result t)) (block nil (setf tx dx ty dy tz dz) (unless (check-LOS-propagate dx dy dz prev-cell :check-projectile t) (setf exit-result 'exit) (return)) ) exit-result))) (if (and (= tx ex) (= ty ey) (= tz ez)) t nil))) (progn (if (> (length items) 1) (progn (let ((item-line-list nil) (item-prompt-list) (item-list (copy-list items))) (setf item-line-list (loop for item-id in item-list for item = (get-item-by-id item-id) collect (format nil "~A" (capitalize-name (prepend-article +article-a+ (visible-name item))) ))) ;; populate the ability prompt list (setf item-prompt-list (loop for item-id in item-list collect #'(lambda (cur-sel) (declare (ignore cur-sel)) "[Enter] Poison [Escape] Cancel"))) ;; show selection window (setf *current-window* (make-instance 'select-obj-window :return-to *current-window* :header-line "Choose a body to poison:" :enter-func #'(lambda (cur-sel) (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-inv-item-by-pos item-list cur-sel) ability-type-id) (setf *current-window* (return-to (return-to (return-to *current-window*)))) ;(set-idle-calcing win) (make-output *current-window*) ;(show-time-label (idle-calcing win) (+ 20 (* *glyph-w* *max-x-view*)) (+ 10 237) t) (setf exit-result t)) :line-list item-line-list :prompt-list item-prompt-list)) (make-output *current-window*) (run-window *current-window*)) exit-result) (progn (clear-message-list (level/small-message-box (level *world*))) (mob-invoke-ability *player* (get-item-by-id (first items)) ability-type-id) t)) t) (progn nil))) )))
844,050
Common Lisp
.lisp
7,830
45.832439
692
0.318416
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
baf663280bbd48fef90b17a083d1833772bf9c030e28499247993007edbc962a
2,890
[ -1 ]
2,891
init-terrain-types.lisp
gwathlobal_CotD/src/init-terrain-types.lisp
(in-package :cotd) ;;-------------------- ;; TERRAIN-TEMPLATE Declarations ;;-------------------- ;;-------------------- ;; Borders ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-border-floor+ :name "dirt" :glyph-idx 95 :glyph-color (sdl:color :r 205 :g 103 :b 63) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision t :trait-blocks-vision-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-blocks-sound t :trait-blocks-sound-floor t :trait-not-climable t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-border-floor-snow+ :name "snow" :glyph-idx 95 :glyph-color sdl:*white* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision t :trait-blocks-vision-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-not-climable t :trait-blocks-sound t :trait-blocks-sound-floor t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-border-water+ :name "water" :glyph-idx +glyph-id-tilda+ :glyph-color sdl:*blue* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-blocks-sound 10 :trait-blocks-sound-floor 10 :trait-not-climable t :trait-water t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-border-grass+ :name "grass" :glyph-idx 95 :glyph-color (sdl:color :r 0 :g 100 :b 0) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision t :trait-blocks-vision-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-not-climable t :trait-blocks-sound t :trait-blocks-sound-floor t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-border-air+ :name "air" :glyph-idx 96 :glyph-color sdl:*cyan* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-not-climable t :trait-blocks-sound t :trait-blocks-sound-floor t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-border-creep+ :name "creep" :glyph-idx 95 :glyph-color (sdl:color :r 100 :g 0 :b 100) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision t :trait-blocks-vision-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-blocks-sound t :trait-blocks-sound-floor t :trait-not-climable t)) ;;-------------------- ;; Floors ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-stone+ :name "stone floor" :glyph-idx +glyph-id-solid-floor+ :glyph-color (sdl:color :r 200 :g 200 :b 200) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-glass+ :name "transparent floor" :glyph-idx +glyph-id-solid-floor+ :glyph-color sdl:*cyan* :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-grass+ :name "grass" :glyph-idx 95 :glyph-color (sdl:color :r 0 :g 100 :b 0) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 3)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-dirt+ :name "dirt" :glyph-idx 95 :glyph-color (sdl:color :r 205 :g 103 :b 63) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-dirt-bright+ :name "dirt" :glyph-idx 95 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-snow+ :name "snow" :glyph-idx 95 :glyph-color sdl:*white* :back-color sdl:*black* :on-step #'(lambda (mob x y z) (when (not (mob-ability-p mob +mob-abil-float+)) (set-terrain-* (level *world*) x y z +terrain-floor-snow-prints+))) :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-snow-prints+ :name "snow" :glyph-idx 95 :glyph-color (sdl:color :r 80 :g 80 :b 155) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-bridge+ :name "bridge" :glyph-idx 96 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 10)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-pier+ :name "pier" :glyph-idx 96 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 10)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-ash+ :name "ash" :glyph-idx 95 :glyph-color (sdl:color :r 70 :g 70 :b 70) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-sign-church-catholic+ :name "sign \"The Catholic Church of the One\"" :glyph-idx 122 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-sign-church-orthodox+ :name "sign \"The Orthodox Church of the One\"" :glyph-idx 122 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-sign-library+ :name "sign \"The Library of His Imperial Majesty\"" :glyph-idx 122 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-sign-prison+ :name "sign \"City Prison\"" :glyph-idx 122 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-sign-bank+ :name "sign \"Bank of Morozov and Sons\"" :glyph-idx 122 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep+ :name "creep" :glyph-idx 95 :glyph-color (sdl:color :r 100 :g 0 :b 100) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep-bright+ :name "creep" :glyph-idx 95 :glyph-color (sdl:color :r 255 :g 0 :b 255) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep-dreadtubes+ :name "dreadtubes" :glyph-idx 129 :glyph-color (sdl:color :r 105 :g 50 :b 255) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :on-step #'(lambda (mob x y z) (when (< (random 100) 20) (generate-sound mob (x mob) (y mob) (z mob) 100 #'(lambda (str) (format nil "You hear an eerie howl~A. " str))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Dreadtubes give off an eerie howl under ~A. " (prepend-article +article-the+ (visible-name mob))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (let ((mob)) (check-surroundings x y t #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (terrain (level *world*)) 0)) (< dy (array-dimension (terrain (level *world*)) 1)) (get-mob-* (level *world*) dx dy z)) (setf mob (get-mob-* (level *world*) dx dy z)) (if (> (random (+ (strength mob) 5)) (strength mob)) (progn (set-mob-effect mob :effect-type-id +mob-effect-fear+ :actor-id (id mob) :cd 4) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A is feared. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))) (progn (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "~A resists fear. " (capitalize-name (prepend-article +article-the+ (visible-name mob)))) :observed-mob mob :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind)))))) ))) )))) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep-spores+ :name "sludgeshrooms" :glyph-idx 130 :glyph-color (sdl:color :r 155 :g 50 :b 0) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :on-step #'(lambda (mob x y z) (when (< (random 100) 20) (generate-sound mob (x mob) (y mob) (z mob) 100 #'(lambda (str) (format nil "You hear a hissing sound~A. " str))) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Sludgeshrooms release spores under ~A. " (prepend-article +article-the+ (visible-name mob))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (check-surroundings x y t #'(lambda (dx dy) (when (and (>= dx 0) (>= dy 0) (< dx (array-dimension (terrain (level *world*)) 0)) (< dy (array-dimension (terrain (level *world*)) 1)) (and (not (get-terrain-type-trait (get-terrain-* (level *world*) dx dy z) +terrain-trait-blocks-move+)) (not (get-terrain-type-trait (get-terrain-* (level *world*) dx dy z) +terrain-trait-blocks-projectiles+)))) (add-feature-to-level-list (level *world*) (make-instance 'feature :feature-type +feature-corrupted-spores+ :x dx :y dy :z z :counter 2)) ) )))))) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep-irradiated+ :name "glowing creep" :glyph-idx 95 :glyph-color (sdl:color :r 200 :g 50 :b 100) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :on-step #'(lambda (mob x y z) (declare (ignore x y z)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Sinister glow irradiates ~A. " (prepend-article +article-the+ (visible-name mob))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (if (mob-effect-p mob +mob-effect-irradiated+) (progn (let ((effect (get-effect-by-id (mob-effect-p mob +mob-effect-irradiated+)))) (when (<= (param1 effect) 5) (incf (param1 effect) (+ 2 (random 2)))))) (progn (set-mob-effect mob :effect-type-id +mob-effect-irradiated+ :actor-id nil :cd t :param1 (+ 2 (random 3)))))))) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-slime+ :name "slime" :glyph-idx +glyph-id-tilda+ :glyph-color sdl:*yellow* :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :on-step #'(lambda (mob x y z) (declare (ignore x y z)) (print-visible-message (x mob) (y mob) (z mob) (level *world*) (format nil "Slime envelops ~A. " (prepend-article +article-the+ (visible-name mob))) :color sdl:*white* :tags (list (when (if-cur-mob-seen-through-shared-vision *player*) :singlemind))) (set-mob-effect mob :effect-type-id +mob-effect-reduce-resitances+ :actor-id nil :cd 6)))) ;;-------------------- ;; Walls ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-stone+ :name "stone wall" :glyph-idx +glyph-id-wall+ :glyph-color sdl:*white* :back-color sdl:*white* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 25 :trait-blocks-sound-floor 20 :trait-blocks-move-floor t :trait-can-have-rune t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-barricade+ :name "barricade" :glyph-idx +glyph-id-hash+ :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 10 :trait-can-jump-over t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-earth+ :name "earth" :glyph-idx +glyph-id-wall+ :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color (sdl:color :r 185 :g 83 :b 43) :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 40 :trait-blocks-sound-floor 40)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-compressed-bones+ :name "compressed bones" :glyph-idx +glyph-id-wall+ :glyph-color (sdl:color :r 189 :g 183 :b 107) :back-color (sdl:color :r 189 :g 183 :b 107) :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 40 :trait-blocks-sound-floor 40)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-raw-flesh+ :name "raw flesh" :glyph-idx +glyph-id-percent+ :glyph-color sdl:*magenta* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 20 :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-bush+ :name "bush" :glyph-idx +glyph-id-hash+ :glyph-color sdl:*green* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 3 :trait-can-jump-over t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-grave+ :name "grave" :glyph-idx 121 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-can-jump-over t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-gloomtwigs+ :name "gloomtwigs" :glyph-idx +glyph-id-hash+ :glyph-color (sdl:color :r 255 :g 0 :b 255) :back-color sdl:*black* :trait-blocks-vision 60 :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-corrupted+ :name "bone wall" :glyph-idx +glyph-id-wall+ :glyph-color (sdl:color :r 189 :g 183 :b 107) :back-color (sdl:color :r 189 :g 183 :b 107) :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 25 :trait-blocks-sound-floor 20 :trait-can-have-rune t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-razorthorns+ :name "razorthorns" :glyph-idx +glyph-id-hash+ :glyph-color (sdl:color :r 100 :g 0 :b 0) :back-color sdl:*black* :trait-blocks-vision 60 :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :on-step #'(lambda (mob x y z) (declare (ignore x y z)) (inflict-damage mob :min-dmg 1 :max-dmg 1 :dmg-type +weapon-dmg-acid+ :att-spd nil :weapon-aux () :acc 100 :add-blood t :no-dodge t :actor nil :no-hit-message t :specific-hit-string-func #'(lambda (cur-dmg) (format nil "~A takes ~A damage from razorthorns. " (capitalize-name (name mob)) cur-dmg)) :specific-no-dmg-string-func #'(lambda () (format nil "~A takes no damage from razorthorns. " (capitalize-name (name mob))))) (when (check-dead mob) (when (eq mob *player*) (setf (killed-by *player*) "razorthorns")))))) ;;-------------------- ;; Trees ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-birch+ :name "young birch tree" :glyph-idx 52 :glyph-color sdl:*green* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-birch-snow+ :name "snow-covered birch tree" :glyph-idx 52 :glyph-color sdl:*white* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-branches+ :name "tree branch" :glyph-idx 3 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-projectiles-floor t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-leaves+ :name "tree leaves" :glyph-idx 3 :glyph-color sdl:*green* :back-color sdl:*black* :trait-blocks-vision 60)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-leaves-snow+ :name "snow-covered tree leaves" :glyph-idx 3 :glyph-color sdl:*white* :back-color sdl:*black* :trait-blocks-vision 60)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-birch-trunk+ :name "mature birch" :glyph-idx 16 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 10 :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-oak-trunk-nw+ :name "mature oak" :glyph-idx 104 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 15 :trait-blocks-sound-floor 15)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-oak-trunk-ne+ :name "mature oak" :glyph-idx 105 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 15 :trait-blocks-sound-floor 15)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-oak-trunk-se+ :name "mature oak" :glyph-idx 106 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 15 :trait-blocks-sound-floor 15)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-oak-trunk-sw+ :name "mature oak" :glyph-idx 107 :glyph-color (sdl:color :r 185 :g 83 :b 43) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 15 :trait-blocks-sound-floor 15)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-twintube+ :name "young twintube" :glyph-idx 57 :glyph-color (sdl:color :r 255 :g 0 :b 255) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-blocks-move-floor t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-tree-twintube-trunk+ :name "mature twintube" :glyph-idx 16 :glyph-color (sdl:color :r 100 :g 0 :b 100) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 10 :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-twintube-branches+ :name "twintube branch" :glyph-idx 3 :glyph-color (sdl:color :r 100 :g 0 :b 100) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-projectiles-floor t)) ;;-------------------- ;; Furniture ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-chair+ :name "chair" :glyph-idx 100 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 6)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-table+ :name "table" :glyph-idx 101 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 10 :trait-can-jump-over t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-bed+ :name "bed" :glyph-idx 102 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 12 :trait-can-jump-over t)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-cabinet+ :name "cabinet" :glyph-idx 103 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 8)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-crate+ :name "crate" :glyph-idx 103 :glyph-color (sdl:color :r 112 :g 128 :b 144) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-bookshelf+ :name "bookshelf" :glyph-idx 103 :glyph-color (sdl:color :r 165 :g 42 :b 42) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-vision t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20 :trait-flammable 8)) ;;-------------------- ;; Doors & Windows ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-window+ :name "window" :glyph-idx 13 :glyph-color (sdl:color :r 0 :g 0 :b 200) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-projectiles t :trait-blocks-projectiles-floor t :trait-blocks-vision 30 :trait-blocks-vision-floor t :trait-blocks-sound 20 :trait-blocks-sound-floor 20 :trait-openable-window t :on-use #'(lambda (mob x y z) ;; TODO: add connections change for size 3 (set-terrain-* (level *world*) x y z +terrain-wall-window-opened+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-walk+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-walk+)) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-climb+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-climb+)) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-fly+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-fly+)) ) :on-bump-terrain #'(lambda (mob x y z) (if (and (mob-ability-p mob +mob-abil-open-close-window+) (can-invoke-ability mob mob +mob-abil-open-close-window+) (= (get-terrain-* (level *world*) x y z) +terrain-wall-window+)) (progn (mob-invoke-ability mob (list x y z) +mob-abil-open-close-window+) t) nil)))) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-window-opened+ :name "opened window" :glyph-idx 15 :glyph-color (sdl:color :r 0 :g 0 :b 200) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 10 :trait-openable-window t :on-use #'(lambda (mob x y z) (declare (ignore mob)) (set-terrain-* (level *world*) x y z +terrain-wall-window+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-walk+ +connect-room-none+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-climb+ +connect-room-none+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-fly+ +connect-room-none+) ))) (set-terrain-type (make-instance 'terrain-type :id +terrain-door-open+ :name "open door" :glyph-idx 7 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 10 :trait-openable-door t :on-use #'(lambda (mob x y z) (declare (ignore mob)) (set-terrain-* (level *world*) x y z +terrain-door-closed+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-walk+ +connect-room-none+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-climb+ +connect-room-none+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-fly+ +connect-room-none+) (let ((func #'(lambda (&key map-size move-mode) (let ((room-id-list nil)) (check-surroundings x y nil #'(lambda (dx dy) (when (/= (get-level-connect-map-value (level *world*) dx dy z map-size move-mode) +connect-room-none+) (pushnew (get-level-connect-map-value (level *world*) dx dy z map-size move-mode) room-id-list)))) (loop for room-id-start in room-id-list do (loop for room-id-end in room-id-list do (when (/= room-id-start room-id-end) (set-aux-map-connection (level *world*) room-id-start room-id-end map-size move-mode :delta-potential 0 :delta-actual -1)))))))) (funcall func :map-size 1 :move-mode +connect-map-move-walk+) (funcall func :map-size 1 :move-mode +connect-map-move-climb+) (funcall func :map-size 1 :move-mode +connect-map-move-fly+) ) ))) (set-terrain-type (make-instance 'terrain-type :id +terrain-door-closed+ :name "closed door" :glyph-idx 11 :glyph-color (sdl:color :r 139 :g 69 :b 19) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-vision t :trait-blocks-projectiles-floor t :trait-blocks-projectiles t :trait-blocks-sound 15 :trait-blocks-sound-floor 20 :trait-openable-door t :on-use #'(lambda (mob x y z) ;; TODO: add connections change for size 3 (set-terrain-* (level *world*) x y z +terrain-door-open+) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-walk+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-walk+)) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-climb+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-climb+)) (set-connect-map-value (aref (connect-map (level *world*)) 1) x y z +connect-map-move-fly+ (get-connect-map-value (aref (connect-map (level *world*)) 1) (x mob) (y mob) (z mob) +connect-map-move-fly+)) (let ((func #'(lambda (&key map-size move-mode) (let ((room-id-list nil)) (check-surroundings x y nil #'(lambda (dx dy) (when (/= (get-level-connect-map-value (level *world*) dx dy z map-size move-mode) +connect-room-none+) (pushnew (get-level-connect-map-value (level *world*) dx dy z map-size move-mode) room-id-list)))) (loop for room-id-start in room-id-list do (loop for room-id-end in room-id-list do (when (/= room-id-start room-id-end) (set-aux-map-connection (level *world*) room-id-start room-id-end map-size move-mode :delta-potential 0 :delta-actual 1)))))))) (funcall func :map-size 1 :move-mode +connect-map-move-walk+) (funcall func :map-size 1 :move-mode +connect-map-move-climb+) (funcall func :map-size 1 :move-mode +connect-map-move-fly+) ) ) :on-bump-terrain #'(lambda (mob x y z) (if (and (mob-ability-p mob +mob-abil-open-close-door+) (can-invoke-ability mob mob +mob-abil-open-close-door+) (= (get-terrain-* (level *world*) x y z) +terrain-door-closed+)) (progn (mob-invoke-ability mob (list x y z) +mob-abil-open-close-door+) t) nil)))) ;;-------------------- ;; Water & Ice ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-water-liquid+ :name "water" :glyph-idx +glyph-id-tilda+ :glyph-color sdl:*blue* :back-color sdl:*black* :trait-not-climable t :trait-blocks-sound-floor 10 :trait-blocks-sound 10 :trait-water t :trait-move-cost-factor *water-move-factor* :on-step #'(lambda (mob x y z) (declare (ignore x y z)) (set-mob-effect mob :effect-type-id +mob-effect-wet+ :actor-id (id mob) :cd 4)))) (set-terrain-type (make-instance 'terrain-type :id +terrain-water-ice+ :name "ice" :glyph-idx +glyph-id-tilda+ :glyph-color (sdl:color :r 0 :g 150 :b 255) :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound-floor 20)) (set-terrain-type (make-instance 'terrain-type :id +terrain-water-liquid-nofreeze+ :name "water" :glyph-idx +glyph-id-tilda+ :glyph-color sdl:*blue* :back-color sdl:*black* :trait-blocks-sound-floor 10 :trait-blocks-sound 10 :trait-water t :trait-move-cost-factor *water-move-factor* :on-step #'(lambda (mob x y z) (declare (ignore x y z)) (set-mob-effect mob :effect-type-id +mob-effect-wet+ :actor-id (id mob) :cd 4)))) (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-ice+ :name "ice" :glyph-idx +glyph-id-wall+ :glyph-color (sdl:color :r 0 :g 150 :b 255) :back-color (sdl:color :r 0 :g 150 :b 255) :trait-blocks-move t :trait-blocks-projectiles t :trait-blocks-move-floor t :trait-blocks-projectiles-floor t :trait-blocks-sound 25 :trait-blocks-sound-floor 20)) ;;-------------------- ;; Air ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-air+ :name "air" :glyph-idx 96 :glyph-color sdl:*cyan* :back-color sdl:*black* )) ;;-------------------- ;; Slopes ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-slope-stone-up+ :name "slope up" :glyph-idx 118 :glyph-color sdl:*white* :back-color sdl:*black* :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-slope-up t :trait-blocks-sound-floor 10)) (set-terrain-type (make-instance 'terrain-type :id +terrain-slope-stone-down+ :name "slope down" :glyph-idx 119 :glyph-color sdl:*white* :back-color sdl:*black* :trait-slope-down t)) ;;-------------------- ;; Light sources ;;-------------------- (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-lantern+ :name "lantern" :glyph-idx 92 :glyph-color sdl:*yellow* :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-light-source 6 :trait-can-switch-light t :trait-blocks-sound 20 :trait-blocks-sound-floor 20 :on-use #'(lambda (mob x y z) (declare (ignore mob)) (set-terrain-* (level *world*) x y z +terrain-wall-lantern-off+) (loop for (nx ny nz light-radius) in (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10)) for i from 0 below (length (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10))) when (and (= x nx) (= y ny) (= z nz)) do (setf (fourth (nth i (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10)))) (get-terrain-type-trait +terrain-wall-lantern-off+ +terrain-trait-light-source+)) (loop-finish)) ) :on-bump-terrain #'(lambda (mob x y z) (if (and (mob-ability-p mob +mob-abil-toggle-light+) (can-invoke-ability mob mob +mob-abil-toggle-light+) (= (get-terrain-* (level *world*) x y z) +terrain-wall-lantern+)) (progn (mob-invoke-ability mob (list x y z) +mob-abil-toggle-light+) t) nil)))) ;; light sources that are off, but can be toggled on - should have the +terrain-trait-light-source+ set to 0, as opposed to non-light-sources, where it is set to nil (set-terrain-type (make-instance 'terrain-type :id +terrain-wall-lantern-off+ :name "lantern (off)" :glyph-idx 92 :glyph-color (sdl:color :r 150 :g 150 :b 150) :back-color sdl:*black* :trait-blocks-move t :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-light-source 0 :trait-can-switch-light t :trait-blocks-sound 20 :trait-blocks-sound-floor 20 :on-use #'(lambda (mob x y z) (declare (ignore mob)) (set-terrain-* (level *world*) x y z +terrain-wall-lantern+) (loop for (nx ny nz light-radius) in (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10)) for i from 0 below (length (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10))) when (and (= x nx) (= y ny) (= z nz)) do (setf (fourth (nth i (aref (light-quadrant-map (level *world*)) (truncate x 10) (truncate y 10)))) (get-terrain-type-trait +terrain-wall-lantern+ +terrain-trait-light-source+)) (loop-finish))) :on-bump-terrain #'(lambda (mob x y z) (if (and (mob-ability-p mob +mob-abil-toggle-light+) (can-invoke-ability mob mob +mob-abil-toggle-light+) (= (get-terrain-* (level *world*) x y z) +terrain-wall-lantern-off+)) (progn (mob-invoke-ability mob (list x y z) +mob-abil-toggle-light+) t) nil)))) (set-terrain-type (make-instance 'terrain-type :id +terrain-floor-creep-glowshroom+ :name "glowshroom" :glyph-idx 130 :glyph-color sdl:*yellow* :back-color sdl:*black* :trait-blocks-move nil :trait-blocks-move-floor t :trait-blocks-vision-floor t :trait-blocks-projectiles-floor t :trait-light-source 4 :trait-can-switch-light nil :trait-blocks-sound-floor 20))
60,087
Common Lisp
.lisp
489
70.378323
241
0.42168
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
f71a07ffe99b581aaf0cdb82483b7c5c37e7ffbb2d4989c8d8130ce310b37ff8
2,891
[ -1 ]
2,892
init-hell-building-types.lisp
gwathlobal_CotD/src/buildings/init-hell-building-types.lisp
(in-package :cotd) ;;===================== ;; Structure ;;===================== (set-building-type (make-building :id +building-city-hell-structure-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-structure+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,XX,,````" ",X,,X,,,,`" ",,,,,,,X,," "````,,,,X," "````,XXX,," "``,,,,,,,`" "`,,XX,,X,`" "`,X,,XX,,`" "`,,,,,,,``")) (build-template-z-3 (list " " " `` " " X X " " X " " ` " " X`` " " " " `` X " " X `` " " ")) (build-template-z-4 (list " " " " " , , " " , " " " " , " " " " , " " , " " "))) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-structure-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-structure+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "00000u0000" "0000,,,000" "0000,,,000" "00000u0000" "0000000000" "000,,00000" "00u,,u0000" "000,,00000" "0000000000")) (build-template-z-2 (list "```````,,," "``,,,d`,X," ",,,X ,,," ",XX, ```" ",X,,`d,,,`" ",X,,``,X,," ",,X `,,X," "`,d d,,,," "``` `,X,`" "``````,,,`")) (build-template-z-3 (list " " " X " " X " " ,X " " , " " , , " " , , " " " " X " " ")) (build-template-z-4 (list " " " , " " , " " , " " " " " " " " " " , " " "))) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-structure-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-structure+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "````,,,```" "`,,,,X,,``" "`,X,,,X,,`" "`,X,,,XX,," "`,,X,X,,X," "`,X,X,,,,," "`,,X,X,,,," ",,X,,XX,X," ",X,`,,XX,," ",,,``,,,,`")) (build-template-z-3 (list " " " , " " , , " " , ,, " " , , , " " , , " " , , " " , ,, , " " , ,, " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-structure-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-structure+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "000,,00000" "00,,,,0000" "0u,,,,,000" "00,,,u0000" "000,,00000" "0000000000" "0000000000" "0000000000" "0000000000")) (build-template-z-2 (list "``````,,,," "``` `,XX," "`` ,X,," "`d ,,," "`` d`,X," "`,, `,,X," "`,X,,`,XX," "`,,X,,X,,," "``,,XXX,``" "```,,,,,``")) (build-template-z-3 (list " " " ,, " " , " " " " , " " , " " , ,, " " , , " " ,,, " " ")) ) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Growth ;;===================== (set-building-type (make-building :id +building-city-hell-outgrowth-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,,```" "```T````T`" "`T```T````" "``````T`,," "``T`````,," ",````T````" ",```````T`" ",`````````" ",,`T``T`,," ",,``````,,"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-outgrowth-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,```," "```T```T`," "`T```T````" "```T``````" "`T````T```" "````T```,," ",`T```T`,," ",`````````" ",`T`T`,`T`" ",`````,```"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-outgrowth-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-growth+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place a large twintube tree (let ((dx (random 8)) (dy (random 8)) (r (random 5))) (cond ((= r 4) (level-place-twintube-corrupted-4 template-level (+ dx x) (+ dy y) z)) ((= r 3) (level-place-twintube-corrupted-3 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-twintube-corrupted-2 template-level (+ dx x) (+ dy y) z)) ((= r 1) (level-place-twintube-corrupted-1 template-level (+ dx x) (+ dy y) z)) (t nil)) ) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-creep+)))))) ;; find a place to position citizens (values nil nil nil) ))) (set-building-type (make-building :id +building-city-hell-outgrowth-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-growth+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-creep+)))))) ;; place a large oak tree (let ((dx (random 8)) (dy (random 8))) (cond (t (level-place-twintube-mutated-1 template-level (+ dx x) (+ dy y) z))) ) ;; find a place to position citizens (values nil nil nil) ))) ;;===================== ;; Border ;;===================== (set-building-type (make-building :id +building-city-hell-border+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (if (zerop (random 5)) (progn ;; place a large birch tree (let ((r (random 4))) (cond ((= r 3) (level-place-twintube-corrupted-4 template-level (+ 1 x) (+ 1 y) z)) ((= r 2) (level-place-twintube-corrupted-3 template-level (+ 1 x) (+ 1 y) z)) ((= r 1) (level-place-twintube-corrupted-2 template-level (+ 1 x) (+ 1 y) z)) (t (level-place-twintube-corrupted-1 template-level (+ 1 x) (+ 1 y) z))) ) (values nil nil) ) (progn ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than two adjacent trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 2) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place grass around trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (if (or (= (aref template-level x y z) +terrain-border-floor+) (= (aref template-level x y z) +terrain-border-grass+) (= (aref template-level x y z) +terrain-border-creep+)) (setf (aref template-level x y z) +terrain-border-creep+) (setf (aref template-level x y z) +terrain-floor-creep+))))))) (values nil nil nil)))) )) ;;===================== ;; Structure-Growth ;;===================== (set-building-type (make-building :id +building-city-hell-struct-growth-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-struct-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,``,,````" ",,`,X,,,,`" ",,,X,,X`,," "````X,,,`," "```X,```,," "``,,,,,,,`" "`T,``,T`,`" "`,`,T``,,`" "`,,,,,,,``")) (build-template-z-3 (list " " " " " , " " , , " " , " " , " " " " " " " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-struct-growth-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-struct-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,``,,````" ",,`,X,,,,`" ",,,X,,X`,," "````X,,,`," "```X,```,," "``,,,,,,,`" "`T,``,T`,`" "`,`,T``,,`" "`,,,,,,,``")) (build-template-z-3 (list " " " " " , " " , , " " , " " , " " " " " " " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-struct-growth-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-struct-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,``,,T```" ",,`T`,,,,`" ",,,`,,``T," "`````,,,`," "````X```,," "``,XX,,,,`" "``X``XX`,`" "`,`,```X,`" "`,,,,,,,``")) (build-template-z-3 (list " " " " " " " " " " " , " " ,, " " , ,, " " , " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-struct-growth-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-struct-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,`T,,````" ",,```,,,,`" ",,,`,,`X`," "`T```,X,X," "````````X," "``,T`,,,,`" "``````X`,`" "`T`,````,`" "`,,,,,,,``")) (build-template-z-3 (list " " " " " " " , " " , , " " , " " " " , " " " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-struct-growth-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-struct-growth+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "`,,,,`````" ",,``,,````" ",X`X`,,T,`" ",,X`,,```," "``X``,`,T," "`````````," "``X``,T,,`" "````````,`" "```X````,`" "`,,,,,,,``")) (build-template-z-3 (list " " " " " , , " " , " " , " " " " , " " " " , " " ")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Machine ;;===================== (set-building-type (make-building :id +building-city-hell-machine-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-machine+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "0XXXXXXXX0" "0X......X0" "0X......X0" "0X..uu..X0" "0X..XX..X0" "0X......X0" "0X......X0" "0XXXXXXXX0" "0000000000")) (build-template-z-2 (list "```````,,," "`XXXXXXXX," ",X......X," ",X......X`" ",X..dd..X`" ",XX....XX," ",X......X," "`X......X," "`XXX..XXX`" "``````,,,`")) (build-template-z-3 (list " " " ........ " " .XXXXXX. " " .X X. " " .X X. " " .X X. " " .X X. " " .XXXXXX. " " ........ " " ")) (build-template-z-4 (list " " " " " ...... " " .XXXX. " " .X X. " " .X X. " " .XXXX. " " ...... " " " " ")) (build-template-z-5 (list " " " " " " " .... " " .... " " .... " " .... " " " " " " "))) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (values nil (list (list +feature-start-machine-point+ 4 7 (- z 1)) (list +feature-start-sigil-point+ 4 2 (- z 1))) nil)))) (set-building-type (make-building :id +building-city-hell-machine-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-machine+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "0XXXXXXXX0" "0X......X0" "0X......X0" "0X..XX..X0" "0X..uu..X0" "0X......X0" "0X......X0" "0XXXXXXXX0" "0000000000")) (build-template-z-2 (list "```````,,," "`XXX..XXX," ",X......X," ",X......X`" ",XX....XX`" ",X..dd..X," ",X......X," "`X......X," "`XXXXXXXX`" "``````,,,`")) (build-template-z-3 (list " " " ........ " " .XXXXXX. " " .X X. " " .X X. " " .X X. " " .X X. " " .XXXXXX. " " ........ " " ")) (build-template-z-4 (list " " " " " ...... " " .XXXX. " " .X X. " " .X X. " " .XXXX. " " ...... " " " " ")) (build-template-z-5 (list " " " " " " " .... " " .... " " .... " " .... " " " " " " "))) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (values nil (list (list +feature-start-machine-point+ 4 2 (- z 1)) (list +feature-start-sigil-point+ 4 7 (- z 1))) nil)))) (set-building-type (make-building :id +building-city-hell-machine-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-machine+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "0XXXXXXXX0" "0X......X0" "0X......X0" "0X..uX..X0" "0X..uX..X0" "0X......X0" "0X......X0" "0XXXXXXXX0" "0000000000")) (build-template-z-2 (list "```````,,," "`XXXXXXXX," ",X......X," ",X......X`" ",X..d....`" ",X..d....," ",X......X," "`X......X," "`XXXXXXXX`" "``````,,,`")) (build-template-z-3 (list " " " ........ " " .XXXXXX. " " .X X. " " .X X. " " .X X. " " .X X. " " .XXXXXX. " " ........ " " ")) (build-template-z-4 (list " " " " " ...... " " .XXXX. " " .X X. " " .X X. " " .XXXX. " " ...... " " " " ")) (build-template-z-5 (list " " " " " " " .... " " .... " " .... " " .... " " " " " " "))) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (values nil (list (list +feature-start-machine-point+ 7 4 (- z 1)) (list +feature-start-sigil-point+ 2 4 (- z 1))) nil)))) (set-building-type (make-building :id +building-city-hell-machine-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-hell-machine+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "0000000000" "0XXXXXXXX0" "0X......X0" "0X......X0" "0X..Xu..X0" "0X..Xu..X0" "0X......X0" "0X......X0" "0XXXXXXXX0" "0000000000")) (build-template-z-2 (list "```````,,," "`XXXXXXXX," ",X......X," ",X......X`" ",....d..X`" ",....d..X," ",X......X," "`X......X," "`XXXXXXXX`" "``````,,,`")) (build-template-z-3 (list " " " ........ " " .XXXXXX. " " .X X. " " .X X. " " .X X. " " .X X. " " .XXXXXX. " " ........ " " ")) (build-template-z-4 (list " " " " " ...... " " .XXXX. " " .X X. " " .X X. " " .XXXX. " " ...... " " " " ")) (build-template-z-5 (list " " " " " " " .... " " .... " " .... " " .... " " " " " " "))) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (values nil (list (list +feature-start-machine-point+ 2 4 (- z 1)) (list +feature-start-sigil-point+ 7 4 (- z 1))) nil)))) ;;===================== ;; Flesh Storage ;;===================== (set-building-type (make-building :id +building-city-hell-storage-1+ :grid-dim '(3 . 3) :act-dim '(15 . 15) :type +building-type-hell-storage+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-0 (list "000000000000000" "000000000000000" "000000000000000" "0000XXXXXXX0000" "000XX%%%%%XX000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000XX%%%%%XX000" "0000XXXXXXX0000" "000000000000000" "000000000000000" "000000000000000")) (build-template-z-1 (list "000000000000000" "000000000000000" "000000000000000" "0000XXXXXXX0000" "000XX%%%%%XX000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000X%%%%%%%X000" "000XX%%%%%XX000" "0000XXXXXXX0000" "000000000000000" "000000000000000" "000000000000000")) (build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,,,XXXXXXX,,,," ",,,XX%%%%%XX,,," ",,,X%%%%%%%X,,," ",uuX%%%%%%%X,,," ",XXX%%%%%%%X,,," ",,,X%%%%%%%X,,," ",,,X%%%%%%%X,,," ",,,XX%%%%%XX,,," ",,,,XXXXXXX,,,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " " " XXXXXXX " " XX%%%%%XX " " X%%%%%%%X " " ddX%%%%%%%X " " ..X%%%%%%%X " " ..X%%%%%%%X " " ..X%%%%%%%X " " ..XX%%%%%XX " " ..XXXXXXX " " ....uX " " ...uX " " ")) (build-template-z-4 (list " " " " " " " XXXXXXX " " XX%%%%%XX " " X%%%%%%%X " " X%%%%%%%XXX " " X%%%%%%%Xuu " " X%%%%%%%X.. " " X%%%%%%%X.. " " XX%%%%%XX.. " " XXXXXXX.. " " d.... " " d... " " ")) (build-template-z-5 (list " " " Xu... " " Xu.... " " XXXXXXX.. " " XX%%%%%XX.. " " X%%%%%%%X.. " " X%%%%%%%X.. " " X%%%%%%%Xdd " " X%%%%%%%X " " X%%%%%%%X " " XX%%%%%XX " " XXXXXXX " " " " " " ")) (build-template-z-6 (list " " " ...d " " ....d " " ..XXXXXXX " " ..XX%%%%%XX " " ..X%%%%%%%X " " ..X%%%%%%%X " " uuX%%%%%%%X " " XXX%%%%%%%X " " X%%%%%%%X " " XX%%%%%XX " " XXXXXXX " " " " " " ")) (build-template-z-7 (list " " " ....... " " ......... " " ........... " " ....ggggg.... " " ...ggggggg... " " ...ggggggg... " " dd.ggggggg... " " ...ggggggg... " " ...ggggggg... " " ....ggggg.... " " ........... " " ......... " " ....... " " "))) (translate-build-to-template x y (- z 2) build-template-z-0 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) (translate-build-to-template x y (+ z 4) build-template-z-6 template-level terrains) (translate-build-to-template x y (+ z 5) build-template-z-7 template-level terrains) ) (values nil (list (list +feature-bomb-plant-target+ 7 7 7) (list +feature-start-sigil-point+ 7 2 7) (list +feature-start-sigil-point+ 7 12 7)) nil) ))) ;;===================== ;; Slime Pool ;;===================== (set-building-type (make-building :id +building-city-hell-slime-pool-1+ :grid-dim '(2 . 4) :act-dim '(10 . 20) :type +building-type-hell-slime-pool+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "``````````" "```~~``~~`" "`~~~~~~~``" "`~~~~~~~~`" "`~~~~~~~~`" "``~~~~~~``" "`~~~~~~~``" "``~~~~~~``" "`~~~~~~```" "`~~~~~~```" "`~~~~~~~``" "``~~~~~~~`" "````~~~~~`" "```~~~~~~`" "``~~~~~~``" "`~~~~~~~``" "`~~~~~~~``" "``~~~~~~~`" "``~~`~~~``" "``````````")) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-hell-slime-pool-2+ :grid-dim '(4 . 2) :act-dim '(20 . 10) :type +building-type-hell-slime-pool+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "````````````````````" "```~~``~~~`~```~~~``" "`~~~~~~~~~~~~`~~~~~`" "`~~~~~~~~~~~~~~~~~~`" "``~~~~~~~~~~~~~~~~``" "```~~~~~~~~~~~~~~```" "`~~~~~~~~~~~~~~~~~``" "``~~~~~~~~~~~~~~~~~`" "```~~~``~~~```~~~```" "````````````````````" )) ) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) ) (values nil nil nil))))
83,834
Common Lisp
.lisp
918
25.385621
154
0.151194
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
a60cf7b92ea913e9f7606de31429b753f8e50bd17db74b5fb88d5e59131f643e
2,892
[ -1 ]
2,893
init-common-building-types.lisp
gwathlobal_CotD/src/buildings/init-common-building-types.lisp
(in-package :cotd) ;;===================== ;; Special Buildings ;;===================== (set-building-type (make-building :id +building-city-free+ :grid-dim '(0 . 0) :act-dim '(0 . 0) :func nil)) (set-building-type (make-building :id +building-city-reserved+ :grid-dim '(0 . 0) :act-dim '(0 . 0) :func nil)) ;;===================== ;; River ;;===================== (set-building-type (make-building :id +building-city-river+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-air+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil nil nil)))) ;;===================== ;; Bridge ;;===================== (set-building-type (make-building :id +building-city-bridge+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-bridge+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil nil nil)))) ;;===================== ;; Pier ;;===================== (set-building-type (make-building :id +building-city-pier-north+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-pier+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil (list (list +feature-arrival-point-north+ 2 2 z)) nil)))) (set-building-type (make-building :id +building-city-pier-south+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-pier+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil (list (list +feature-arrival-point-south+ 2 2 z)) nil)))) (set-building-type (make-building :id +building-city-pier-east+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-pier+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil (list (list +feature-arrival-point-east+ 2 2 z)) nil)))) (set-building-type (make-building :id +building-city-pier-west+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-pier+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil (list (list +feature-arrival-point-west+ 2 2 z)) nil)))) ;;===================== ;; Sea ;;===================== (set-building-type (make-building :id +building-city-sea+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for x1 from 0 below 5 do (loop for y1 from 0 below 5 do (setf (aref template-level (+ x x1) (+ y y1) (- z 0)) +terrain-floor-air+) (setf (aref template-level (+ x x1) (+ y y1) (- z 1)) +terrain-water-liquid-nofreeze+) (setf (aref template-level (+ x x1) (+ y y1) (- z 2)) +terrain-water-liquid-nofreeze+))) (values nil nil nil)))) ;;===================== ;; Lakes ;;===================== (set-building-type (make-building :id +building-city-central-lake+ :grid-dim '(4 . 4) :act-dim '(20 . 20) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "````` `````" "`` ```" "` ``" "` `" " " " " " " " " " " " " " " " " " " " " " " "` `" "` ``" "` `" "`` ``" "````` ```")) (build-template-z-1 (list "00000__________00000" "00_______________000" "0_________________00" "0__________________0" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "0__________________0" "0_________________00" "0__________________0" "00________________00" "00000____________000")) (build-template-z-0 (list "000000________000000" "00000__________00000" "0000_____________000" "00________________00" "00_________________0" "0___________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "____________________" "0__________________0" "00________________00" "00_______________000" "000_____________0000" "00000__________00000" "000000________000000"))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (- z 2) build-template-z-0 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-lake-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-lake+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",```````,," "`` ` ``," "` `," "` ``," "`` ``," "`` ``" "` `" "` `" "``` ``" ",,```````,")) (build-template-z-1 (list "0000000000" "00_0___000" "0_______00" "0______000" "00_____000" "00______00" "0________0" "0________0" "000_____00" "0000000000")) (build-template-z-0 (list "0000000000" "0000000000" "000___0000" "00_____000" "00_____000" "00______00" "00______00" "00p_____00" "0000___000" "0000000000"))) ;; we assume that z is always 2 (translate-build-to-template x y (- z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (- z 2) build-template-z-0 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-lake-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-lake+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",````````," "`` ` ``" "` `" "` ``" "` ```" "`` `T`" ",` ```" ",` `," ",`` ` `," ",,```````,")) (build-template-z-1 (list "0000000000" "00___0__00" "0________0" "0_______00" "0______000" "00_____000" "00_____000" "00______00" "000__0__00" "0000000000")) (build-template-z-0 (list "0000000000" "0000000000" "000___0000" "00_____000" "00_____000" "00_____000" "00_____000" "000___0000" "0000000000" "0000000000"))) ;; we assume that z is always 2 (translate-build-to-template x y (- z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (- z 2) build-template-z-0 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Satanists' lair ;;===================== (set-building-type (make-building :id +building-city-satan-lair-1+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-satanists+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-0 (list "000000000" "0#######0" "0#|#u#|#0" "0#.....#0" "0#.....#0" "0##...##0" "0###.###0" "0#######0" "000000000")) (build-template-z-1 (list "000000000" "0#######0" "0##ud.|#0" "0#.....#0" "0#..####0" "0#..+.b#0" "0##u#.h#0" "0#######0" "000000000")) (build-template-z-2 (list ",,,,,,,,," ",#######," ",#.d#.h#," ",#..+.b#," ",+.|####," ",#..+.b#," ",#.d#.h#," ",#######," ",,,,,,,,,")) (build-template-z-3 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z -2) build-template-z-0 template-level terrains) (translate-build-to-template x y (+ z -1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values (list (list +mob-type-satanist+ 5 2 (+ z 0)) (list +mob-type-satanist+ 5 5 (+ z 0)) (list +mob-type-satanist+ 5 2 (+ z -1)) (list +mob-type-satanist+ 5 5 (+ z -1))) (list (list +feature-sacrificial-circle+ 4 4 (+ z -2)) (list +feature-blood-stain+ 4 6 (+ z -2)) (list +feature-blood-stain+ 2 4 (+ z -2)) (list +feature-blood-stain+ 6 4 (+ z -2)) (list +feature-blood-fresh+ 4 5 (+ z -2)) (list +feature-blood-fresh+ 4 7 (+ z -2)) (list +feature-blood-fresh+ 3 6 (+ z -2)) (list +feature-blood-fresh+ 5 6 (+ z -2)) (list +feature-blood-old+ 3 4 (+ z -2)) (list +feature-blood-old+ 2 3 (+ z -2)) (list +feature-blood-fresh+ 1 4 (+ z -2)) (list +feature-blood-fresh+ 2 5 (+ z -2)) (list +feature-blood-old+ 6 4 (+ z -2)) (list +feature-blood-fresh+ 7 4 (+ z -2)) (list +feature-blood-old+ 5 4 (+ z -2)) (list +feature-blood-old+ 6 3 (+ z -2)) (list +feature-blood-fresh+ 6 5 (+ z -2)) (list +feature-blood-fresh+ 4 4 (+ z -2)) (list +feature-blood-old+ 3 5 (+ z -2)) (list +feature-blood-old+ 5 5 (+ z -2)) (list +feature-blood-fresh+ 3 7 (+ z -2)) (list +feature-blood-fresh+ 5 7 (+ z -2)) (list +feature-start-satanist-player+ 4 4 (+ z -2)) ) nil)))) ;;===================== ;; Churches ;;===================== (set-building-type (make-building :id +building-city-church-1+ :grid-dim '(4 . 4) :act-dim '(17 . 17) :type +building-type-church+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "```,,,,,,,,,,```," "`T````#-#-#```T`," "`````##...##````," ",##-##.....##-##," ",#.............#," ",-.............-," ",#...hhh.hhh...#," ",##-#.......#-##," "````-hhh.hhh-```," "`T``#.......#````" "````#hhh.hhh#``T`" ",```-.......-````" ",####hhh.hhh####," ",-ch#.......#hc-," ",#..+.......+..#," ",##-#-#+#+#-#-##," ",,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ##### " " ## ## " " ##### ##### " " #| |# " " - - " " # # " " ##-#| |#-## " " - - " " # # " " # # " " - - " " ####| |#### " " # # # # " " # # # # " " ####-#####-#### " " ")) (build-template-z-4 (list " " " ..... " " ..###.. " " .....##|##..... " " .##### #####. " " .#| |#. " " .#### ####. " " ....#| |#.... " " .# #. " " .# #. " " .# #. " " .# #. " " ....#| |#.... " " ....# #.... " " ....# #.... " " ....#######.... " " ")) (build-template-z-5 (list " " " " " ... " " ..... " " ............. " " ............. " " ............. " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (setf (aref template-level (+ x 8) (+ y 16) z) +terrain-floor-sign-church-catholic+) (values nil (list (list +feature-start-church-player+ 8 2 z) (list +feature-start-place-church-priest+ 8 4 z) (list +feature-start-place-church-priest+ 3 4 z) (list +feature-start-place-church-priest+ 12 4 z) (list +feature-start-place-civilian-man+ 6 7 z) (list +feature-start-place-civilian-man+ 10 11 z) (list +feature-start-place-civilian-woman+ 10 7 z) (list +feature-start-place-civilian-woman+ 6 11 z) (list +feature-start-place-relic+ 8 2 z) (list +feature-start-strong-repel-demons+ 8 9 z) (list +feature-start-place-angels+ 8 5 z) (list +feature-start-place-angels+ 8 8 z) (list +feature-start-place-angels+ 8 11 z) (list +feature-start-place-angels+ 8 14 z)) nil)))) (set-building-type (make-building :id +building-city-church-2+ :grid-dim '(4 . 4) :act-dim '(17 . 17) :type +building-type-church+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list "```,,,,,,,,,,,,,," "`T``###-#-###```," "````#.......#`T`," ",```#.......#```," ",####.......####," ",#.............#," ",-.............-," ",#...#.....#...#," ",#.............#," ",#...#.....#...#," ",-.............-," ",#.............#," ",####.......####," ",```-.......-````" "````#.......#``T`" "`T``#-#+#+#-#````" "```,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ######### " " #| |# " " # # " " #### #### " " # # " " - | | - " " # # # # " " # # " " # # # # " " - | | - " " # # " " #### #### " " - - " " #| |# " " ###+#+### " " ")) (build-template-z-4 (list " " " ......... " " ......... " " ......... " " ............... " " .....#####..... " " ....## ##.... " " ....# #.... " " ....# #.... " " ....# #.... " " ....## ##.... " " .....#####..... " " ............... " " ......... " " ......... " " ......... " " ")) (build-template-z-5 (list " " " " " " " " " ####### " " ## ## " " # # " " # # " " # # " " # # " " # # " " ## ## " " ####### " " " " " " " " ")) (build-template-z-6 (list " " " " " " " " " " " ##### " " ## ## " " # # " " # # " " # # " " ## ## " " ##### " " " " " " " " " " ")) (build-template-z-7 (list " " " " " " " " " " " ..... " " ....... " " ....... " " ....... " " ....... " " ....... " " ..... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) (translate-build-to-template x y (+ z 4) build-template-z-6 template-level terrains) (translate-build-to-template x y (+ z 5) build-template-z-7 template-level terrains) ) (setf (aref template-level (+ x 8) (+ y 16) z) +terrain-floor-sign-church-orthodox+) (values nil (list (list +feature-start-church-player+ 8 6 z) (list +feature-start-place-church-priest+ 8 4 z) (list +feature-start-place-church-priest+ 5 4 z) (list +feature-start-place-church-priest+ 11 4 z) (list +feature-start-place-civilian-man+ 6 7 z) (list +feature-start-place-civilian-woman+ 10 7 z) (list +feature-start-place-civilian-man+ 10 11 z) (list +feature-start-place-civilian-woman+ 6 11 z) (list +feature-start-place-relic+ 8 2 z) (list +feature-start-strong-repel-demons+ 8 9 z) (list +feature-start-place-angels+ 8 5 z) (list +feature-start-place-angels+ 8 8 z) (list +feature-start-place-angels+ 8 11 z) (list +feature-start-place-angels+ 8 14 z)) nil)))) ;;===================== ;; Barricades ;;===================== (set-building-type (make-building :id +building-city-barricade-ns+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dy from 0 to 4 do (setf (aref template-level (+ x 1) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y dy) z) +terrain-wall-barricade+)) (values nil nil) ))) (set-building-type (make-building :id +building-city-barricade-we+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dx from 0 to 4 do (setf (aref template-level (+ x dx) (+ y 1) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 3) z) +terrain-wall-barricade+)) (values nil nil nil) ))) (set-building-type (make-building :id +building-city-barricade-se+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dx from 2 to 4 do (setf (aref template-level (+ x dx) (+ y 1) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 3) z) +terrain-wall-barricade+)) (loop for dy from 2 to 4 do (setf (aref template-level (+ x 1) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y dy) z) +terrain-wall-barricade+)) (values nil nil nil) ))) (set-building-type (make-building :id +building-city-barricade-sw+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dx from 0 to 2 do (setf (aref template-level (+ x dx) (+ y 1) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 3) z) +terrain-wall-barricade+)) (loop for dy from 2 to 4 do (setf (aref template-level (+ x 1) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y dy) z) +terrain-wall-barricade+)) (values nil nil nil) ))) (set-building-type (make-building :id +building-city-barricade-nw+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dx from 0 to 2 do (setf (aref template-level (+ x dx) (+ y 1) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 3) z) +terrain-wall-barricade+)) (loop for dy from 0 to 2 do (setf (aref template-level (+ x 1) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y dy) z) +terrain-wall-barricade+)) (values nil nil nil) ))) (set-building-type (make-building :id +building-city-barricade-ne+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (loop for dx from 2 to 4 do (setf (aref template-level (+ x dx) (+ y 1) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x dx) (+ y 3) z) +terrain-wall-barricade+)) (loop for dy from 0 to 2 do (setf (aref template-level (+ x 1) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y dy) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y dy) z) +terrain-wall-barricade+)) (values nil nil nil) ))) ;;===================== ;; Army posts ;;===================== (set-building-type (make-building :id +building-city-army-post+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",,,,,,,,,," ",,##,,##,," ",,#,,,,#,," ",,,,,|,,,," ",,,,,,,,,," ",,#,,,,#,," ",,##,,##,," ",,,,,,,,,," ",,,,,,,,,,")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (setf (aref template-level (+ x 2) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y 3) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 6) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 7) (+ y 2) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 7) (+ y 3) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y 6) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 2) (+ y 7) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 3) (+ y 7) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 6) (+ y 7) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 7) (+ y 7) z) +terrain-wall-barricade+) (setf (aref template-level (+ x 7) (+ y 6) z) +terrain-wall-barricade+) ) (values nil (list (list +feature-start-repel-demons+ 5 5 z) (list +feature-start-place-military+ 5 5 z)) nil)))) ;;===================== ;; Sigil posts ;;===================== (set-building-type (make-building :id +building-city-sigil-post+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",uuuuuuu," ",u00000u," ",u00000u," ",u00000u," ",u00000u," ",u00000u," ",uuuuuuu," ",,,,,,,,," )) (build-template-z-3 (list " " " ddddddd " " d,,,,,d " " d,,,,,d " " d,,.,,d " " d,,,,,d " " d,,,,,d " " ddddddd " " " )) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil (list (list +feature-start-sigil-point+ 4 4 (+ z 1))) nil)))) ;;===================== ;; Craters ;;===================== (set-building-type (make-building :id +building-city-crater-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-crater+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",,dddddd,," ",dd dd," ",d d," ",d d," ",d d," ",d d," ",dd dd," ",,dddddd,," ",,,,,,,,,,")) (build-template-z-1 (list "0000000000" "00uuuuuu00" "0uudddduu0" "0udd ddu0" "0ud du0" "0ud du0" "0udd ddu0" "0uudddduu0" "00uuuuuu00" "0000000000")) (build-template-z-0 (list "0000000000" "0000000000" "000uuuu000" "00uu,,uu00" "00u,,,,u00" "00u,,,,u00" "00uu,,uu00" "000uuuu000" "0000000000" "0000000000")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (- z 2) build-template-z-0 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-crater-2+ :grid-dim '(2 . 2) :act-dim '(8 . 8) :type +building-type-crater+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,," ",,dddd,," ",dd dd," ",d d," ",d d," ",dd dd," ",,dddd,," ",,,,,,,,")) (build-template-z-1 (list "00000000" "00uuuu00" "0uu,,uu0" "0u,,,,u0" "0u,,,,u0" "0uu,,uu0" "00uuuu00" "00000000")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-crater-large+ :grid-dim '(3 . 3) :act-dim '(15 . 15) :type +building-type-crater-large+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-3 (list " " " ddddddddd " " dd,,,,,,,dd " " dd,,ddddd,,dd " " d,,dd dd,,d " " d,dd dd,d " " d,d d,d " " d,d d,d " " d,d d,d " " d,dd dd,d " " d,,dd dd,,d " " dd,,ddddd,,dd " " dd,,,,,,,dd " " ddddddddd " " ")) (build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,uuuuuuuuu,,," ",,uu0000000uu,," ",uu00uuuuu00uu," ",u00uuddduu00u," ",u0uudd dduu0u," ",u0udd ddu0u," ",u0ud du0u," ",u0udd ddu0u," ",u0uudd dduu0u," ",u00uuddduu00u," ",uu00uuuuu00uu," ",,uu0000000uu,," ",,,uuuuuuuuu,,," ",,,,,,,,,,,,,,,")) (build-template-z-1 (list "000000000000000" "000000000000000" "000000000000000" "000000000000000" "000000uuu000000" "00000uu,uu00000" "0000uu,,,uu0000" "0000u,,,,,u0000" "0000uu,,,uu0000" "00000uu,uu00000" "000000uuu000000" "000000000000000" "000000000000000" "000000000000000" "000000000000000")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) ) (values nil nil nil))))
75,685
Common Lisp
.lisp
812
31.75
141
0.183726
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
e403bb5e49497596bb10c21bc8e59d4ad9644d9d505f19127dc525bd07ea682a
2,893
[ -1 ]
2,894
init-corrupted-building-types.lisp
gwathlobal_CotD/src/buildings/init-corrupted-building-types.lisp
(in-package :cotd) ;;===================== ;; Runied houses ;;===================== (set-building-type (make-building :id +building-city-corrupted-house-1+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-corrupted-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",,.#####," ",....u##," ",.h....#," ",####|.#," ",-ht...#," ",#....c#," ",.##+###," ",,,,,,,,,")) (build-template-z-3 (list " " " #-### " " ..d.# " " c....# " " ####|.# " " #b....# " " ..h..h# " " ..-### " " ")) (build-template-z-4 (list " " " ..... " " ..... " " ...... " " ....... " " ....... " " ..... " " .... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil )))) (set-building-type (make-building :id +building-city-corrupted-house-2+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-corrupted-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",#c...t#," ",#..|...," ",+..#..,," ",#.u#...," ",-.##ht#," ",#######," ",,,,,,,,,")) (build-template-z-3 (list " " " ##-#### " " #c...b. " " #..|. " " #..#. " " #.d#.. " " #..#bc# " " ##-#### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ..... " " .... " " ..... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-house-3+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-corrupted-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",##u#ht-," ",#..#..#," ",-..#..+," ",#t.|..#," ",.....c#," ",,..####," ",,,,,,,,,")) (build-template-z-3 (list " " " ####### " " #.d#cb# " " #..#..# " " -..#..- " " #..|.b# " " ...c# " " #### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ..... " " .... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-house-4+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-corrupted-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",###..,,," ",#c....,," ",#......," ",#.|####," ",#....##," ",#cb..u#," ",#####-#," ",,,,,,,,,")) (build-template-z-3 (list " " " ### " " #c... " " #.... " " #.|#### " " #.....# " " -th..d# " " ####### " " ")) (build-template-z-4 (list " " " .... " " ..... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined townhalls ;;===================== (set-building-type (make-building :id +building-city-corrupted-townhall-1+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-corrupted-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",,,##......#,,,," ",,```......```,," ",#```......```,," ",#```......```,," ",##-###..###-##," ",#|..#c..c#..|.," ",#...+....+...,," ",##u.#|..|#...,," ",###-##--##.,,,," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .. . " " " " . " " . " " ##-###-###.... " " #..|#|...#... " " #...+....+.. " " #.d.#c.ht#.. " " ###-##-###. " " ")) (build-template-z-4 (list " " " " " " " " " " " .......... " " .......... " " .......... " " .......... " " .......... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-townhall-2+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-corrupted-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",###-##--##-###," ",#ht.#|..|#.u##," ",#...+....+...,," ",#|..#c..c#...,," ",##-###..###..,," ",#```......```,," ",#```......```#," ",,```......```#," ",,,##......####," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ....###-##-### " " ....#th.c#.d.# " " ....+....+... " " ....#...|#|. " " ....###-### " " . " " . . " " . " " .. .... " " ")) (build-template-z-4 (list " " " .......... " " .......... " " .......... " " .......... " " .......... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-townhall-3+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-corrupted-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",#########," ",##..#```#," ",#u..-```#," ",-..|#```#," ",##+##....," ",....#....," ",.........," ",.........," ",....#....," ",##+##....," ",-..|#```#," ",#t..-```#," ",#h..#```#," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " #####.... " " #..|# . " " #d..- . " " -...# . " " ##+## " " ..# " " .- " " .# " " ..# " " ##+## " " ..... . " " ..... . " " ..... . " " ......... " " ")) (build-template-z-4 (list " " " ..... " " ..... " " ..... " " ..... " " .... " " ... " " .... " " ..... " " ..... " " ..... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-townhall-4+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-corrupted-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",,,,,,..##," ",,```...h#," ",,```...t#," ",,```#...#," ",....##+##," ",....#c.|#," ",........-," ",........-," ",....#c.|#," ",....##+##," ",#```#...-," ",#```-..u#," ",#```#|.##," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " .. " " ... " " .... " " ..... " " ##+## " " #..t# " " #..h# " " -...- " " #|.c# " " ##+## " " . #|..- " " . -..d# " " . #...# " " ....##### " " ")) (build-template-z-4 (list " " " " " " " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined parks ;;===================== (set-building-type (make-building :id +building-city-corrupted-park-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-corrupted-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,,```" "```T````T`" "`T```T````" "``````T`,," "``T`````,," ",````T````" ",```````T`" ",`````````" ",,`T``T`,," ",,``````,,"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-park-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-corrupted-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,```," "```T```T`," "`T```T````" "```T``````" "`T````T```" "````T```,," ",`T```T`,," ",`````````" ",`T`T`,`T`" ",`````,```"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-park-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-corrupted-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place a large twintube tree (let ((dx (random 8)) (dy (random 8)) (r (random 5))) (cond ((= r 4) (level-place-twintube-corrupted-4 template-level (+ dx x) (+ dy y) z)) ((= r 3) (level-place-twintube-corrupted-3 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-twintube-corrupted-2 template-level (+ dx x) (+ dy y) z)) ((= r 1) (level-place-twintube-corrupted-1 template-level (+ dx x) (+ dy y) z)) (t nil)) ) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-creep+)))))) ;; find a place to position citizens (values nil nil nil) ))) (set-building-type (make-building :id +building-city-corrupted-park-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-corrupted-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-creep+)))))) ;; place a large oak tree (let ((dx (random 8)) (dy (random 8))) (cond (t (level-place-twintube-mutated-1 template-level (+ dx x) (+ dy y) z))) ) ;; find a place to position citizens (values nil nil nil) ))) (set-building-type (make-building :id +building-city-corrupted-park-tiny+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (if (zerop (random 5)) (progn ;; place a large birch tree (let ((r (random 4))) (cond ((= r 3) (level-place-twintube-corrupted-4 template-level (+ 1 x) (+ 1 y) z)) ((= r 2) (level-place-twintube-corrupted-3 template-level (+ 1 x) (+ 1 y) z)) ((= r 1) (level-place-twintube-corrupted-2 template-level (+ 1 x) (+ 1 y) z)) (t (level-place-twintube-corrupted-1 template-level (+ 1 x) (+ 1 y) z))) ) (values nil nil) ) (progn ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than two adjacent trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 2) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place grass around trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (if (or (= (aref template-level x y z) +terrain-border-floor+) (= (aref template-level x y z) +terrain-border-grass+) (= (aref template-level x y z) +terrain-border-creep+)) (setf (aref template-level x y z) +terrain-border-creep+) (setf (aref template-level x y z) +terrain-floor-creep+))))))) (values nil nil nil)))) )) ;;===================== ;; Ruined prisons ;;===================== (set-building-type (make-building :id +building-city-corrupted-prison-1+ :grid-dim '(4 . 4) :act-dim '(17 . 17) :type +building-type-corrupted-prison+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,," ",,.#####.#######," ",......-.#...+.#," ",#.....-.#htc-.#," ",#.....-.#|###.#," ",#.....-.#htc-.#," ",#.....-.#...+.#," ",#.....-.#####.#," ",#.....-........," ",#+#####h..###.,," ",#....|###+##u..," ",#..............," ",#-+#-+#-+#-+#.#," ",...#..#..#..#.#," ",...#.b#.b#.b#.#," ",,..############," ",,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ############# " " #|...+.b# " " # #....-..# " " # -....#### " " # #h...+.b# " " # -....-..# " " # #....#### " " # #|.....h " " #-###-####... " " #.....|.....d. " " #.............# " " #-+#-+#-+#-+#.# " " ..#..#..#..#.# " " #.b#.b#.b#.# " " ############ " " ")) (build-template-z-4 (list " " " ............. " " ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ........ " " ............. " " .............. " " ............... " " ............... " " .............. " " ............ " " ............ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (setf (aref template-level (+ x 7) (+ y 0) z) +terrain-floor-sign-prison+) (values nil nil nil)))) ;;===================== ;; Corrupted warehouses ;;===================== (set-building-type (make-building :id +building-city-corrupted-warehouse-1+ :grid-dim '(4 . 4) :act-dim '(20 . 20) :type +building-type-corrupted-warehouse+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",##-#####..#####-##," ",#|..............|#," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..####....####..#," ",..................," ",..................," ",#..####....####..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",#|..............|#," ",##-#####..#####-##," ",,,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " ....... ....... " " ...... ...... " " ...... ...... " " ....... ....... " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined libraries ;;===================== (set-building-type (make-building :id +building-city-corrupted-library-1+ :grid-dim '(4 . 3) :act-dim '(20 . 13) :type +building-type-corrupted-library+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "000000000000#######0" "000000000000#BB.BB#0" "000000000000#.....#0" "000000000000#|....#0" "000000000000#####.#0" "0000000000000000#u#0" "0000000000000000###0" "00000000000000000000" )) (build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",,..####-###-###-##," ",..h.|#..........|#," ",..t..+..B..B..B..-," ",#....#..B..B..B..#," ",##..##..B..B..B..#," ",`````-..B..B..B..-," ",`````#..B..B..B..#," ",`T```#..B..B..B..#," ",`````-..B..B..#...," ",,``T`#|.........d.," ",,,```##-###-##....," ",,,,,,,,,,,,,,,,,,,," )) (build-template-z-3 (list " " " ............... " " ................ " " ................. " " .................. " " .................. " " ............. " " ............. " " ............. " " ........... " " .......... " " .......... " " " ))) ;; we assume that z = 2 (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 2) (+ y 6) z) +terrain-floor-sign-library+) (values nil nil nil)))) ;;===================== ;; Corrupted port warehouses ;;===================== (set-building-type (make-building :id +building-city-corrupted-warehouse-port-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",########," ",#|CCCCC#," ",+......+," ",#.CCCC.#," ",#.CCCC.#," ",+......+," ",#CCCCC|#," ",########," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-warehouse-port-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",##+##+##," ",#C....|#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#|....C#," ",##+##+##," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Corrupted mansions ;;===================== (set-building-type (make-building :id +building-city-corrupted-mansion-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-corrupted-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,###-#-###-#-.,,,," ",,#B..#.|#|.#...,,," ",,#B..+..u..+....,," ",,#B..#c...c#...,,," ",,##+####-####.,,,," ",,#|..#``````*``,,," ",,#...+``*``````*,," ",,#...#`*``*````,,," ",,#...#```````*`,,," ",,##+##***,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ###-#####-#.. " " #...#|....#.. " " #ht.+..d..+.. " " #|..#BB.BB#.. " " ##+####-###. " " #c.|# " " #...- " " #..t- " " #b.h# " " ##-## " " " " ")) (build-template-z-4 (list " " " " " ........... " " ........... " " ........... " " ........... " " ........... " " ..... " " ..... " " ..... " " ..... " " ..... " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-corrupted-mansion-2+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-corrupted-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,##+##**,,,,**,,,," ",,#...#`````````,,," ",,#...#``*`*``*`,,," ",,#...+`*```````*,," ",,#|..#``````*``*,," ",,##+####-####-##,," ",,#B..#c...c#..c#,," ",,#B..+..u..+..c-,," ",,,...#.|#|.#..c#,," ",,,,..#-###-#-###,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ##-## " " #b.h# " " #..t- " " #...- " " #c.|# " " ##+####-###.... " " #|..#BB.BB#..h. " " #ht.+..d..+..t. " " .#|....#..h. " " #####-#.... " " " " ")) (build-template-z-4 (list " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ........... " " ........... " " ........... " " ......... " " ........ " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Corrupted banks ;;===================== (set-building-type (make-building :id +building-city-corrupted-bank-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-corrupted-bank+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "000000000000000" "000000000000000" "00###########00" "00#h....h#u.#00" "00#.........#00" "00##+##|#,,,uu0" "00##.####,,,,u0" "00##+##|#,,,,u0" "00#.......,,uu0" "00#.........u00" "00###########00" "000000000000000" "000000000000000" "000000000000000")) (build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,###########,," ",,#|......d##,," ",,#..........,," ",,#+##+## dd," ",,#.#...# d," ",,#.#.h.# d," ",,#+#|t## dd," ",,#....... d.," ",,-....hhhh..,," ",,##++##-####,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ........... " " ........... " " .......... " " ......... " " ........ " " ........ " " ......... " " .......... " " ........... " " ........... " " " " ")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z -1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 6) (+ y 12) z) +terrain-floor-sign-bank+) (values nil nil nil)))) ;;===================== ;; Graveyards ;;===================== (set-building-type (make-building :id +building-city-corrupted-graveyard-1+ :grid-dim '(4 . 4) :act-dim '(16 . 16) :type +building-type-corrupted-graveyard+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",*,,**,*,,**,,*," ",,,,,,,,,,,,,,*," ",,*G,,G,,G,,G,,," ",,,,,*,,,,,,,,*," ",*,,,,,,,,,*,,*," ",,,G,,G,,G,,G,,," ",*,,,,,,,,,,,,,," ",*,,,,,*,,,,,,,," ",,,G,,G,,G,,G,*," ",*,,*,,,,,,,,,*," ",,,,,,,,,,*,,,*," ",*,G,,G,,G,,G,*," ",*,,,,,,,,,,,,,," ",*,****,,,***,*," ",,,,,,,,,,,,,,,,")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Corrupted shrine ;;===================== (set-building-type (make-building :id +building-city-corrupted-shrine-1+ :grid-dim '(3 . 3) :act-dim '(15 . 15) :type +building-type-corrupted-shrine+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,XXXXXXXXX,,," ",,*,,,,,,,,,*,," ",X,,,XXXXX,,,X," ",X,,*,,,,,*,,X," ",X,X,XX,XX,X,X," ",X,X,X,,,X,X,X," ",X,X,,,.,,,X,X," ",X,X,X,,,X,X,X," ",X,X,XX,XX,X,X," ",X,,*,,,,,*,,X," ",X,,,XXXXX,,,X," ",,*,,,,,,,,,*,," ",,,XXXXXXXXX,,," ",,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ````````` " " XXXXXXXXXXX " " XX XXXXX XX " " X X " " X X XX XX X X " " X X X X X X " " X X X X " " X X X X X X " " X X XX XX X X " " X X " " XX XXXXX XX " " XXXXXXXXXXX " " ````````` " " ")) (build-template-z-4 (list " " " " " ``````````` " " ``XXXXXXXXX`` " " `XX XX` " " `XX XX XX XX` " " `XX X X XX` " " `XX XX` " " `XX X X XX` " " `XX XX XX XX` " " `XX XX` " " ``XXXXXXXXX`` " " ``````````` " " " " ")) (build-template-z-5 (list " " " " " " " ````````` " " ``````````` " " ``````````` " " ``````````` " " ``````````` " " ``````````` " " ``````````` " " ``````````` " " ````````` " " " " " " ")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) (translate-build-to-template x y (+ z 3) build-template-z-5 template-level terrains) ) (values nil (list (list +feature-start-place-relic+ 7 7 z) (list +feature-start-place-demons+ 7 7 z) (list +feature-start-place-demons+ 7 5 z) (list +feature-start-place-demons+ 7 9 z) (list +feature-start-place-demons+ 5 7 z) (list +feature-start-place-demons+ 9 7 z) (list +feature-start-place-demons+ 4 4 z) (list +feature-start-place-demons+ 10 4 z) (list +feature-start-place-demons+ 4 10 z) (list +feature-start-place-demons+ 10 10 z) (list +feature-start-place-demons+ 9 7 z) (list +feature-start-place-demons+ 2 2 z) (list +feature-start-place-demons+ 12 2 z) (list +feature-start-place-demons+ 2 12 z) (list +feature-start-place-demons+ 12 12 z)) nil)))) ;;===================== ;; Borders ;;===================== (set-building-type (make-building :id +building-city-corrupted-forest-border+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (if (zerop (random 5)) (progn ;; place a large birch tree (let ((r (random 4))) (cond ((= r 3) (level-place-twintube-corrupted-4 template-level (+ 1 x) (+ 1 y) z)) ((= r 2) (level-place-twintube-corrupted-3 template-level (+ 1 x) (+ 1 y) z)) ((= r 1) (level-place-twintube-corrupted-2 template-level (+ 1 x) (+ 1 y) z)) (t (level-place-twintube-corrupted-1 template-level (+ 1 x) (+ 1 y) z))) ) (values nil nil) ) (progn ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+)))) ;; make sure that each tree has no more than two adjacent trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-twintube+) (incf tree-num)))) (when (> tree-num 2) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-creep+)))) ;; place grass around trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-twintube+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (if (or (= (aref template-level x y z) +terrain-border-floor+) (= (aref template-level x y z) +terrain-border-grass+) (= (aref template-level x y z) +terrain-border-creep+)) (setf (aref template-level x y z) +terrain-border-creep+) (setf (aref template-level x y z) +terrain-floor-creep+))))))) (values nil nil nil)))) ))
98,776
Common Lisp
.lisp
1,088
27.111213
156
0.141265
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
118441038674190fff8d9d91be0da5c7125041cfb5129b4f57fc5fa11f03a1a7
2,894
[ -1 ]
2,895
init-normal-building-types.lisp
gwathlobal_CotD/src/buildings/init-normal-building-types.lisp
(in-package :cotd) ;;===================== ;; Houses ;;===================== (set-building-type (make-building :id +building-city-house-1+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#-#####," ",#t..u##," ",#h....#," ",####|.#," ",-ht...#," ",#....c#," ",###+###," ",,,,,,,,,")) (build-template-z-3 (list " " " ###-### " " #b..d.# " " #c....# " " ####|.# " " #b....# " " #ch..h# " " ###-### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 4 5 z) (list +mob-type-woman+ 3 2 (+ z 1)) (list +mob-type-child+ 5 5 (+ z 1))) (list (list +feature-start-gold-small+ 3 2 (+ z 1))) nil )))) (set-building-type (make-building :id +building-city-house-2+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",#c...t#," ",#..|.h#," ",+..#..-," ",#.u#..#," ",-.##ht#," ",#######," ",,,,,,,,,")) (build-template-z-3 (list " " " ##-#### " " #c...b# " " #..|.c# " " #..#..- " " #.d#..# " " #..#bc# " " ##-#### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 2 3 z) (list +mob-type-woman+ 4 2 (+ z 1)) (list +mob-type-child+ 5 4 (+ z 1))) (list (list +feature-start-gold-small+ 4 2 (+ z 1))) nil)))) (set-building-type (make-building :id +building-city-house-3+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",##u#ht-," ",#..#..#," ",-..#..+," ",#t.|..#," ",#h...c#," ",#######," ",,,,,,,,,")) (build-template-z-3 (list " " " ####### " " #.d#cb# " " #..#..# " " -..#..- " " #..|.b# " " #c...c# " " ####### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 5 4 z) (list +mob-type-woman+ 2 2 (+ z 1)) (list +mob-type-child+ 2 4 (+ z 1))) (list (list +feature-start-gold-small+ 2 2 (+ z 1))) nil)))) (set-building-type (make-building :id +building-city-house-4+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",###+###," ",#c...h#," ",#....t-," ",#.|####," ",#....##," ",#cb..u#," ",#####-#," ",,,,,,,,,")) (build-template-z-3 (list " " " ####### " " #c...c# " " #....b- " " #.|#### " " #.....# " " -th..d# " " ####### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 4 2 z) (list +mob-type-woman+ 2 4 (+ z 1)) (list +mob-type-child+ 4 5 (+ z 1))) (list (list +feature-start-gold-small+ 2 4 (+ z 1))) nil)))) ;;===================== ;; Townhalls ;;===================== (set-building-type (make-building :id +building-city-townhall-1+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",####......####," ",#```......```#," ",#```......```#," ",#```......```#," ",##-###..###-##," ",#|..#c..c#..|#," ",#...+....+...#," ",##u.#|..|#.th#," ",###-##--##-###," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .... .... " " . . " " . . " " . . " " ##-###-###.... " " #..|#|...#.... " " #...+....+.... " " #.d.#c.ht#.... " " ###-##-###.... " " ")) (build-template-z-4 (list " " " " " " " " " " " .......... " " .......... " " .......... " " .......... " " .......... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-clerk+ 7 8 (+ z 1)) (list +mob-type-clerk+ 7 8 z) (list +mob-type-clerk+ 12 7 z)) (list (list +feature-start-gold-small+ 7 8 (+ z 1))) nil)))) (set-building-type (make-building :id +building-city-townhall-2+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",###-##--##-###," ",#ht.#|..|#.u##," ",#...+....+...#," ",#|..#c..c#..|#," ",##-###..###-##," ",#```......```#," ",#```......```#," ",#```......```#," ",####......####," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ....###-##-### " " ....#th.c#.d.# " " ....+....+...# " " ....#...|#|..# " " ....###-###-## " " . . " " . . " " . . " " .... .... " " ")) (build-template-z-4 (list " " " .......... " " .......... " " .......... " " .......... " " .......... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-clerk+ 3 3 z) (list +mob-type-clerk+ 8 3 (+ z 1)) (list +mob-type-clerk+ 8 2 z)) (list (list +feature-start-gold-small+ 8 3 (+ z 1))) nil)))) (set-building-type (make-building :id +building-city-townhall-3+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",#########," ",##..#```#," ",#u..-```#," ",-..|#```#," ",##+##....," ",#|.c#....," ",-........," ",-........," ",#|.c#....," ",##+##....," ",-..|#```#," ",#t..-```#," ",#h..#```#," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " #####.... " " #..|# . " " #d..- . " " -...# . " " ##+## " " #|.c# " " -...- " " #h..# " " #t..# " " ##+## " " ..... . " " ..... . " " ..... . " " ......... " " ")) (build-template-z-4 (list " " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-clerk+ 2 8 (+ z 1)) (list +mob-type-clerk+ 2 13 z) (list +mob-type-clerk+ 2 8 z)) (list (list +feature-start-gold-small+ 2 8 (+ z 1))) nil)))) (set-building-type (make-building :id +building-city-townhall-4+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",#########," ",#```#|.h#," ",#```-..t#," ",#```#...#," ",....##+##," ",....#c.|#," ",........-," ",........-," ",....#c.|#," ",....##+##," ",#```#...-," ",#```-..u#," ",#```#|.##," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " ......... " " . ..... " " . ..... " " . ..... " " ##+## " " #..t# " " #..h# " " -...- " " #|.c# " " ##+## " " . #|..- " " . -..d# " " . #...# " " ....##### " " ")) (build-template-z-4 (list " " " " " " " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-clerk+ 7 2 z) (list +mob-type-clerk+ 7 8 (+ z 1)) (list +mob-type-clerk+ 7 8 z)) (list (list +feature-start-gold-small+ 7 8 (+ z 1))) nil)))) ;;===================== ;; Parks ;;===================== (set-building-type (make-building :id +building-city-park-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,,```" "```T````T`" "`T```T````" "``````T`,," "``T`````,," ",````T````" ",`|`````T`" ",`````````" ",,`T``T`,," ",,``````,,"))) (translate-build-to-template x y z build-template template-level terrains) ) (values (list (list +mob-type-man+ 2 1 z) (list +mob-type-woman+ 7 4 z)) nil nil)))) (set-building-type (make-building :id +building-city-park-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,```," "```T```T`," "`T```T````" "```T````|`" "`T````T```" "````T```,," ",`T```T`,," ",`````````" ",`T`T`,`T`" ",`````,```"))) (translate-build-to-template x y z build-template template-level terrains) ) (values (list (list +mob-type-man+ 4 6 z) (list +mob-type-woman+ 4 1 z)) nil nil)))) (set-building-type (make-building :id +building-city-park-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place a large birch tree (let ((dx (random 8)) (dy (random 8)) (r (random 5))) (cond ((= r 4) (level-place-birch-mature-4 template-level (+ dx x) (+ dy y) z)) ((= r 3) (level-place-birch-mature-3 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-birch-mature-2 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-birch-mature-1 template-level (+ dx x) (+ dy y) z)) (t nil)) ) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-grass+)))))) ;; find a place to position citizens (values (loop repeat 2 collect (loop with rx = (random 10) with ry = (random 10) until (and (not (= (aref template-level (+ x rx) (+ y ry) z) +terrain-tree-birch+)) (not (= (aref template-level (+ x rx) (+ y ry) z) +terrain-tree-birch-trunk+))) finally (return (list +mob-type-man+ rx ry z)) do (setf rx (random 10)) (setf ry (random 10)) )) nil nil) ))) (set-building-type (make-building :id +building-city-park-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-grass+)))))) ;; place a large oak tree (let ((dx (random 7)) (dy (random 7))) (cond (t (level-place-oak-mature-1 template-level (+ dx x) (+ dy y) z))) ) ;; find a place to position citizens (values (loop repeat 2 collect (loop with rx = (random 10) with ry = (random 10) until (not (get-terrain-type-trait (aref template-level (+ x rx) (+ y ry) z) +terrain-trait-blocks-move+)) finally (return (list +mob-type-man+ rx ry z)) do (setf rx (random 10)) (setf ry (random 10)) )) nil nil) ))) (set-building-type (make-building :id +building-city-park-tiny+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (if (zerop (random 5)) (progn ;; place a large birch tree (let ((r (random 4))) (cond ((= r 3) (level-place-birch-mature-4 template-level (+ 1 x) (+ 1 y) z)) ((= r 2) (level-place-birch-mature-3 template-level (+ 1 x) (+ 1 y) z)) ((= r 1) (level-place-birch-mature-2 template-level (+ 1 x) (+ 1 y) z)) (t (level-place-birch-mature-1 template-level (+ 1 x) (+ 1 y) z))) ) (values nil nil) ) (progn ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than two adjacent trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 2) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place grass around trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (if (or (= (aref template-level x y z) +terrain-border-floor+) (= (aref template-level x y z) +terrain-border-grass+)) (setf (aref template-level x y z) +terrain-border-grass+) (setf (aref template-level x y z) +terrain-floor-grass+))))))) (values nil nil nil)))) )) ;;===================== ;; Prisons ;;===================== (set-building-type (make-building :id +building-city-prison-1+ :grid-dim '(4 . 4) :act-dim '(17 . 17) :type +building-type-prison+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,," ",#######.#######," ",#|....-.#...+.#," ",#.....-.#htc-.#," ",#.....-.#|###.#," ",#.....-.#htc-.#," ",#.....-.#...+.#," ",#.....-.#####.#," ",#.....-.......#," ",#+#####h..#####," ",#....|###+##u.#," ",#.............#," ",#-+#-+#-+#-+#.#," ",#..#..#..#..#.#," ",#.b#.b#.b#.b#.#," ",###############," ",,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ############### " " # #|...+.b# " " # #....-..# " " # -....#### " " # #h...+.b# " " # -....-..# " " # #....#### " " # #|.....h# " " #-###-####....# " " #.....|.....d.# " " #.............# " " #-+#-+#-+#-+#.# " " #..#..#..#..#.# " " #.b#.b#.b#.b#.# " " ############### " " ")) (build-template-z-4 (list " " " ............... " " . ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ......... " " ............... " " ............... " " ............... " " ............... " " ............... " " ............... " " ............... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (setf (aref template-level (+ x 7) (+ y 0) z) +terrain-floor-sign-prison+) (values (list (list +mob-type-criminal+ 2 14 z) (list +mob-type-criminal+ 5 14 z) (list +mob-type-criminal+ 8 14 z) (list +mob-type-criminal+ 11 14 z) (list +mob-type-policeman+ 10 2 z) (list +mob-type-policeman+ 10 6 z) (list +mob-type-policeman+ 8 9 z) (list +mob-type-criminal+ 2 14 (+ z 1)) (list +mob-type-criminal+ 5 14 (+ z 1)) (list +mob-type-criminal+ 8 14 (+ z 1)) (list +mob-type-criminal+ 11 14 (+ z 1)) (list +mob-type-criminal+ 14 3 (+ z 1)) (list +mob-type-criminal+ 14 6 (+ z 1)) (list +mob-type-policeman+ 8 5 (+ z 1)) (list +mob-type-policeman+ 14 8 (+ z 1))) nil nil)))) ;;===================== ;; Warehouses ;;===================== (set-building-type (make-building :id +building-city-warehouse-1+ :grid-dim '(4 . 4) :act-dim '(20 . 20) :type +building-type-warehouse+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",##-#####..#####-##," ",#|..............|#," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",..................," ",..................," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",#|..............|#," ",##-#####..#####-##," ",,,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values (list (list +mob-type-man+ 3 3 z) (list +mob-type-man+ 16 3 z) (list +mob-type-man+ 3 16 z) (list +mob-type-man+ 16 16 z)) nil nil)))) ;;===================== ;; Libraries ;;===================== (set-building-type (make-building :id +building-city-library-1+ :grid-dim '(4 . 3) :act-dim '(20 . 13) :type +building-type-library+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "000000000000#######0" "000000000000#BB.BB#0" "000000000000#.....#0" "000000000000#|....#0" "000000000000#####.#0" "0000000000000000#u#0" "0000000000000000###0" "00000000000000000000" )) (build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",##-####-###-###-##," ",#.h.|#..........|#," ",-.t..+..B..B..B..-," ",#....#..B..B..B..#," ",##..##..B..B..B..#," ",`````-..B..B..B..-," ",`````#..B..B..B..#," ",`T```#..B..B..B..#," ",`````-..B..B..####," ",,``T`#|.......+.d#," ",|,```##-###-######," ",,,,,,,,,,,,,,,,,,,," )) (build-template-z-3 (list " " " .................. " " .................. " " .................. " " .................. " " .................. " " ............. " " ............. " " ............. " " ............. " " ............. " " ............. " " " ))) ;; we assume that z = 2 (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 2) (+ y 6) z) +terrain-floor-sign-library+) (values nil (list (list +feature-start-place-book-of-rituals+ 15 6 (- z 1) 1) (list +feature-start-place-civilian-man+ 3 2 z) (list +feature-start-place-civilian-woman+ 10 6 z) (list +feature-start-place-civilian-woman+ 13 8 z) (list +feature-start-place-civilian-woman+ 16 8 z)) nil)))) ;;===================== ;; Port warehouses ;;===================== (set-building-type (make-building :id +building-city-warehouse-port-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",########," ",#|CCCCC#," ",+......+," ",#.CCCC.#," ",#.CCCC.#," ",+......+," ",#CCCCC|#," ",########," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values (list (list +mob-type-man+ 3 3 z) (list +mob-type-man+ 6 6 z)) nil nil)))) (set-building-type (make-building :id +building-city-warehouse-port-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",##+##+##," ",#C....|#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#|....C#," ",##+##+##," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values (list (list +mob-type-man+ 3 6 z) (list +mob-type-man+ 6 3 z)) nil nil)))) ;;===================== ;; Borders ;;===================== (set-building-type (make-building :id +building-city-normal-forest-border+ :grid-dim '(1 . 1) :act-dim '(5 . 5) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) (if (zerop (random 5)) (progn ;; place a large birch tree (let ((r (random 4))) (cond ((= r 3) (level-place-birch-mature-4 template-level (+ 1 x) (+ 1 y) z)) ((= r 2) (level-place-birch-mature-3 template-level (+ 1 x) (+ 1 y) z)) ((= r 1) (level-place-birch-mature-2 template-level (+ 1 x) (+ 1 y) z)) (t (level-place-birch-mature-1 template-level (+ 1 x) (+ 1 y) z))) ) (values nil nil) ) (progn ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than two adjacent trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 2) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place grass around trees (loop for dx from 1 to 3 do (loop for dy from 1 to 3 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (if (or (= (aref template-level x y z) +terrain-border-floor+) (= (aref template-level x y z) +terrain-border-grass+)) (setf (aref template-level x y z) +terrain-border-grass+) (setf (aref template-level x y z) +terrain-floor-grass+))))))) (values nil nil nil)))) )) ;;===================== ;; Stables ;;===================== (set-building-type (make-building :id +building-city-stables-1+ :grid-dim '(3 . 3) :act-dim '(14 . 15) :type +building-type-stables+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,," ",#####,,#####," ",-,,,,,,,,,,-," ",#####,,#####," ",-,,,,,,,,,,-," ",#####,,#####," ",-,,,,,,,,,,-," ",#####,,#####," ",-,,,,,,,,,,-," ",#####,,#####," ",-,,,,,,,,,,-," ",#####,,#####," ",-,,,,,,,,,,-," ",#####--#####," ",,,,,,,,,,,,,," )) (build-template-z-3 (list " " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " ............ " " " ))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values (list (list +mob-type-horse+ 2 2 z) (list +mob-type-horse+ 2 4 z) (list +mob-type-horse+ 2 6 z) (list +mob-type-horse+ 2 8 z) (list +mob-type-horse+ 2 10 z) (list +mob-type-horse+ 2 12 z) (list +mob-type-horse+ 11 2 z) (list +mob-type-horse+ 11 4 z) (list +mob-type-horse+ 11 6 z) (list +mob-type-horse+ 11 8 z) (list +mob-type-horse+ 11 10 z) (list +mob-type-horse+ 11 12 z)) nil nil)))) ;;===================== ;; Mansions ;;===================== (set-building-type (make-building :id +building-city-mansion-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,###-#-###-#-###,," ",,#B..#.|#|.#..c#,," ",,#B..+..u..+..c-,," ",,#B..#c...c#..c#,," ",,##+####-####-##,," ",,#|..#`````````*,," ",,#...+`````````*,," ",,#...#`````````*,," ",,#...#`````````*,," ",,##+##**********,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ###-#####-#.... " " #...#|....#..h. " " #ht.+..d..+..t. " " #|..#BB.BB#..h. " " ##+####-###.... " " #c.|# " " #...- " " #..t- " " #b.h# " " ##-## " " " " ")) (build-template-z-4 (list " " " " " ........... " " ........... " " ........... " " ........... " " ........... " " ..... " " ..... " " ..... " " ..... " " ..... " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 4 4 z) (list +mob-type-woman+ 9 4 z) (list +mob-type-woman+ 14 4 z) (list +mob-type-child+ 4 8 (+ z 1)) (list +mob-type-man+ 5 4 (+ z 1))) nil (list (list +item-type-coin+ 5 4 (+ z 1) (+ 150 (random 151)))))))) (set-building-type (make-building :id +building-city-mansion-2+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,##+##**********,," ",,#...#`````````*,," ",,#...#`````````*,," ",,#...+`````````*,," ",,#|..#`````````*,," ",,##+####-####-##,," ",,#B..#c...c#..c#,," ",,#B..+..u..+..c-,," ",,#B..#.|#|.#..c#,," ",,###-#-###-#-###,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ##-## " " #b.h# " " #..t- " " #...- " " #c.|# " " ##+####-###.... " " #|..#BB.BB#..h. " " #ht.+..d..+..t. " " #...#|....#..h. " " ###-#####-#.... " " " " ")) (build-template-z-4 (list " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ........... " " ........... " " ........... " " ........... " " ........... " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values (list (list +mob-type-man+ 4 9 z) (list +mob-type-woman+ 9 9 z) (list +mob-type-woman+ 14 9 z) (list +mob-type-child+ 4 4 (+ z 1)) (list +mob-type-man+ 5 9 (+ z 1))) nil (list (list +item-type-coin+ 5 9 (+ z 1) (+ 100 (random 101)))))))) ;;===================== ;; Banks ;;===================== (set-building-type (make-building :id +building-city-bank-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-bank+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "000000000000000" "000000000000000" "00###########00" "00#h....h#u.#00" "00#.........#00" "00##+##|##|##00" "00##.########00" "00##+##|##|##00" "00#.........#00" "00#.........#00" "00###########00" "000000000000000" "000000000000000" "000000000000000")) (build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,###########,," ",,#|......d##,," ",,#........|#,," ",,#+##+###+##,," ",,#.#...#...#,," ",,#.#.h.#.h.#,," ",,#+#|t##|t##,," ",,#.........-,," ",,-....hhhhh#,," ",,##++##-####,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ........... " " ........... " " ........... " " ........... " " ........... " " ........... " " ........... " " ........... " " ........... " " ........... " " " " ")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z -1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 6) (+ y 12) z) +terrain-floor-sign-bank+) (values (list (list +mob-type-clerk+ 6 7 z) (list +mob-type-clerk+ 10 7 z) (list +mob-type-policeman+ 3 3 (- z 1)) (list +mob-type-policeman+ 8 3 (- z 1))) nil (list (list +item-type-coin+ 3 9 (- z 1) (+ 50 (random 251))) (list +item-type-coin+ 5 9 (- z 1) (+ 50 (random 251))) (list +item-type-coin+ 7 9 (- z 1) (+ 50 (random 251))) (list +item-type-coin+ 9 9 (- z 1) (+ 50 (random 251))) (list +item-type-coin+ 11 9 (- z 1) (+ 50 (random 251))) ))))) ;;===================== ;; Graveyards ;;===================== (set-building-type (make-building :id +building-city-graveyard-1+ :grid-dim '(4 . 4) :act-dim '(16 . 16) :type +building-type-graveyard+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",*****,,,,*****," ",*,,,,,,,,,,,,*," ",*,G,,G,,G,,G,*," ",*,,,,,,,,,,,,*," ",*,,,,,,,,,,,,*," ",,,G,,G,,G,,G,,," ",,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,," ",,,G,,G,,G,,G,,," ",*,,,,,,,,,,,,*," ",*,,,,,,,,,,,,*," ",*,G,,G,,G,,G,*," ",*,,,,,,,,,,,,*," ",*****,,,,*****," ",,,,,,,,,,,,,,,,")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) ) (values nil nil nil))))
104,455
Common Lisp
.lisp
1,126
27.991119
179
0.145388
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
22a5dde6538201337c71f0772f92c601ec93d4e029bfe7fba34572868f55dfd8
2,895
[ -1 ]
2,896
buildings.lisp
gwathlobal_CotD/src/buildings/buildings.lisp
(in-package :cotd) ;;-------------------------------------- ;; GENERAL BUILDING TYPES ;;-------------------------------------- (defconstant +building-type-none+ 0) (defconstant +building-type-house+ 1) (defconstant +building-type-townhall+ 2) (defconstant +building-type-park+ 3) (defconstant +building-type-lake+ 4) (defconstant +building-type-prison+ 5) (defconstant +building-type-church+ 6) (defconstant +building-type-library+ 7) (defconstant +building-type-warehouse+ 8) (defconstant +building-type-satanists+ 9) (defconstant +building-type-stables+ 10) (defconstant +building-type-mansion+ 11) (defconstant +building-type-bank+ 12) (defconstant +building-type-graveyard+ 13) (defconstant +building-type-ruined-house+ 14) (defconstant +building-type-ruined-townhall+ 15) (defconstant +building-type-ruined-park+ 16) (defconstant +building-type-ruined-prison+ 17) (defconstant +building-type-ruined-warehouse+ 18) (defconstant +building-type-ruined-library+ 19) (defconstant +building-type-ruined-mansion+ 20) (defconstant +building-type-ruined-bank+ 21) (defconstant +building-type-corrupted-house+ 22) (defconstant +building-type-corrupted-townhall+ 23) (defconstant +building-type-corrupted-park+ 24) (defconstant +building-type-corrupted-prison+ 25) (defconstant +building-type-corrupted-warehouse+ 26) (defconstant +building-type-corrupted-library+ 27) (defconstant +building-type-corrupted-mansion+ 28) (defconstant +building-type-corrupted-bank+ 29) (defconstant +building-type-corrupted-graveyard+ 30) (defconstant +building-type-corrupted-shrine+ 31) (defconstant +building-type-crater+ 32) (defconstant +building-type-crater-large+ 33) (defconstant +building-type-hell-structure+ 34) (defconstant +building-type-hell-growth+ 35) (defconstant +building-type-hell-struct-growth+ 36) (defconstant +building-type-hell-machine+ 37) (defconstant +building-type-hell-storage+ 38) (defconstant +building-type-hell-slime-pool+ 39) ;;-------------------------------------- ;; SPECIFIC BUILDING TYPES ;;-------------------------------------- (defconstant +building-city-free+ 0) (defconstant +building-city-reserved+ 1) (defconstant +building-city-house-1+ 2) (defconstant +building-city-house-2+ 3) (defconstant +building-city-house-3+ 4) (defconstant +building-city-house-4+ 5) (defconstant +building-city-townhall-1+ 6) (defconstant +building-city-park-1+ 7) (defconstant +building-city-lake-1+ 8) (defconstant +building-city-park-2+ 9) (defconstant +building-city-prison-1+ 10) (defconstant +building-city-church-1+ 11) (defconstant +building-city-warehouse-1+ 12) (defconstant +building-city-library-1+ 13) (defconstant +building-city-park-3+ 14) (defconstant +building-city-lake-2+ 15) (defconstant +building-city-park-tiny+ 16) (defconstant +building-city-townhall-2+ 17) (defconstant +building-city-townhall-3+ 18) (defconstant +building-city-townhall-4+ 19) (defconstant +building-city-satan-lair-1+ 20) (defconstant +building-city-river+ 21) (defconstant +building-city-bridge+ 22) (defconstant +building-city-pier+ 23) (defconstant +building-city-sea+ 24) (defconstant +building-city-warehouse-port-1+ 25) (defconstant +building-city-warehouse-port-2+ 26) (defconstant +building-city-barricade-ns+ 27) (defconstant +building-city-barricade-we+ 28) (defconstant +building-city-barricade-se+ 29) (defconstant +building-city-barricade-sw+ 30) (defconstant +building-city-barricade-nw+ 31) (defconstant +building-city-barricade-ne+ 32) (defconstant +building-city-stables-1+ 33) (defconstant +building-city-mansion-1+ 34) (defconstant +building-city-mansion-2+ 35) (defconstant +building-city-park-4+ 36) (defconstant +building-city-bank-1+ 37) (defconstant +building-city-graveyard-1+ 38) (defconstant +building-city-church-2+ 39) (defconstant +building-city-normal-forest-border+ 40) (defconstant +building-city-army-post+ 41) (defconstant +building-city-ruined-house-1+ 43) (defconstant +building-city-ruined-house-2+ 44) (defconstant +building-city-ruined-house-3+ 45) (defconstant +building-city-ruined-house-4+ 46) (defconstant +building-city-ruined-townhall-1+ 47) (defconstant +building-city-ruined-townhall-2+ 48) (defconstant +building-city-ruined-townhall-3+ 49) (defconstant +building-city-ruined-townhall-4+ 50) (defconstant +building-city-ruined-park-1+ 51) (defconstant +building-city-ruined-park-2+ 52) (defconstant +building-city-ruined-park-3+ 53) (defconstant +building-city-ruined-park-4+ 54) (defconstant +building-city-ruined-prison-1+ 55) (defconstant +building-city-ruined-warehouse-1+ 56) (defconstant +building-city-ruined-library-1+ 57) (defconstant +building-city-ruined-warehouse-port-1+ 58) (defconstant +building-city-ruined-warehouse-port-2+ 59) (defconstant +building-city-ruined-mansion-1+ 60) (defconstant +building-city-ruined-mansion-2+ 61) (defconstant +building-city-ruined-bank-1+ 62) (defconstant +building-city-sigil-post+ 63) (defconstant +building-city-corrupted-house-1+ 64) (defconstant +building-city-corrupted-house-2+ 65) (defconstant +building-city-corrupted-house-3+ 66) (defconstant +building-city-corrupted-house-4+ 67) (defconstant +building-city-corrupted-townhall-1+ 68) (defconstant +building-city-corrupted-townhall-2+ 69) (defconstant +building-city-corrupted-townhall-3+ 70) (defconstant +building-city-corrupted-townhall-4+ 71) (defconstant +building-city-corrupted-park-1+ 72) (defconstant +building-city-corrupted-park-2+ 73) (defconstant +building-city-corrupted-park-3+ 74) (defconstant +building-city-corrupted-park-4+ 75) (defconstant +building-city-corrupted-prison-1+ 76) (defconstant +building-city-corrupted-warehouse-1+ 77) (defconstant +building-city-corrupted-library-1+ 78) (defconstant +building-city-corrupted-warehouse-port-1+ 79) (defconstant +building-city-corrupted-warehouse-port-2+ 80) (defconstant +building-city-corrupted-mansion-1+ 81) (defconstant +building-city-corrupted-mansion-2+ 82) (defconstant +building-city-corrupted-bank-1+ 83) (defconstant +building-city-corrupted-park-tiny+ 84) (defconstant +building-city-corrupted-graveyard-1+ 85) (defconstant +building-city-corrupted-shrine-1+ 86) (defconstant +building-city-corrupted-forest-border+ 87) (defconstant +building-city-central-lake+ 88) (defconstant +building-city-crater-1+ 89) (defconstant +building-city-crater-2+ 90) (defconstant +building-city-crater-large+ 91) (defconstant +building-city-pier-north+ 92) (defconstant +building-city-pier-south+ 93) (defconstant +building-city-pier-west+ 94) (defconstant +building-city-pier-east+ 95) (defconstant +building-city-hell-border+ 96) (defconstant +building-city-hell-outgrowth-1+ 97) (defconstant +building-city-hell-outgrowth-2+ 98) (defconstant +building-city-hell-outgrowth-3+ 99) (defconstant +building-city-hell-outgrowth-4+ 100) (defconstant +building-city-hell-structure-1+ 101) (defconstant +building-city-hell-structure-2+ 102) (defconstant +building-city-hell-structure-3+ 103) (defconstant +building-city-hell-structure-4+ 104) (defconstant +building-city-hell-struct-growth-1+ 105) (defconstant +building-city-hell-struct-growth-2+ 106) (defconstant +building-city-hell-struct-growth-3+ 107) (defconstant +building-city-hell-struct-growth-4+ 108) (defconstant +building-city-hell-machine-1+ 109) (defconstant +building-city-hell-machine-2+ 110) (defconstant +building-city-hell-machine-3+ 111) (defconstant +building-city-hell-machine-4+ 112) (defconstant +building-city-hell-storage-1+ 113) (defconstant +building-city-hell-slime-pool-1+ 114) (defconstant +building-city-hell-slime-pool-2+ 115) (defparameter *level-grid-size* 5) (defvar *building-types* (make-hash-table)) (defvar *general-building-types* (make-hash-table)) (defstruct building (id) ;; building id (grid-dim) ;; dimensions on a grid map, type (X . Y) (act-dim) ;; dimensions on an actual map, type (X . Y) (func) ;; function that places the building onto the actual map (type +building-type-none+) ) (defun get-building-grid-dim (building) (values (car (building-grid-dim building)) (cdr (building-grid-dim building)))) (defun get-building-act-dim (building) (values (car (building-act-dim building)) (cdr (building-act-dim building)))) (defun set-building-type (building) (destructuring-bind (adx . ady) (building-act-dim building) (destructuring-bind (gdx . gdy) (building-grid-dim building) (when (or (> adx (* gdx *level-grid-size*)) (> ady (* gdy *level-grid-size*))) (error "Grid and actual dimensions do not match!")))) (unless (= (building-type building) +building-type-none+) (setf (gethash (building-type building) *general-building-types*) t)) (setf (gethash (building-id building) *building-types*) building)) (defun get-building-type (building-type-id) (gethash building-type-id *building-types*)) (defun get-all-building-ids-by-type (building-type-id) (loop for building being the hash-values in *building-types* when (eq (building-type building) building-type-id) collect (building-id building))) (defun translate-build-to-template (x y z build-template template-level terrains) (loop for y1 from 0 below (length build-template) do (loop for c across (nth y1 build-template) and x1 from 0 for tt = (case c (#\. +terrain-floor-stone+) (#\# +terrain-wall-stone+) (#\T (if (getf terrains +level-city-terrain-tree+) (funcall (getf terrains +level-city-terrain-tree+)) +terrain-tree-birch+)) (#\, (if (getf terrains +level-city-terrain-dirt+) (funcall (getf terrains +level-city-terrain-dirt+)) +terrain-floor-dirt+)) (#\_ +terrain-water-liquid+) (#\` (if (getf terrains +level-city-terrain-grass+) (funcall (getf terrains +level-city-terrain-grass+)) +terrain-floor-grass+)) (#\- +terrain-wall-window+) (#\h +terrain-floor-chair+) (#\t +terrain-floor-table+) (#\b +terrain-floor-bed+) (#\c +terrain-floor-cabinet+) (#\C +terrain-floor-crate+) (#\B +terrain-floor-bookshelf+) (#\+ +terrain-door-closed+) (#\' +terrain-door-open+) (#\0 (if (getf terrains +level-city-terrain-earth+) (funcall (getf terrains +level-city-terrain-earth+)) +terrain-wall-earth+)) (#\X +terrain-wall-corrupted+) (#\Space +terrain-floor-air+) (#\u +terrain-slope-stone-up+) (#\d +terrain-slope-stone-down+) (#\* (if (getf terrains +level-city-terrain-bush+) (funcall (getf terrains +level-city-terrain-bush+)) +terrain-wall-bush+)) (#\| +terrain-wall-lantern+) (#\G +terrain-wall-grave+) (#\g +terrain-floor-glass+) (#\% +terrain-wall-raw-flesh+) (#\~ +terrain-floor-slime+)) when tt do (setf (aref template-level (+ x x1) (+ y y1) z) tt)))) (defun level-city-reserve-build-on-grid (template-building-id gx gy gz reserved-level &key (force-remove t)) (destructuring-bind (dx . dy) (building-grid-dim (get-building-type template-building-id)) (let ((building (list template-building-id gx gy gz))) (loop for y1 from 0 below dy do (loop for x1 from 0 below dx for building-to-remove = (aref reserved-level (+ gx x1) (+ gy y1) gz) do (when (and force-remove (listp building-to-remove) building-to-remove) (level-city-remove-build-from-grid building-to-remove reserved-level)) (setf (aref reserved-level (+ gx x1) (+ gy y1) gz) building))) building))) (defun level-city-remove-build-from-grid (building reserved-level) (let ((template-building-id (first building)) (gx (second building)) (gy (third building)) (gz (fourth building))) (destructuring-bind (dx . dy) (building-grid-dim (get-building-type template-building-id)) (loop for y1 from 0 below dy do (loop for x1 from 0 below dx do (setf (aref reserved-level (+ gx x1) (+ gy y1) gz) nil)))))) (defun level-city-can-place-build-on-grid (template-building-id gx gy gz reserved-level) (destructuring-bind (dx . dy) (building-grid-dim (get-building-type template-building-id)) ;; if the staring point of the building + its dimensions) is more than level dimensions - fail (when (or (> (+ gx dx) (array-dimension reserved-level 0)) (> (+ gy dy) (array-dimension reserved-level 1))) (return-from level-city-can-place-build-on-grid nil)) ;; if any of the grid tiles that the building is going to occupy are already reserved - fail (loop for y1 from 0 below dy do (loop for x1 from 0 below dx do (when (not (eq (aref reserved-level (+ gx x1) (+ gy y1) gz) nil)) (return-from level-city-can-place-build-on-grid nil)) )) ;; all checks done - success t )) (defun level-place-birch-mature-1 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-grass+) ;; z = 3 (setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-grass+) ) (defun level-place-birch-mature-2 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-grass+) ;; z = 3 (setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-grass+) ) (defun level-place-birch-mature-3 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-grass+) ;; z = 3 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 (setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-branches+) ) (defun level-place-birch-mature-4 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-grass+) ;; z = 3 (setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 (setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-tree-birch-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;; z = 5 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 3)) +terrain-floor-branches+) ) (defun level-place-oak-mature-1 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 3) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-oak-trunk-nw+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-tree-oak-trunk-sw+) (setf (aref template-level (+ x 1) (+ y 3) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-tree-oak-trunk-ne+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-tree-oak-trunk-se+) (setf (aref template-level (+ x 2) (+ y 3) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 0) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 1) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 2) (+ z 0)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 3) (+ z 0)) +terrain-floor-grass+) ;; z = 3 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 3) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-tree-oak-trunk-nw+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-oak-trunk-sw+) (setf (aref template-level (+ x 1) (+ y 3) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-tree-oak-trunk-ne+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-tree-oak-trunk-se+) (setf (aref template-level (+ x 2) (+ y 3) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 3) (+ y 0) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 1) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 3) (+ y 2) (+ z 1)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 3) (+ y 3) (+ z 1)) +terrain-floor-grass+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 0) (+ y 3) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-tree-oak-trunk-nw+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-tree-oak-trunk-sw+) (setf (aref template-level (+ x 1) (+ y 3) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-tree-oak-trunk-ne+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-tree-oak-trunk-se+) (setf (aref template-level (+ x 2) (+ y 3) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 3) (+ y 0) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 3) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 3) (+ y 3) (+ z 2)) +terrain-floor-grass+) ;; z = 5 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 3)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 3) (+ z 3)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 3) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 3)) +terrain-floor-branches+) (setf (aref template-level (+ x 2) (+ y 3) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 3) (+ y 0) (+ z 3)) +terrain-floor-grass+) (setf (aref template-level (+ x 3) (+ y 1) (+ z 3)) +terrain-floor-leaves+) (setf (aref template-level (+ x 3) (+ y 2) (+ z 3)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 3) (+ y 3) (+ z 3)) +terrain-floor-grass+) ) (defun level-place-twintube-corrupted-1 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-creep+) ;; z = 3 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-grass+) ) (defun level-place-twintube-corrupted-2 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-creep+) ;; z = 3 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-floor-leaves+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-grass+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-floor-leaves+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-grass+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-grass+) ) (defun level-place-twintube-corrupted-3 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-creep+) ;; z = 3 (setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-floor-grass+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;; z = 4 (setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-leaves+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ) (defun level-place-twintube-corrupted-4 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-creep+) ;; z = 3 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;; z = 4 ;;(setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) ;;(setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ) (defun level-place-twintube-mutated-1 (template-level x y z) ;; (0, 0) is the top left corner ;; z = 2 (setf (aref template-level (+ x 0) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 0) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 0)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 1) (+ z 0)) +terrain-floor-creep+) (setf (aref template-level (+ x 2) (+ y 2) (+ z 0)) +terrain-floor-creep+) ;; z = 3 (setf (aref template-level (+ x 0) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 1) (+ y 1) (+ z 1)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 1)) +terrain-tree-twintube-trunk+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 1)) +terrain-tree-twintube-trunk+) ;; z = 4 (setf (aref template-level (+ x 0) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 0) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 1) (+ y 1) (+ z 2)) +terrain-floor-branches+) (setf (aref template-level (+ x 1) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) (setf (aref template-level (+ x 2) (+ y 0) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 1) (+ z 2)) +terrain-floor-twintube-branches+) ;;(setf (aref template-level (+ x 2) (+ y 2) (+ z 2)) +terrain-floor-twintube-branches+) )
41,150
Common Lisp
.lisp
651
57.821813
109
0.608513
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
25e7c5ef44d00d7a84b79e6c8eccdac76aa9721f63a0103dc015f00ace192f89
2,896
[ -1 ]
2,897
init-ruined-building-types.lisp
gwathlobal_CotD/src/buildings/init-ruined-building-types.lisp
(in-package :cotd) ;;===================== ;; Runied houses ;;===================== (set-building-type (make-building :id +building-city-ruined-house-1+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-ruined-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",,.#####," ",....u##," ",.h....#," ",####|.#," ",-ht...#," ",#....c#," ",.##+###," ",,,,,,,,,")) (build-template-z-3 (list " " " #-### " " ..d.# " " c....# " " ####|.# " " #b....# " " ..h..h# " " ..-### " " ")) (build-template-z-4 (list " " " ..... " " ..... " " ...... " " ....... " " ....... " " ..... " " .... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil )))) (set-building-type (make-building :id +building-city-ruined-house-2+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-ruined-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",#c...t#," ",#..|...," ",+..#..,," ",#.u#...," ",-.##ht#," ",#######," ",,,,,,,,,")) (build-template-z-3 (list " " " ##-#### " " #c...b. " " #..|. " " #..#. " " #.d#.. " " #..#bc# " " ##-#### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ..... " " .... " " ..... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-house-3+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-ruined-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",#######," ",##u#ht-," ",#..#..#," ",-..#..+," ",#t.|..#," ",.....c#," ",,..####," ",,,,,,,,,")) (build-template-z-3 (list " " " ####### " " #.d#cb# " " #..#..# " " -..#..- " " #..|.b# " " ...c# " " #### " " ")) (build-template-z-4 (list " " " ....... " " ....... " " ....... " " ....... " " ....... " " ..... " " .... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-house-4+ :grid-dim '(2 . 2) :act-dim '(9 . 9) :type +building-type-ruined-house+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,," ",###..,,," ",#c....,," ",#......," ",#.|####," ",#....##," ",#cb..u#," ",#####-#," ",,,,,,,,,")) (build-template-z-3 (list " " " ### " " #c... " " #.... " " #.|#### " " #.....# " " -th..d# " " ####### " " ")) (build-template-z-4 (list " " " .... " " ..... " " ....... " " ....... " " ....... " " ....... " " ....... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined townhalls ;;===================== (set-building-type (make-building :id +building-city-ruined-townhall-1+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-ruined-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",####......####," ",#```......```#," ",#```......```#," ",#```......```#," ",##-###..###-##," ",#|..#c..c#..|.," ",#...+....+...,," ",##u.#|..|#...,," ",###-##--##.,,,," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .... .... " " . . " " . . " " . . " " ##-###-###.... " " #..|#|...#... " " #...+....+.. " " #.d.#c.ht#.. " " ###-##-###. " " ")) (build-template-z-4 (list " " " " " " " " " " " .......... " " .......... " " .......... " " .......... " " .......... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-townhall-2+ :grid-dim '(4 . 3) :act-dim '(16 . 11) :type +building-type-ruined-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,," ",###-##--##-###," ",#ht.#|..|#.u##," ",#...+....+...,," ",#|..#c..c#...,," ",##-###..###..,," ",#```......```,," ",#```......```#," ",,```......```#," ",,,##......####," ",,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ....###-##-### " " ....#th.c#.d.# " " ....+....+... " " ....#...|#|. " " ....###-### " " . " " . . " " . " " .. .... " " ")) (build-template-z-4 (list " " " .......... " " .......... " " .......... " " .......... " " .......... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-townhall-3+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-ruined-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",#########," ",##..#```#," ",#u..-```#," ",-..|#```#," ",##+##....," ",....#....," ",.........," ",.........," ",....#....," ",##+##....," ",-..|#```#," ",#t..-```#," ",#h..#```#," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " #####.... " " #..|# . " " #d..- . " " -...# . " " ##+## " " ..# " " .- " " .# " " ..# " " ##+## " " ..... . " " ..... . " " ..... . " " ......... " " ")) (build-template-z-4 (list " " " ..... " " ..... " " ..... " " ..... " " .... " " ... " " .... " " ..... " " ..... " " ..... " " " " " " " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-townhall-4+ :grid-dim '(3 . 4) :act-dim '(11 . 16) :type +building-type-ruined-townhall+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,," ",,,,,,..##," ",,```...h#," ",,```...t#," ",,```#...#," ",....##+##," ",....#c.|#," ",........-," ",........-," ",....#c.|#," ",....##+##," ",#```#...-," ",#```-..u#," ",#```#|.##," ",#########," ",,,,,,,,,,,")) (build-template-z-3 (list " " " .. " " ... " " .... " " ..... " " ##+## " " #..t# " " #..h# " " -...- " " #|.c# " " ##+## " " . #|..- " " . -..d# " " . #...# " " ....##### " " ")) (build-template-z-4 (list " " " " " " " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " ..... " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined parks ;;===================== (set-building-type (make-building :id +building-city-ruined-park-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-ruined-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,,```" "```T````T`" "`T```T````" "``````T`,," "``T`````,," ",````T````" ",`|`````T`" ",`````````" ",,`T``T`,," ",,``````,,"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-park-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-ruined-park+ :func #'(lambda (x y z template-level terrains) (let ((build-template (list ",,```,```," "```T```T`," "`T```T````" "```T``````" "`T````T```" "````T```,," ",`T```T`,," ",`````````" ",`T`T`,`T`" ",`````,```"))) (translate-build-to-template x y z build-template template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-park-3+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-ruined-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place a large birch tree (let ((dx (random 8)) (dy (random 8)) (r (random 5))) (cond ((= r 4) (level-place-birch-mature-4 template-level (+ dx x) (+ dy y) z)) ((= r 3) (level-place-birch-mature-3 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-birch-mature-2 template-level (+ dx x) (+ dy y) z)) ((= r 2) (level-place-birch-mature-1 template-level (+ dx x) (+ dy y) z)) (t nil)) ) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-grass+)))))) ;; find a place to position citizens (values nil nil nil) ))) (set-building-type (make-building :id +building-city-ruined-park-4+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-ruined-park+ :func #'(lambda (x y z template-level terrains) (declare (ignore terrains)) ;; populate the area with trees, leaving the border untouched (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (zerop (random 3)) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+)))) ;; make sure that each tree has no more than one adjacent tree (loop for dx from 1 to 8 do (loop for dy from 1 to 8 with tree-num do (setf tree-num 0) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (when (= (aref template-level x y z) +terrain-tree-birch+) (incf tree-num)))) (when (> tree-num 1) (setf (aref template-level (+ x dx) (+ y dy) z) +terrain-floor-dirt+)))) ;; place grass around trees (loop for dx from 1 to 8 do (loop for dy from 1 to 8 do (when (= (aref template-level (+ x dx) (+ y dy) z) +terrain-tree-birch+) (check-surroundings (+ x dx) (+ y dy) nil #'(lambda (x y) (setf (aref template-level x y z) +terrain-floor-grass+)))))) ;; place a large oak tree (let ((dx (random 7)) (dy (random 7))) (cond (t (level-place-oak-mature-1 template-level (+ dx x) (+ dy y) z))) ) ;; find a place to position citizens (values nil nil nil) ))) ;;===================== ;; Ruined prisons ;;===================== (set-building-type (make-building :id +building-city-ruined-prison-1+ :grid-dim '(4 . 4) :act-dim '(17 . 17) :type +building-type-ruined-prison+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,," ",,.#####.#######," ",......-.#...+.#," ",#.....-.#htc-.#," ",#.....-.#|###.#," ",#.....-.#htc-.#," ",#.....-.#...+.#," ",#.....-.#####.#," ",#.....-........," ",#+#####h..###.,," ",#....|###+##u..," ",#..............," ",#-+#-+#-+#-+#.#," ",...#..#..#..#.#," ",...#.b#.b#.b#.#," ",,..############," ",,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " ############# " " #|...+.b# " " # #....-..# " " # -....#### " " # #h...+.b# " " # -....-..# " " # #....#### " " # #|.....h " " #-###-####... " " #.....|.....d. " " #.............# " " #-+#-+#-+#-+#.# " " ..#..#..#..#.# " " #.b#.b#.b#.# " " ############ " " ")) (build-template-z-4 (list " " " ............. " " ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ......... " " . ........ " " ............. " " .............. " " ............... " " ............... " " .............. " " ............ " " ............ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (setf (aref template-level (+ x 7) (+ y 0) z) +terrain-floor-sign-prison+) (values nil nil nil)))) ;;===================== ;; Ruined warehouses ;;===================== (set-building-type (make-building :id +building-city-ruined-warehouse-1+ :grid-dim '(4 . 4) :act-dim '(20 . 20) :type +building-type-ruined-warehouse+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",##-#####..#####-##," ",#|..............|#," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..####....####..#," ",..................," ",..................," ",#..####....####..#," ",#..CCCCCCCCCCCC..#," ",-................-," ",#..CCCCCCCCCCCC..#," ",#..############..#," ",#..CCCCCCCCCCCC..#," ",#|..............|#," ",##-#####..#####-##," ",,,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " ....... ....... " " ...... ...... " " ...... ...... " " ....... ....... " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " .................. " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined libraries ;;===================== (set-building-type (make-building :id +building-city-ruined-library-1+ :grid-dim '(4 . 3) :act-dim '(20 . 13) :type +building-type-ruined-library+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "00000000000000000000" "000000000000#######0" "000000000000#BB.BB#0" "000000000000#.....#0" "000000000000#|....#0" "000000000000#####.#0" "0000000000000000#u#0" "0000000000000000###0" "00000000000000000000" )) (build-template-z-2 (list ",,,,,,,,,,,,,,,,,,,," ",,..####-###-###-##," ",..h.|#..........|#," ",..t..+..B..B..B..-," ",#....#..B..B..B..#," ",##..##..B..B..B..#," ",`````-..B..B..B..-," ",`````#..B..B..B..#," ",`T```#..B..B..B..#," ",`````-..B..B..#...," ",,``T`#|.........d.," ",|,```##-###-##....," ",,,,,,,,,,,,,,,,,,,," )) (build-template-z-3 (list " " " ............... " " ................ " " ................. " " .................. " " .................. " " ............. " " ............. " " ............. " " ........... " " .......... " " .......... " " " ))) ;; we assume that z = 2 (translate-build-to-template x y (- z 1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 2) (+ y 6) z) +terrain-floor-sign-library+) (values nil nil nil)))) ;;===================== ;; Ruined port warehouses ;;===================== (set-building-type (make-building :id +building-city-ruined-warehouse-port-1+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",########," ",#|CCCCC#," ",+......+," ",#.CCCC.#," ",#.CCCC.#," ",+......+," ",#CCCCC|#," ",########," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-warehouse-port-2+ :grid-dim '(2 . 2) :act-dim '(10 . 10) :type +building-type-none+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,," ",##+##+##," ",#C....|#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#C.CC.C#," ",#|....C#," ",##+##+##," ",,,,,,,,,,")) (build-template-z-3 (list " " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " ........ " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined mansions ;;===================== (set-building-type (make-building :id +building-city-ruined-mansion-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-ruined-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,###-#-###-#-.,,,," ",,#B..#.|#|.#...,,," ",,#B..+..u..+....,," ",,#B..#c...c#...,,," ",,##+####-####.,,,," ",,#|..#`````````*,," ",,#...+`````````*,," ",,#...#`````````,,," ",,#...#`````````,,," ",,##+##****,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ###-#####-#.. " " #...#|....#.. " " #ht.+..d..+.. " " #|..#BB.BB#.. " " ##+####-###. " " #c.|# " " #...- " " #..t- " " #b.h# " " ##-## " " " " ")) (build-template-z-4 (list " " " " " ........... " " ........... " " ........... " " ........... " " ........... " " ..... " " ..... " " ..... " " ..... " " ..... " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) (set-building-type (make-building :id +building-city-ruined-mansion-2+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-ruined-mansion+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-2 (list ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,," ",,##+##**********,," ",,#...#`````````*,," ",,#...#`````````*,," ",,#...+`````````*,," ",,#|..#`````````*,," ",,##+####-####-##,," ",,#B..#c...c#..c#,," ",,#B..+..u..+..c-,," ",,,...#.|#|.#..c#,," ",,,,..#-###-#-###,," ",,,,,,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ##-## " " #b.h# " " #..t- " " #...- " " #c.|# " " ##+####-###.... " " #|..#BB.BB#..h. " " #ht.+..d..+..t. " " .#|....#..h. " " #####-#.... " " " " ")) (build-template-z-4 (list " " " " " ..... " " ..... " " ..... " " ..... " " ..... " " ........... " " ........... " " ........... " " ......... " " ........ " " " " "))) ;; we assume that z = 2 (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) (translate-build-to-template x y (+ z 2) build-template-z-4 template-level terrains) ) (values nil nil nil)))) ;;===================== ;; Ruined banks ;;===================== (set-building-type (make-building :id +building-city-ruined-bank-1+ :grid-dim '(4 . 3) :act-dim '(19 . 14) :type +building-type-ruined-bank+ :func #'(lambda (x y z template-level terrains) (let ((build-template-z-1 (list "000000000000000" "000000000000000" "00###########00" "00#h....h#u.#00" "00#.........#00" "00##+##|#,,,uu0" "00##.####,,,,u0" "00##+##|#,,,,u0" "00#.......,,uu0" "00#.........u00" "00###########00" "000000000000000" "000000000000000" "000000000000000")) (build-template-z-2 (list ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,," ",,###########,," ",,#|......d##,," ",,#..........,," ",,#+##+## dd," ",,#.#...# d," ",,#.#.h.# d," ",,#+#|t## dd," ",,#....... d.," ",,-....hhhh..,," ",,##++##-####,," ",,,,,,,,,,,,,,," ",,,,,,,,,,,,,,,")) (build-template-z-3 (list " " " " " ........... " " ........... " " .......... " " ......... " " ........ " " ........ " " ......... " " .......... " " ........... " " ........... " " " " ")) ) ;; we assume that z = 2 (translate-build-to-template x y (+ z -1) build-template-z-1 template-level terrains) (translate-build-to-template x y (+ z 0) build-template-z-2 template-level terrains) (translate-build-to-template x y (+ z 1) build-template-z-3 template-level terrains) ) (setf (aref template-level (+ x 6) (+ y 12) z) +terrain-floor-sign-bank+) (values nil nil nil))))
78,896
Common Lisp
.lisp
874
25.938215
150
0.124767
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ca0cafe50074ff06a6a44335cf561a113cf4c7ab7ea255e5fe9b478cebc83db3
2,897
[ -1 ]
2,898
init-game-events-military-raid.lisp
gwathlobal_CotD/src/game-events/init-game-events-military-raid.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-military-raid-win-for-angels+ :descr-func #'(lambda () "To win, destroy all demons in the district. To lose, have all angels killed.") :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (zerop (total-demons (level world)))) (and (/= (loyal-faction *player*) +faction-type-angels+) (zerop (nth +faction-type-satanists+ (total-faction-list (level world)))) (> (total-angels (level world)) 0) (zerop (total-demons (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1400 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-angels-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-raid-win-for-demons+ :descr-func #'(lambda () "To win, destroy all angels and military in the district. To lose, have all demons killed.") :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world)))) (zerop (total-angels (level world)))) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world)))) (zerop (nth +faction-type-church+ (total-faction-list (level world)))) (zerop (total-angels (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-raid-win-for-military+ :descr-func #'(lambda () "To win, destroy all demons in the district. To lose, have all military killed.") :disabled nil :on-check #'(lambda (world) (if (and (> (total-humans (level world)) 0) (zerop (total-demons (level world)))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (= (loyal-faction *player*) +faction-type-military+) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1500 (* 7 (total-humans (level world))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-military-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-raid-win-for-satanists+ :descr-func #'(lambda () "To win, destroy all angels and military in the district. To lose, have all demons and satanists killed.") :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-satanists+) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (zerop (total-angels (level world))) (zerop (nth +faction-type-military+ (total-faction-list (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "District successfully defended by demons." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-satanists-won)) )))
12,289
Common Lisp
.lisp
117
36.837607
167
0.251664
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
11755b001727bd818645e0a40c19511795ee0bc9b6be31ba79ed8a846eaf6c10
2,898
[ -1 ]
2,899
init-game-events-military-sabotage.lisp
gwathlobal_CotD/src/game-events/init-game-events-military-sabotage.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-military-sabotage-win-for-military+ :descr-func #'(lambda () (format nil "To win, destroy all of raw flesh storages in the district. You can do it by using a Bomb item next to the Target bomb location. To lose, have all military killed or possessed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-military+) (> (nth +faction-type-military+ (total-faction-list (level world))) 0) (null (bomb-plant-locations (level world)))) (and (/= (loyal-faction *player*) +faction-type-military+) (> (nth +faction-type-military+ (total-faction-list (level world))) 0) (null (bomb-plant-locations (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (= (loyal-faction *player*) +faction-type-military+) t nil))) (trigger-game-over world :final-str "Raw flesh storages successfully sabotaged." :score (calculate-player-score (+ 1450 0)) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-military-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-sabotage-win-for-demons+ :descr-func #'(lambda () (format nil "To win, destroy all military. To lose, have all raw flesh storages destroyed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world)))) (bomb-plant-locations (level world))) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world)))) (bomb-plant-locations (level world)))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Raw flesh storages successfully defended by demons." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) )))
6,044
Common Lisp
.lisp
59
40.508475
250
0.283517
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
c2b71da18e9a07fa2423cc972f8e82af57202267178d21623bc3e5478b1343ce
2,899
[ -1 ]
2,900
init-game-events-military-conquest.lisp
gwathlobal_CotD/src/game-events/init-game-events-military-conquest.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-military-conquest-win-for-angels+ :descr-func #'(lambda () (format nil "To win, destroy all demonic sigils in the district. To lose, have all angels killed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (null (get-military-conquest-check-alive-sigils (level world)))) (and (/= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (null (get-military-conquest-check-alive-sigils (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "District successfully conquered back." :score (calculate-player-score (+ 1400 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-angels-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-conquest-win-for-demons+ :descr-func #'(lambda () (format nil "To win, destroy all angels and military in the district. To lose, have all demonic sigils destroyed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (total-angels (level world))) (zerop (nth +faction-type-military+ (total-faction-list (level world))))) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world)))) (zerop (nth +faction-type-church+ (total-faction-list (level world)))) (zerop (total-angels (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "District successfully defended by demons." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-conquest-win-for-military+ :descr-func #'(lambda () (format nil "To win, destroy all demonic sigils in the district. To lose, have all military killed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-military+) (> (nth +faction-type-military+ (total-faction-list (level world))) 0) (null (get-military-conquest-check-alive-sigils (level world)))) (and (/= (loyal-faction *player*) +faction-type-military+) (> (nth +faction-type-military+ (total-faction-list (level world))) 0) (null (get-military-conquest-check-alive-sigils (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (= (loyal-faction *player*) +faction-type-military+) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1450 (* 7 (total-humans (level world))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-military-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-military-conquest-win-for-satanists+ :descr-func #'(lambda () "To win, destroy all angels and military in the district. To lose, have all demonic sigils destroyed.") :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-satanists+) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (zerop (total-angels (level world))) (zerop (nth +faction-type-military+ (total-faction-list (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "District successfully defended by demons." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) )))
12,910
Common Lisp
.lisp
120
39.325
175
0.264216
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
cbd624077984c16435fecdc12373eb106c71b9e746d29ec7681c7769e03b7dc6
2,900
[ -1 ]
2,901
game-events.lisp
gwathlobal_CotD/src/game-events/game-events.lisp
(in-package :cotd) (defparameter *game-events* (make-hash-table)) (defconstant +game-event-demon-attack-win-for-angels+ 0) (defconstant +game-event-demon-attack-win-for-demons+ 1) (defconstant +game-event-demon-attack-win-for-military+ 2) (defconstant +game-event-lose-game-died+ 3) (defconstant +game-event-snow-falls+ 4) (defconstant +game-event-lose-game-possessed+ 5) (defconstant +game-event-adjust-outdoor-light+ 6) (defconstant +game-event-win-for-thief+ 7) (defconstant +game-event-rain-falls+ 8) (defconstant +game-event-win-for-eater+ 9) (defconstant +game-event-win-for-ghost+ 10) (defconstant +game-event-unnatural-darkness+ 11) (defconstant +game-event-constant-reanimation+ 12) (defconstant +game-event-hellday+ 13) (defconstant +game-event-acid-falls+ 14) (defconstant +game-event-player-died+ 15) (defconstant +game-event-demon-attack-win-for-church+ 16) (defconstant +game-event-demon-attack-win-for-satanists+ 17) (defconstant +game-event-demon-raid-win-for-angels+ 18) (defconstant +game-event-demon-raid-win-for-demons+ 19) (defconstant +game-event-demon-raid-win-for-military+ 20) (defconstant +game-event-demon-raid-win-for-church+ 21) (defconstant +game-event-demon-raid-win-for-satanists+ 22) (defconstant +game-event-demon-steal-win-for-angels+ 23) (defconstant +game-event-demon-steal-win-for-demons+ 24) (defconstant +game-event-demon-steal-win-for-military+ 25) (defconstant +game-event-demon-steal-win-for-church+ 26) (defconstant +game-event-demon-steal-win-for-satanists+ 27) (defconstant +game-event-demon-conquest-win-for-angels+ 28) (defconstant +game-event-demon-conquest-win-for-demons+ 29) (defconstant +game-event-demon-conquest-win-for-military+ 30) (defconstant +game-event-demon-conquest-win-for-church+ 31) (defconstant +game-event-demon-conquest-win-for-satanists+ 32) (defconstant +game-event-military-conquest-win-for-angels+ 33) (defconstant +game-event-military-conquest-win-for-demons+ 34) (defconstant +game-event-military-conquest-win-for-military+ 35) (defconstant +game-event-military-conquest-win-for-satanists+ 36) (defconstant +game-event-military-raid-win-for-angels+ 37) (defconstant +game-event-military-raid-win-for-demons+ 38) (defconstant +game-event-military-raid-win-for-military+ 39) (defconstant +game-event-military-raid-win-for-satanists+ 40) (defconstant +game-event-angelic-steal-win-for-angels+ 41) (defconstant +game-event-angelic-steal-win-for-demons+ 42) (defconstant +game-event-angelic-steal-win-for-military+ 43) (defconstant +game-event-angelic-steal-win-for-satanists+ 44) (defconstant +game-event-delayed-arrival-military+ 45) (defconstant +game-event-delayed-arrival-angels+ 46) (defconstant +game-event-delayed-arrival-demons+ 47) (defconstant +game-event-campaign-demon-win+ 48) (defconstant +game-event-campaign-military-win+ 49) (defconstant +game-event-campaign-angel-win+ 50) (defconstant +game-event-eliminate-satanists-win-for-angels+ 51) (defconstant +game-event-eliminate-satanists-win-for-demons+ 52) (defconstant +game-event-eliminate-satanists-win-for-military+ 53) (defconstant +game-event-eliminate-satanists-win-for-church+ 54) (defconstant +game-event-eliminate-satanists-win-for-satanists+ 55) (defconstant +game-event-campaign-satanists-move+ 56) (defconstant +game-event-campaign-flesh-gathered+ 57) (defconstant +game-event-campaign-move-military+ 58) (defconstant +game-event-campaign-move-demons+ 59) (defconstant +game-event-angelic-sabotage-win-for-angels+ 60) (defconstant +game-event-angelic-sabotage-win-for-demons+ 61) (defconstant +game-event-military-sabotage-win-for-demons+ 62) (defconstant +game-event-military-sabotage-win-for-military+ 63) (defconstant +game-event-campaign-trigger-commands+ 64) (defconstant +game-event-campaign-move-relic-to-church+ 65) (defconstant +game-event-malseraphs-power-infusion+ 66) (defconstant +game-event-campaign-malseraphs-focus+ 67) (defconstant +game-event-win-for-eater-consume+ 68) (defenum:defenum game-over-enum (:game-over-player-dead :game-over-demons-won :game-over-angels-won :game-over-military-won :game-over-church-won :game-over-satanists-won :game-over-player-possessed :game-over-thief-won :game-over-eater-won :game-over-ghost-won)) (defenum:defenum campaign-over-enum (:campaign-over-demons-conquer :campaign-over-demons-gather :campaign-over-angels-won :campaign-over-military-won )) (defclass game-event () ((id :initarg :id :accessor id) (descr-func :initarg :descr-func :accessor descr-func) ;; a lambda with no params (disabled :initform nil :initarg :disabled :accessor disabled) (on-check :initarg :on-check :accessor on-check) (on-trigger :initarg :on-trigger :accessor on-trigger))) (defun set-game-event (game-event) (setf (gethash (id game-event) *game-events*) game-event)) (defun get-game-event-by-id (game-event-id) (gethash game-event-id *game-events*))
5,426
Common Lisp
.lisp
96
49.385417
85
0.710189
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
13fed7e72de1ac8c6a48621c48b11f880963435eb55e8deddb4018176e045e84
2,901
[ -1 ]
2,902
init-game-events-campaign-win.lisp
gwathlobal_CotD/src/game-events/init-game-events-campaign-win.lisp
(in-package :cotd) (set-game-event (make-instance 'game-event :id +game-event-campaign-demon-win+ :descr-func #'(lambda () (let ((max-flesh-points (win-condition/win-formula (get-win-condition-by-id :win-cond-demon-campaign)))) (format nil "To win:~% - collect ~A pts of flesh, or~% - corrupt all districts in the City.~%~%To lose:~% - have all dimensional engines shattered, or ~% - let the satanists' lair be destroyed while having no corrupted districts in the City." max-flesh-points))) :disabled nil :on-check #'(lambda (world) (let* ((win-condition (get-win-condition-by-id :win-cond-demon-campaign)) (max-flesh-points (win-condition/win-formula win-condition)) (normal-sectors-left (funcall (win-condition/win-func win-condition) world win-condition))) (if (or (>= (world/flesh-points world) max-flesh-points) (<= normal-sectors-left 0)) t nil))) :on-trigger #'(lambda (world) (let* ((win-condition (get-win-condition-by-id :win-cond-demon-campaign)) (normal-sectors-left (funcall (win-condition/win-func win-condition) world win-condition)) (demon-win-type)) (cond ((<= normal-sectors-left 0) (setf demon-win-type :campaign-over-demons-conquer)) (t (setf demon-win-type :campaign-over-demons-gather))) (setf *current-window* (make-instance 'campaign-over-window :campaign-over-type demon-win-type :player-won (eq (get-general-faction-from-specific (world/player-specific-faction world)) +faction-type-demons+))) (make-output *current-window*) (run-window *current-window*)) ))) (set-game-event (make-instance 'game-event :id +game-event-campaign-military-win+ :descr-func #'(lambda () (let ((max-flesh-points (win-condition/win-formula (get-win-condition-by-id :win-cond-demon-campaign)))) (format nil "To win, reconquer corrupted districts while all satanists' lairs are destroyed.~%To lose, let the demons capture all districts in the City or gather ~A pts of flesh." max-flesh-points))) :disabled nil :on-check #'(lambda (world) (let* ((win-condition (get-win-condition-by-id :win-cond-military-campaign))) (multiple-value-bind (corrupted-sectors-left satanist-lairs-left) (funcall (win-condition/win-func win-condition) world win-condition) (if (and (<= corrupted-sectors-left 0) (<= satanist-lairs-left 0)) t nil)) )) :on-trigger #'(lambda (world) (setf *current-window* (make-instance 'campaign-over-window :campaign-over-type :campaign-over-military-won :player-won (eq (get-general-faction-from-specific (world/player-specific-faction world)) +faction-type-military+))) (make-output *current-window*) (run-window *current-window*) ))) (set-game-event (make-instance 'game-event :id +game-event-campaign-angel-win+ :descr-func #'(lambda () (let ((max-flesh-points (win-condition/win-formula (get-win-condition-by-id :win-cond-demon-campaign)))) (format nil "To win, destroy all dimensional engines that enable the Pandemonium to escape the Prison Dimension.~%To lose, let the demons capture all districts in the City or gather ~A pts of flesh." max-flesh-points))) :disabled nil :on-check #'(lambda (world) (let* ((win-condition (get-win-condition-by-id :win-cond-angels-campaign)) (machines-left (funcall (win-condition/win-func win-condition) world win-condition))) (if (<= machines-left 0) t nil))) :on-trigger #'(lambda (world) (setf *current-window* (make-instance 'campaign-over-window :campaign-over-type :campaign-over-angels-won :player-won (eq (get-general-faction-from-specific (world/player-specific-faction world)) +faction-type-angels+))) (make-output *current-window*) (run-window *current-window*) )))
7,028
Common Lisp
.lisp
62
55.983871
323
0.375269
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
ba23144355e30ac1e45e8cb69cf28c2f600fdc6a7c68a55f5b1c805513380144
2,902
[ -1 ]
2,903
init-game-events-angelic-sabotage.lisp
gwathlobal_CotD/src/game-events/init-game-events-angelic-sabotage.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-angelic-sabotage-win-for-angels+ :descr-func #'(lambda () (format nil "To win, destroy all demonic machines in the district. To lose, have all angels killed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (null (get-angel-sabotage-check-alive-machines (level world)))) (and (/= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (null (get-angel-sabotage-check-alive-machines (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "Dimensional engines successfully destroyed." :score (calculate-player-score (+ 1400 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-angels-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-angelic-sabotage-win-for-demons+ :descr-func #'(lambda () (format nil "To win, destroy all angels. To lose, have all demonic machines destroyed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (total-angels (level world)))) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (zerop (total-angels (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Dimensional engines successfully defended by demons." :score (calculate-player-score 1500) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) )))
7,012
Common Lisp
.lisp
66
36.242424
167
0.242258
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5aa748ed68089d54d0d934e77f95a619290b4c5936e8245e29c44e96a5c999ef
2,903
[ -1 ]
2,904
init-game-events-eliminate-satanists.lisp
gwathlobal_CotD/src/game-events/init-game-events-eliminate-satanists.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-eliminate-satanists-win-for-angels+ :descr-func #'(lambda () (format nil "To win, destroy all demons & satanists in the district. To lose, have all angels killed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (zerop (total-demons (level world))) (zerop (nth +faction-type-satanists+ (total-faction-list (level world))))) (and (/= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (zerop (total-demons (level world))) (zerop (nth +faction-type-satanists+ (total-faction-list (level world)))) (zerop (nth +faction-type-military+ (total-faction-list (level world)))))) t nil)) :on-trigger #'(lambda (world) (let* ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil)) (bonus (if if-player-won 1400 0))) (trigger-game-over world :final-str "Satanists eliminated." :score (calculate-player-score (+ bonus (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-angels-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-eliminate-satanists-win-for-demons+ :descr-func #'(lambda () (format nil "To win, destroy all military units in the district. To lose, have all satanists killed.")) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (<= (nth +faction-type-military+ (total-faction-list (level world))) 0)) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (<= (nth +faction-type-military+ (total-faction-list (level world))) 0))) t nil)) :on-trigger #'(lambda (world) (let* ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil)) (bonus (if if-player-won 1450 0))) (trigger-game-over world :final-str "Satanists protected." :score (calculate-player-score bonus) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-eliminate-satanists-win-for-military+ :descr-func #'(lambda () (format nil "To win, destroy all satanists in the district. To lose, have all military units killed.")) :disabled nil :on-check #'(lambda (world) (if (and (> (nth +faction-type-military+ (total-faction-list (level world))) 0) (zerop (nth +faction-type-satanists+ (total-faction-list (level world))))) t nil)) :on-trigger #'(lambda (world) (let* ((if-player-won (if (= (loyal-faction *player*) +faction-type-military+) t nil)) (bonus (if if-player-won 1500 0))) (trigger-game-over world :final-str "Satanists eliminated." :score (calculate-player-score (+ bonus (* 10 (total-humans (level world))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-military-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-eliminate-satanists-win-for-church+ :descr-func #'(lambda () "To win, destroy all satanists and demons in the district. To lose, get all priests and angels killed.") :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-church+) (> (nth +faction-type-church+ (total-faction-list (level world))) 0) (zerop (total-demons (level world))) (zerop (nth +faction-type-satanists+ (total-faction-list (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "Satanists eliminated." :score (calculate-player-score (+ 1450 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-church-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-eliminate-satanists-win-for-satanists+ :descr-func #'(lambda () (format nil "To win, destroy all military units in the district. To lose, have all satanists killed.")) :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-satanists+) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (zerop (nth +faction-type-military+ (total-faction-list (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Satanists protected." :score (calculate-player-score 1450) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-satanists-won)) )))
17,173
Common Lisp
.lisp
159
36.81761
167
0.245532
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
5e7827104d08eba9de057d06e4bac0073d9a4f65331f5f91d2642b1f6088492f
2,904
[ -1 ]
2,905
init-game-events-demonic-attack.lisp
gwathlobal_CotD/src/game-events/init-game-events-demonic-attack.lisp
(in-package :cotd) ;;=========================== ;; WIN EVENTS ;;=========================== (set-game-event (make-instance 'game-event :id +game-event-demon-attack-win-for-angels+ :descr-func #'(lambda () (let ((win-figure (win-condition/win-formula (get-win-condition-by-id :win-cond-demonic-attack)))) (format nil "To win, destroy all demons in the district. To lose, have all angels killed or have ~A% of civilians in the district destroyed or possessed." win-figure))) :disabled nil :on-check #'(lambda (world) (if (or (and (= (loyal-faction *player*) +faction-type-angels+) (> (total-angels (level world)) 0) (zerop (total-demons (level world)))) (and (/= (loyal-faction *player*) +faction-type-angels+) (zerop (nth +faction-type-satanists+ (total-faction-list (level world)))) (> (total-angels (level world)) 0) (zerop (total-demons (level world))))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1400 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-angels-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-demon-attack-win-for-demons+ :descr-func #'(lambda () (let ((win-figure (win-condition/win-formula (get-win-condition-by-id :win-cond-demonic-attack)))) (format nil "To win, destroy or possess ~A% of civilians in the district. To lose, have all demons killed." win-figure))) :disabled nil :on-check #'(lambda (world) (let* ((win-condition (get-win-condition-by-id :win-cond-demonic-attack)) (civilians-left (funcall (win-condition/win-func win-condition) world win-condition))) (if (or (and (= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (<= civilians-left 0)) (and (/= (loyal-faction *player*) +faction-type-demons+) (> (total-demons (level world)) 0) (<= civilians-left 0))) t nil))) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Civilians eliminated." :score (calculate-player-score 1450) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-demons-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-demon-attack-win-for-military+ :descr-func #'(lambda () (let ((win-figure (win-condition/win-formula (get-win-condition-by-id :win-cond-demonic-attack)))) (format nil "To win, destroy all demons in the district. To lose, have all military killed or have ~A% of civilians in the district destroyed or possessed." win-figure))) :disabled nil :on-check #'(lambda (world) (if (and (> (total-humans (level world)) 0) (zerop (total-demons (level world)))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (= (loyal-faction *player*) +faction-type-military+) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1500 (* 10 (total-humans (level world))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-military-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-demon-attack-win-for-church+ :descr-func #'(lambda () "To win, destroy all demons in the district. To lose, get all priests and angels killed.") :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-church+) (> (nth +faction-type-church+ (total-faction-list (level world))) 0) (zerop (total-demons (level world)))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-angels+) (= (loyal-faction *player*) +faction-type-church+)) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score (+ 1400 (if (not (mimic-id-list *player*)) 0 (loop for mimic-id in (mimic-id-list *player*) for mimic = (get-mob-by-id mimic-id) with cur-score = 0 when (not (eq mimic *player*)) do (incf cur-score (cur-score mimic)) finally (return cur-score))))) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-church-won)) ))) (set-game-event (make-instance 'game-event :id +game-event-demon-attack-win-for-satanists+ :descr-func #'(lambda () (let ((win-figure (win-condition/win-formula (get-win-condition-by-id :win-cond-demonic-attack)))) (format nil "To win, destroy ~A% of civilians in the district. To lose, have all satanists killed." win-figure))) :disabled nil :on-check #'(lambda (world) (if (and (= (loyal-faction *player*) +faction-type-satanists+) (> (nth +faction-type-satanists+ (total-faction-list (level world))) 0) (zerop (total-angels (level world)))) t nil)) :on-trigger #'(lambda (world) (let ((if-player-won (if (or (= (loyal-faction *player*) +faction-type-demons+) (= (loyal-faction *player*) +faction-type-satanists+)) t nil))) (trigger-game-over world :final-str "Enemies eliminated." :score (calculate-player-score 1450) :if-player-won if-player-won :player-msg (if if-player-won (format nil "Congratulations! Your faction has won!~%") (format nil "Curses! Your faction has lost!~%")) :game-over-type :game-over-satanists-won)) )))
16,529
Common Lisp
.lisp
151
38.688742
231
0.254764
gwathlobal/CotD
79
3
0
GPL-3.0
9/19/2024, 11:25:50 AM (Europe/Amsterdam)
8407ee46de003800ec290e4beccb80dc364bc38a0de3bda752dd5218d54f77df
2,905
[ -1 ]