damagetype System
Posted: 22 Jun 2009, 07:37
A bit of weapon postdef code that allows you to define damagetypes, which you can assign to weapons via the damagetype customparam (default is "default"). You can then specify a multiplier to damage (relative to default) that each damagetype should get against different armortypes. Damages explicitly defined in the weapondefs override the calculated values.
Examples of use:
In a weapondef:
In gamedata/damagedefs.lua:
Another example: part of Warcraft III's damagetype system:
(note that I am not suggesting that anybody actually try to copy Warcraft III; this is just to use a well-known example)
S44's weapondefs_post.lua:
http://spring1944.svn.sourceforge.net/v ... iew=markup
Examples of use:
In a weapondef:
Code: Select all
name=Molotov Cocktail;
[...]
[customParams] {
damagetype=fire;
}
[...]
[damages] {
default=9001;
magic=9001; //overrides calculated value
}
Code: Select all
local damagedefs = {
default = {
invulnerable=0,
magic=0.5,
},
fire = {
fire=0.5,
ice=2,
invulnerable=0,
magic=0.5,
},
}
return damagedefs
Code: Select all
name=Footman Sword;
[...]
[customParams] {
damagetype=normal;
}
[...]
[damages] {
default=12.5;
}
Code: Select all
local damagedefs = {
normal = {
medium = 1.5,
fortified = 0.7,
},
piercing = {
light = 2,
medium = 0.75,
fortified = 0.35,
hero = 0.5,
unarmored = 1.5,
},
[...]
S44's weapondefs_post.lua:
http://spring1944.svn.sourceforge.net/v ... iew=markup