-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
armor.dm
127 lines (109 loc) · 4.54 KB
/
armor.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#define ARMORID "armor-[melee]-[bullet]-[laser]-[energy]-[bomb]-[bio]-[rad]-[fire]-[acid]-[magic]-[wound]-[electric]"
/proc/getArmor(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 0, acid = 0, magic = 0, wound = 0, electric=0)
. = locate(ARMORID)
if (!.)
. = new /datum/armor(melee, bullet, laser, energy, bomb, bio, rad, fire, acid, magic, wound, electric)
/datum/armor
var/melee
var/bullet
var/laser
var/energy
var/bomb
var/bio
var/rad
var/fire
var/acid
var/magic
var/wound
var/electric
/datum/armor/New(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 0, acid = 0, magic = 0, wound = 0, electric=0)
src.melee = melee
src.bullet = bullet
src.laser = laser
src.energy = energy
src.bomb = bomb
src.bio = bio
src.rad = rad
src.fire = fire
src.acid = acid
src.magic = magic
src.wound = wound
src.electric = electric
tag = ARMORID
GenerateTag()
/datum/armor/proc/modifyRating(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 0, acid = 0, magic = 0, wound = 0, electric=0)
return getArmor(src.melee+melee, src.bullet+bullet, src.laser+laser, src.energy+energy, src.bomb+bomb, src.bio+bio, src.rad+rad, src.fire+fire, src.acid+acid, src.magic+magic, src.wound+wound, src.electric+electric)
/datum/armor/proc/modifyAllRatings(modifier = 0)
return getArmor(melee+modifier, bullet+modifier, laser+modifier, energy+modifier, bomb+modifier, bio+modifier, rad+modifier, fire+modifier, acid+modifier, magic+modifier, wound+modifier, electric+modifier)
/datum/armor/proc/setRating(melee, bullet, laser, energy, bomb, bio, rad, fire, acid, magic, wound, electric)
return getArmor(
(isnull(melee) ? src.melee : melee),
(isnull(bullet) ? src.bullet : bullet),
(isnull(laser) ? src.laser : laser),
(isnull(energy) ? src.energy : energy),
(isnull(bomb) ? src.bomb : bomb),
(isnull(bio) ? src.bio : bio),
(isnull(rad) ? src.rad : rad),
(isnull(fire) ? src.fire : fire),
(isnull(acid) ? src.acid : acid),
(isnull(magic) ? src.magic : magic),
(isnull(wound) ? src.wound : wound),
(isnull(electric) ? src.electric : electric),
)
/datum/armor/proc/getRating(rating)
return vars[rating]
/datum/armor/proc/getList()
return list(MELEE = melee, BULLET = bullet, LASER = laser, ENERGY = energy, BOMB = bomb, BIO = bio, RAD = rad, FIRE = fire, ACID = acid, MAGIC = magic, WOUND = wound, ELECTRIC = electric)
/datum/armor/proc/attachArmor(datum/armor/AA)
return getArmor(melee+AA.melee, bullet+AA.bullet, laser+AA.laser, energy+AA.energy, bomb+AA.bomb, bio+AA.bio, rad+AA.rad, fire+AA.fire, acid+AA.acid, magic+AA.magic, wound+AA.wound, electric+AA.electric)
/datum/armor/proc/detachArmor(datum/armor/AA)
return getArmor(melee-AA.melee, bullet-AA.bullet, laser-AA.laser, energy-AA.energy, bomb-AA.bomb, bio-AA.bio, rad-AA.rad, fire-AA.fire, acid-AA.acid, magic-AA.magic, wound-AA.wound, electric-AA.electric)
/datum/armor/vv_edit_var(var_name, var_value)
if (var_name == NAMEOF(src, tag))
return FALSE
. = ..()
tag = ARMORID // update tag in case armor values were edited
/datum/armor/proc/show_protection_classes(additional_info = "")
var/list/readout = list("<span class='notice'><u><b>PROTECTION CLASSES</u></b>")
if(bomb || bullet || energy || laser || melee)
readout += "\n<b>ARMOR (I-X)</b>"
if(bomb)
readout += "\nEXPLOSIVE [armor_to_protection_class(bomb)]"
if(bullet)
readout += "\nBULLET [armor_to_protection_class(bullet)]"
if(energy)
readout += "\nENERGY [armor_to_protection_class(energy)]"
if(laser)
readout += "\nLASER [armor_to_protection_class(laser)]"
if(melee)
readout += "\nMELEE [armor_to_protection_class(melee)]"
if(bio || rad || electric)
readout += "\n<b>ENVIRONMENT (I-X)</b>"
if(bio)
readout += "\nBIOHAZARD [armor_to_protection_class(bio)]"
if(rad)
readout += "\nRADIATION [armor_to_protection_class(rad)]"
if(electric)
readout += "\nELECTRICAL [armor_to_protection_class(electric)]"
if(fire || acid)
readout += "\n<b>DURABILITY (I-X)</b>"
if(fire)
readout += "\nFIRE [armor_to_protection_class(fire)]"
if(acid)
readout += "\nACID [armor_to_protection_class(acid)]"
if(additional_info != "")
readout += additional_info
readout += "</span>"
return readout.Join()
/**
* Rounds armor_value down to the nearest 10, divides it by 10 and then converts it to Roman numerals.
*
* Arguments:
* * armor_value - Number we're converting
*/
/datum/armor/proc/armor_to_protection_class(armor_value)
if (armor_value < 0)
. = "-"
. += "\Roman[round(abs(armor_value), 10) / 10]"
return .
#undef ARMORID