# Is it possible to define new special attacks/deaths with a mod?

**URL:** https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389
**Category:** The Lab
**Created:** [February 10, 2016, 8:21pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389 "2016-02-10T20:21:39Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [February 10, 2016, 8:21pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/1 "2016-02-10T20:21:39Z")

</div>

After some tinkering with the data I did find, Ive been unable to either find an example of it or get my own jerry-rigged example to work.

I took the thrillers death function and replaced the monster\_id to let me turn all squirrels into bees upon the death of a critter, but the game doesnt seem to recognize my efforts.

---

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [February 10, 2016, 10:04pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/2 "2016-02-10T22:04:33Z")

</div>

mmmk.

So I thought on it, and maybe? Im not afraid to try.

Ive managed to get the main.lua file that I see in some mods to accept a specific creature instead of a species, and as far as Im concerned thats more progress than a less curious person would have.

I dont know if main.lua is the only lua file accepted, what lua is, or even how .cpp and .h files play into that, but .h files seem to name variables and ids, while .cpp files have the meats.

It appears I need to get the game to register a new deathtype or special attack. From there, with some inspiration, I could cannibalize existing code into something that might function, but I dont know if I can define new variables in lua.

---

<div class="post-metadata">

### Author: ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)
#### Post date: [February 10, 2016, 10:23pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/3 "2016-02-10T22:23:07Z")

</div>

I have relevant input!  
You can define a new variable like this:  
local blah = blah

It seems to not care about types, I’ve seen strings and ints used with the same declaration ie:  
local string = "foobar"  
and  
local number = 18

and it can accept data from functions as well  
local p = player:pos()

uses one of the functions from catabindings to return a tripoint of the player position. Not that I know what a tripoint is or how to use one, but…

---

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [February 10, 2016, 10:26pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/4 "2016-02-10T22:26:52Z")

</div>

So if I define a mdefense (treesprout) as a local variable, then the game should read it as an attack\_on\_hit that sprouts trees like a Queen would if I do a rough copypaste job?

See, my problem is I know what I mean, but I have zero clues if that makes senses.

But I dont really have to bother with trying to replicate the .h or .cpp files then? I can define them in lua? Because lua is a bit friendlier on my eyes.

---

<div class="post-metadata">

### Author: ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)
#### Post date: [February 10, 2016, 10:41pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/5 "2016-02-10T22:41:25Z")

</div>

I’m not sure, but my gut says no. Have you seen the class\_definitions.lua in the lua directory? There are a lot of predefined functions available to manipulate creatures and the environment. Perhaps something in there will help?

---

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [February 10, 2016, 11:41pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/6 "2016-02-10T23:41:02Z")

</div>

Well Im still not making headway. Thanks for the help though

---

<div class="post-metadata">

### Author: ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)
#### Post date: [February 11, 2016, 4:18am UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/7 "2016-02-11T04:18:01Z")

</div>

I beat my head against the lua brick wall whenever I feel like getting frustrated and angry at a computer screen. I’m considering springing for some online classes in c++ and lua or something similar to give myself a better foundation, this self-taught-no-lessons crap is bad for the blood pressure.

---

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [February 11, 2016, 6:23am UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/8 "2016-02-11T06:23:23Z")

</div>

This only means that Id have to maintain/compile my own version of dda to put threse in.

tempting, but not with my level of expertise, jaa

---

<div class="post-metadata">

### Author: ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)
#### Post date: [February 11, 2016, 6:30am UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/9 "2016-02-11T06:30:52Z")

</div>

If you put your mod into github, kevin has said before he’s willing to support code changes that would support the mod.

---

<div class="post-metadata">

### Author: ![macrosblackd](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@macrosblackd](https://discourse.cataclysmdda.org/u/macrosblackd)
#### Post date: [February 11, 2016, 5:29pm UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/10 "2016-02-11T17:29:13Z")

</div>

If I’m not mistaken, there currently isn’t code to handle custom on\_hit effects for monster attacks. One thing we could do, however, is refactor the on\_hit effect handling to something similar to iuse actions. This would let you register a function in lua as an on\_hit effect, which could then be used in the json definition to tell the game to use that function for the effect. I’ll take a look at this later in the week/weekend to see if I can get something going.

---

<div class="post-metadata">

### Author: ![pisskop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/pisskop/32/1327_2.png) [@pisskop](https://discourse.cataclysmdda.org/u/pisskop)
#### Post date: [November 22, 2017, 1:41am UTC](https://discourse.cataclysmdda.org/t/is-it-possible-to-define-new-special-attacks-deaths-with-a-mod/11389/11 "2017-11-22T01:41:33Z")

</div>

there is now code to support this. special player defined attacks and mon effects both…

i respond to this because its on the top of my feed fsr. happy holidays
