Difference between revisions of "Modding:being blueprint (0.9.9.7)"
From DoomRL Wiki
Yaflhdztioxo (Talk | contribs) (→Being Flags) |
Yaflhdztioxo (Talk | contribs) |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | The being [[Modding:blueprint|blueprint]] is used to define new beings. | |
+ | == Blueprint == | ||
− | + | Being blueprints are registered with the ''register_being'' procedure. Registered blueprints are stored in a global Lua table called ''beings''. | |
− | + | {{drltable|Being Blueprint|3|{{Table3Col | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|es=background: #333; | |es=background: #333; | ||
− | |c1=font- | + | |c1=font-family:monospace; text-align:right; vertical-align:top; padding:0px 2px; |
|c2=vertical-align:top; padding:0px 2px; | |c2=vertical-align:top; padding:0px 2px; | ||
|c3=padding:0px 2px; | |c3=padding:0px 2px; | ||
− | | | + | |id |{{modarg|string}}|The unique identifier used by the engine for this being. Passed as the first argument when registering a blueprint. |
− | + | |<u>name</u> |{{modarg|string}}|This is the being's name. | |
− | | | + | |name_plural |{{modarg|string}}|This is the being's pluralized name. This defaults to the being's the name with an "s" appended. |
− | | | + | |sound_id |{{modarg|being}}|If included the being will search for sounds bound to this id instead of its own. |
− | | | + | |<u>ascii</u> |{{modarg|string}}|This is the being's picture in console mode. It should be a single character string. |
− | | | + | |<u>color</u> |{{modarg|Color}}|This is the being's color in console mode. |
− | | | + | |<u>sprite</u> |{{modarg|Sprite}}|This is the being's sprite in graphical mode. |
− | | | + | |coscolor |{{modarg|ColorSet}}|This is a graphical mode filter that can be used to add color to specific sprites. |
− | | | + | |glow |{{modarg|ColorSet}}|This is a graphical mode filter that can be used to give a sprite a colored glow. |
− | | | + | |overlay |{{modarg|ColorSet}}|This is a graphical mode filter that can be used to subtract color from any sprite. |
− | | | + | |hp |{{modarg|integer}}|This is the being's hpmax and starting hp. The default is 10. |
− | | | + | |armor |{{modarg|integer}}|This is the being's armor bonus. The default is 0. |
− | | | + | |attackchance |{{modarg|integer}}|This is the being's attackchance. The default is 75. |
− | | | + | |todam |{{modarg|integer}}|This is the being's todam bonus. The bonus applies only to melee attacks. The default is 0. |
− | + | |tohit |{{modarg|integer}}|This is the being's tohit bonus. The default is 0. | |
− | | | + | |tohitmelee |{{modarg|integer}}|This is the being's tohitmelee bonus. The default is 0. |
− | |''' | + | |speed |{{modarg|integer}}|This is the being's speed. The maximum allowed speed is 255. The default is 100. |
− | | | + | |vision |{{modarg|integer}}|This is the being's vision bonus. The default is 0, meaning the same vision as the player. |
− | | | + | |<u>min_lev</u> |{{modarg|integer}}|This is a [[Monster Generation|monster generation]] parameter. |
− | + | |max_lev |{{modarg|integer}}|This is a [[Monster Generation|monster generation]] parameter. The default is 10000. | |
− | + | |corpse |{{modarg|cell}}|The determines the corpse left by the being. Instead of passing in a cell directly you can pass a boolean ''true'' which will make the engine automatically create and assign an appropriate being corpse. You can also pass in ''false'' or leave this field blank to specify no corpse. | |
− | + | |<u>danger</u> |{{modarg|integer}}|This is a [[Monster Generation|monster generation]] parameter. | |
− | | | + | |<u>weight</u> |{{modarg|integer}}|This is a [[Monster Generation|monster generation]] parameter. |
− | | | + | |xp |{{modarg|integer}}|This is the being's expvalue. By default, it is <font-family: monospace>3xD<sup>2</sup>+20, where D is the being's <u>danger</u> value (above). |
− | | | + | |bulk |{{modarg|integer}}|This parameter is unused. The default is 100. |
− | + | |flags |{{modarg|Being Flag}}|This parameter is an array of being flags which will be used by all beings of this type by default. | |
− | | | + | |<u>ai_type</u> |{{modarg|AI}}|This determines the being's AI. |
− | + | |res_bullet |{{modarg|integer}}|This is the being's resistance to bullet damage. The default is 0. | |
− | | | + | |res_melee |{{modarg|integer}}|This is the being's resistance to melee damage. The default is 0. |
− | | | + | |res_shrapnel |{{modarg|integer}}|This is the being's resistance to shrapnel damage. The default is 0. |
− | | | + | |res_acid |{{modarg|integer}}|This is the being's resistance to acid damage. The default is 0. |
− | | | + | |res_fire |{{modarg|integer}}|This is the being's resistance to fire damage. The default is 0. |
− | | | + | |res_plasma |{{modarg|integer}}|This is the being's resistance to plasma damage. The default is 0. |
− | + | |<u>desc</u> |{{modarg|string}}|This is the description of the being displayed in the 'more information' view. | |
− | | | + | |<u>kill_desc</u> |{{modarg|string}}|If included this being will have a special kill description in the mortem. |
− | | | + | |kill_desc_melee |{{modarg|string}}|If included this being will have a special melee kill description in the mortem. |
+ | |weapon |{{modarg|Item Blueprint}}|You can inline an item blueprint here and it will be registered for you. Items defined this way are always natural ranged weapons that never drop and have no ammo. It will even be equippedly automatically for you. | ||
+ | |OnCreate |{{modarg|function}}| | ||
+ | |OnAction |{{modarg|function}}| | ||
+ | |OnAttacked |{{modarg|function}}| | ||
+ | |OnDie |{{modarg|function}}| | ||
+ | |OnDieCheck |{{modarg|function}}| | ||
+ | |OnPickupItem |{{modarg|function}}| | ||
|}} | |}} | ||
− | + | }} | |
− | + | ||
− | + | ||
== Engine Hooks == | == Engine Hooks == | ||
− | |||
− | {| | + | {{drltable|Being Hooks|2|{{Table2Col |
− | + | ||
− | + | ||
|es=background: #333; | |es=background: #333; | ||
− | |c1=font- | + | |c1=font-family:monospace; text-align:right; vertical-align:top; padding:0px 2px; |
|c2=padding:0px 2px; | |c2=padding:0px 2px; | ||
− | | | + | |{{modarg|void}} |[[#being_OnCreate |OnCreate]] ({{modarg|being}} self) |
− | | | + | |{{modarg|void}} |[[#being_OnAction |OnAction]] ({{modarg|being}} self) |
− | | | + | |{{modarg|void}} |[[#being_OnAttacked |OnAttacked]] ({{modarg|being}} self) |
+ | |{{modarg|void}} |[[#being_OnDie |OnDie]] ({{modarg|being}} self, {{modarg|boolean}} overkill) | ||
+ | |{{modarg|boolean}}|[[#being_OnDieCheck |OnDieCheck]] ({{modarg|being}} self, {{modarg|boolean}} overkill) | ||
+ | |{{modarg|void}} |[[#being_OnPickupItem|OnPickupItem]] ({{modarg|being}} self, {{modarg|item}} item) | ||
|}} | |}} | ||
− | + | }} | |
+ | |||
{{Anchor|being_OnCreate}} | {{Anchor|being_OnCreate}} | ||
− | + | '''OnCreate'''({{modarg|being}} self) | |
− | :This is called when the being is created. | + | :This is called when the being is created. Usually inventory and equipment get added here but many more adjustments are possible. |
---- | ---- | ||
{{Anchor|being_OnAction}} | {{Anchor|being_OnAction}} | ||
− | + | '''OnAction'''({{modarg|being}} self) | |
− | :This is called at the beginning of | + | :This is called at the beginning of a being's turn. It is never called more than once per tick and the player, sadly, does not use this. |
+ | ---- | ||
+ | {{Anchor|being_OnAttacked}} | ||
+ | '''OnAttacked'''({{modarg|being}} self) | ||
+ | :This is called when a being is attacked and is usually only used by being AIs. It is not possible to determine the attacker. | ||
---- | ---- | ||
{{Anchor|being_OnDie}} | {{Anchor|being_OnDie}} | ||
− | + | '''OnDie'''({{modarg|being}} self, {{modarg|boolean}} overkill) | |
:This is called when the being dies. ''overkill'' is true if the being was gibbed. | :This is called when the being dies. ''overkill'' is true if the being was gibbed. | ||
+ | ---- | ||
+ | {{Anchor|being_OnDieCheck}} | ||
+ | '''OnDieCheck'''({{modarg|being}} self, {{modarg|boolean}} overkill) → '''boolean''' | ||
+ | :This is called right before a being would normally die. Returning '''false''' will prevent the death, giving the being a minimum of 1 hp. ''overkill'' is true if the being was gibbed. | ||
+ | ---- | ||
+ | {{Anchor|being_OnPickupItem}} | ||
+ | '''OnPickupItem'''({{modarg|being}} self, {{modarg|item}} item) | ||
+ | :This is called when a being picks up an item. It is only used in DoomRL for statistical purposes. |
Latest revision as of 01:03, 22 April 2013
The being blueprint is used to define new beings.
Blueprint
Being blueprints are registered with the register_being procedure. Registered blueprints are stored in a global Lua table called beings.
Being Blueprint | ||
id | string | The unique identifier used by the engine for this being. Passed as the first argument when registering a blueprint. |
name | string | This is the being's name. |
name_plural | string | This is the being's pluralized name. This defaults to the being's the name with an "s" appended. |
sound_id | being | If included the being will search for sounds bound to this id instead of its own. |
ascii | string | This is the being's picture in console mode. It should be a single character string. |
color | Color | This is the being's color in console mode. |
sprite | Sprite | This is the being's sprite in graphical mode. |
coscolor | ColorSet | This is a graphical mode filter that can be used to add color to specific sprites. |
glow | ColorSet | This is a graphical mode filter that can be used to give a sprite a colored glow. |
overlay | ColorSet | This is a graphical mode filter that can be used to subtract color from any sprite. |
hp | integer | This is the being's hpmax and starting hp. The default is 10. |
armor | integer | This is the being's armor bonus. The default is 0. |
attackchance | integer | This is the being's attackchance. The default is 75. |
todam | integer | This is the being's todam bonus. The bonus applies only to melee attacks. The default is 0. |
tohit | integer | This is the being's tohit bonus. The default is 0. |
tohitmelee | integer | This is the being's tohitmelee bonus. The default is 0. |
speed | integer | This is the being's speed. The maximum allowed speed is 255. The default is 100. |
vision | integer | This is the being's vision bonus. The default is 0, meaning the same vision as the player. |
min_lev | integer | This is a monster generation parameter. |
max_lev | integer | This is a monster generation parameter. The default is 10000. |
corpse | cell | The determines the corpse left by the being. Instead of passing in a cell directly you can pass a boolean true which will make the engine automatically create and assign an appropriate being corpse. You can also pass in false or leave this field blank to specify no corpse. |
danger | integer | This is a monster generation parameter. |
weight | integer | This is a monster generation parameter. |
xp | integer | This is the being's expvalue. By default, it is 3xD2+20, where D is the being's danger value (above). |
bulk | integer | This parameter is unused. The default is 100. |
flags | Being Flag | This parameter is an array of being flags which will be used by all beings of this type by default. |
ai_type | AI | This determines the being's AI. |
res_bullet | integer | This is the being's resistance to bullet damage. The default is 0. |
res_melee | integer | This is the being's resistance to melee damage. The default is 0. |
res_shrapnel | integer | This is the being's resistance to shrapnel damage. The default is 0. |
res_acid | integer | This is the being's resistance to acid damage. The default is 0. |
res_fire | integer | This is the being's resistance to fire damage. The default is 0. |
res_plasma | integer | This is the being's resistance to plasma damage. The default is 0. |
desc | string | This is the description of the being displayed in the 'more information' view. |
kill_desc | string | If included this being will have a special kill description in the mortem. |
kill_desc_melee | string | If included this being will have a special melee kill description in the mortem. |
weapon | Item Blueprint | You can inline an item blueprint here and it will be registered for you. Items defined this way are always natural ranged weapons that never drop and have no ammo. It will even be equippedly automatically for you. |
OnCreate | function | |
OnAction | function | |
OnAttacked | function | |
OnDie | function | |
OnDieCheck | function | |
OnPickupItem | function | |
Engine Hooks
Being Hooks | |
void | OnCreate (being self) |
void | OnAction (being self) |
void | OnAttacked (being self) |
void | OnDie (being self, boolean overkill) |
boolean | OnDieCheck (being self, boolean overkill) |
void | OnPickupItem (being self, item item) |
OnCreate(being self)
- This is called when the being is created. Usually inventory and equipment get added here but many more adjustments are possible.
OnAction(being self)
- This is called at the beginning of a being's turn. It is never called more than once per tick and the player, sadly, does not use this.
OnAttacked(being self)
- This is called when a being is attacked and is usually only used by being AIs. It is not possible to determine the attacker.
OnDie(being self, boolean overkill)
- This is called when the being dies. overkill is true if the being was gibbed.
OnDieCheck(being self, boolean overkill) → boolean
- This is called right before a being would normally die. Returning false will prevent the death, giving the being a minimum of 1 hp. overkill is true if the being was gibbed.
OnPickupItem(being self, item item)
- This is called when a being picks up an item. It is only used in DoomRL for statistical purposes.