Defines math, take 2

This commit is contained in:
Emmett Gaines
2017-12-17 11:02:11 -05:00
committed by CitadelStationBot
parent 220e1cd8cf
commit f875d4e176
180 changed files with 1250 additions and 644 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
/mob/living/simple_animal/hostile/blob/fire_act(exposed_temperature, exposed_volume)
..()
if(exposed_temperature)
adjustFireLoss(Clamp(0.01 * exposed_temperature, 1, 5))
adjustFireLoss(CLAMP(0.01 * exposed_temperature, 1, 5))
else
adjustFireLoss(5)
+1 -1
View File
@@ -153,7 +153,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
B.hud_used.blobpwrdisplay.maptext = "<div align='center' valign='middle' style='position:relative; top:0px; left:6px'><font color='#82ed00'>[round(blob_core.obj_integrity)]</font></div>"
/mob/camera/blob/proc/add_points(points)
blob_points = Clamp(blob_points + points, 0, max_blob_points)
blob_points = CLAMP(blob_points + points, 0, max_blob_points)
hud_used.blobpwrdisplay.maptext = "<div align='center' valign='middle' style='position:relative; top:0px; left:6px'><font color='#82ed00'>[round(blob_points)]</font></div>"
/mob/camera/blob/say(message)
@@ -207,7 +207,7 @@
to_chat(cyborg, "<span class='brass'>You start to charge from the [sigil_name]...</span>")
if(!do_after(cyborg, 50, target = src, extra_checks = CALLBACK(src, .proc/cyborg_checks, cyborg, TRUE)))
return
var/giving_power = min(Floor(cyborg.cell.maxcharge - cyborg.cell.charge, MIN_CLOCKCULT_POWER), get_clockwork_power()) //give the borg either all our power or their missing power floored to MIN_CLOCKCULT_POWER
var/giving_power = min(FLOOR(cyborg.cell.maxcharge - cyborg.cell.charge, MIN_CLOCKCULT_POWER), get_clockwork_power()) //give the borg either all our power or their missing power floored to MIN_CLOCKCULT_POWER
if(adjust_clockwork_power(-giving_power))
cyborg.visible_message("<span class='warning'>[cyborg] glows a brilliant orange!</span>")
var/previous_color = cyborg.color
@@ -90,7 +90,7 @@
if(amount_temp < 2)
to_chat(user, "<span class='warning'>You need at least <b>2</b> floor tiles to convert into power.</span>")
return TRUE
if(IsOdd(amount_temp))
if(ISODD(amount_temp))
amount_temp--
no_delete = TRUE
use(amount_temp)
@@ -239,7 +239,7 @@
if(!do_after(user, repair_values["healing_for_cycle"] * fabricator.speed_multiplier, target = src, \
extra_checks = CALLBACK(fabricator, /obj/item/clockwork/replica_fabricator.proc/fabricator_repair_checks, repair_values, src, user, TRUE)))
break
obj_integrity = Clamp(obj_integrity + repair_values["healing_for_cycle"], 0, max_integrity)
obj_integrity = CLAMP(obj_integrity + repair_values["healing_for_cycle"], 0, max_integrity)
adjust_clockwork_power(-repair_values["power_required"])
playsound(src, 'sound/machines/click.ogg', 50, 1)
@@ -97,7 +97,7 @@
if(ishuman(M.current))
human_servants++
construct_limit = human_servants / 4 //1 per 4 human servants, and a maximum of 3 marauders
construct_limit = Clamp(construct_limit, 1, 3)
construct_limit = CLAMP(construct_limit, 1, 3)
/datum/clockwork_scripture/create_object/construct/clockwork_marauder/pre_recital()
channel_time = initial(channel_time)
@@ -60,4 +60,4 @@
break
if(!M)
M = H.apply_status_effect(STATUS_EFFECT_MANIAMOTOR, src)
M.severity = Clamp(M.severity + ((11 - get_dist(src, H)) * efficiency * efficiency), 0, MAX_MANIA_SEVERITY)
M.severity = CLAMP(M.severity + ((11 - get_dist(src, H)) * efficiency * efficiency), 0, MAX_MANIA_SEVERITY)
@@ -57,5 +57,5 @@
L.confused = min(L.confused + 15, 50)
L.dizziness = min(L.dizziness + 15, 50)
if(L.confused >= 25)
L.Knockdown(Floor(L.confused * 0.8))
L.Knockdown(FLOOR(L.confused * 0.8, 1))
take_damage(max_integrity)
+1 -1
View File
@@ -25,7 +25,7 @@
if (prob(meteorminutes/2))
wavetype = GLOB.meteors_catastrophic
var/ramp_up_final = Clamp(round(meteorminutes/rampupdelta), 1, 10)
var/ramp_up_final = CLAMP(round(meteorminutes/rampupdelta), 1, 10)
spawn_meteors(ramp_up_final, wavetype)
+1 -1
View File
@@ -353,7 +353,7 @@
var/N = text2num(user_input)
if(!N)
return
timer_set = Clamp(N,minimum_timer_set,maximum_timer_set)
timer_set = CLAMP(N,minimum_timer_set,maximum_timer_set)
. = TRUE
if("safety")
if(auth && yes_code)
+2 -2
View File
@@ -161,7 +161,7 @@
return
log_activity("changed greater than charge filter to \"[new_filter]\"")
if(new_filter)
new_filter = Clamp(new_filter, 0, 100)
new_filter = CLAMP(new_filter, 0, 100)
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0)
result_filters["Charge Above"] = new_filter
if(href_list["below_filter"])
@@ -171,7 +171,7 @@
return
log_activity("changed lesser than charge filter to \"[new_filter]\"")
if(new_filter)
new_filter = Clamp(new_filter, 0, 100)
new_filter = CLAMP(new_filter, 0, 100)
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0)
result_filters["Charge Below"] = new_filter
if(href_list["access_filter"])
@@ -211,7 +211,7 @@
if("pressure")
var/target = input("New target pressure:", name, output_info ? output_info["internal"] : 0) as num|null
if(!isnull(target) && !..())
target = Clamp(target, 0, 50 * ONE_ATMOSPHERE)
target = CLAMP(target, 0, 50 * ONE_ATMOSPHERE)
signal.data += list("tag" = output_tag, "set_internal_pressure" = target)
. = TRUE
radio_connection.post_signal(src, signal, filter = GLOB.RADIO_ATMOSIA)
+17 -16
View File
@@ -337,12 +337,12 @@
if(!num)
num = round(input(usr, "Choose pulse duration:", "Input an Integer", null) as num|null)
if(num)
radduration = Wrap(num, 1, RADIATION_DURATION_MAX+1)
radduration = WRAP(num, 1, RADIATION_DURATION_MAX+1)
if("setstrength")
if(!num)
num = round(input(usr, "Choose pulse strength:", "Input an Integer", null) as num|null)
if(num)
radstrength = Wrap(num, 1, RADIATION_STRENGTH_MAX+1)
radstrength = WRAP(num, 1, RADIATION_STRENGTH_MAX+1)
if("screen")
current_screen = href_list["text"]
if("rejuv")
@@ -353,13 +353,13 @@
if("setbufferlabel")
var/text = sanitize(input(usr, "Input a new label:", "Input an Text", null) as text|null)
if(num && text)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
buffer_slot["label"] = text
if("setbuffer")
if(num && viable_occupant)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
buffer[num] = list(
"label"="Buffer[num]:[viable_occupant.real_name]",
"UI"=viable_occupant.dna.uni_identity,
@@ -370,7 +370,7 @@
)
if("clearbuffer")
if(num)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
buffer_slot.Cut()
@@ -387,7 +387,7 @@
apply_buffer(SCANNER_ACTION_MIXED,num)
if("injector")
if(num && injectorready < world.time)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
var/obj/item/dnainjector/timed/I
@@ -436,11 +436,11 @@
injectorready = world.time + INJECTOR_TIMEOUT
if("loaddisk")
if(num && diskette && diskette.fields)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
buffer[num] = diskette.fields.Copy()
if("savedisk")
if(num && diskette && !diskette.read_only)
num = Clamp(num, 1, NUMBER_OF_BUFFERS)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
diskette.name = "data disk \[[buffer_slot["label"]]\]"
@@ -454,8 +454,8 @@
delayed_action = list("action"=text2num(href_list["delayaction"]),"buffer"=num)
if("pulseui","pulsese")
if(num && viable_occupant && connected)
radduration = Wrap(radduration, 1, RADIATION_DURATION_MAX+1)
radstrength = Wrap(radstrength, 1, RADIATION_STRENGTH_MAX+1)
radduration = WRAP(radduration, 1, RADIATION_DURATION_MAX+1)
radstrength = WRAP(radstrength, 1, RADIATION_STRENGTH_MAX+1)
var/locked_state = connected.locked
connected.locked = TRUE
@@ -471,7 +471,7 @@
switch(href_list["task"]) //Same thing as there but values are even lower, on best part they are about 0.0*, effectively no damage
if("pulseui")
var/len = length(viable_occupant.dna.uni_identity)
num = Wrap(num, 1, len+1)
num = WRAP(num, 1, len+1)
num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len) //Each manipulator level above 1 makes randomization as accurate as selected time + manipulator lvl^2
//Value is this high for the same reason as with laser - not worth the hassle of upgrading if the bonus is low
var/block = round((num-1)/DNA_BLOCK_SIZE)+1
@@ -487,7 +487,7 @@
viable_occupant.updateappearance(mutations_overlay_update=1)
if("pulsese")
var/len = length(viable_occupant.dna.struc_enzymes)
num = Wrap(num, 1, len+1)
num = WRAP(num, 1, len+1)
num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len)
var/block = round((num-1)/DNA_BLOCK_SIZE)+1
@@ -518,10 +518,11 @@
ran = round(ran) //negative, so floor it
else
ran = -round(-ran) //positive, so ceiling it
return num2hex(Wrap(hex2num(input)+ran, 0, 16**length), length)
return num2hex(WRAP(hex2num(input)+ran, 0, 16**length), length)
/obj/machinery/computer/scan_consolenew/proc/randomize_radiation_accuracy(position_we_were_supposed_to_hit, radduration, number_of_blocks)
return Wrap(round(position_we_were_supposed_to_hit + gaussian(0, RADIATION_ACCURACY_MULTIPLIER/radduration), 1), 1, number_of_blocks+1)
/obj/machinery/computer/scan_consolenew/proc/randomize_radiation_accuracy(position, radduration, number_of_blocks)
var/val = round(gaussian(0, RADIATION_ACCURACY_MULTIPLIER/radduration) + position, 1)
return WRAP(val, 1, number_of_blocks+1)
/obj/machinery/computer/scan_consolenew/proc/get_viable_occupant()
var/mob/living/carbon/viable_occupant = null
@@ -532,7 +533,7 @@
return viable_occupant
/obj/machinery/computer/scan_consolenew/proc/apply_buffer(action,buffer_num)
buffer_num = Clamp(buffer_num, 1, NUMBER_OF_BUFFERS)
buffer_num = CLAMP(buffer_num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[buffer_num]
var/mob/living/carbon/viable_occupant = get_viable_occupant()
if(istype(buffer_slot))
@@ -106,7 +106,7 @@
return
if(!new_goal)
new_goal = default_goal
id.goal = Clamp(new_goal, 0, 1000) //maximum 1000 points
id.goal = CLAMP(new_goal, 0, 1000) //maximum 1000 points
if("toggle_open")
if(teleporter.locked)
to_chat(usr, "The teleporter is locked")
@@ -154,8 +154,14 @@ GLOBAL_LIST_INIT(possible_uplinker_IDs, list("Alfa","Bravo","Charlie","Delta","E
/obj/machinery/computer/telecrystals/boss/proc/getDangerous()//This scales the TC assigned with the round population.
..()
<<<<<<< HEAD
var/danger = GLOB.joined_player_list.len - SSticker.mode.syndicates.len
danger = Ceiling(danger, 10)
=======
var/list/nukeops = get_antagonists(/datum/antagonist/nukeop)
var/danger = GLOB.joined_player_list.len - nukeops.len
danger = CEILING(danger, 10)
>>>>>>> 25080ff... defines math (#33498)
scaleTC(danger)
/obj/machinery/computer/telecrystals/boss/proc/scaleTC(amt)//Its own proc, since it'll probably need a lot of tweaks for balance, use a fancier algorhithm, etc.
+1 -1
View File
@@ -33,7 +33,7 @@
to_chat(user, "<span class='notice'>You begin repairing [src]...</span>")
playsound(loc, WT.usesound, 40, 1)
if(do_after(user, 40*I.toolspeed, target = src))
obj_integrity = Clamp(obj_integrity + 20, 0, max_integrity)
obj_integrity = CLAMP(obj_integrity + 20, 0, max_integrity)
else
return ..()
+1 -1
View File
@@ -142,7 +142,7 @@
. /= 10
/obj/machinery/door_timer/proc/set_timer(value)
var/new_time = Clamp(value,0,MAX_TIMER)
var/new_time = CLAMP(value,0,MAX_TIMER)
. = new_time == timer_duration //return 1 on no change
timer_duration = new_time
+2 -2
View File
@@ -53,9 +53,9 @@
new /obj/item/pipe_meter(loc)
wait = world.time + 15
if(href_list["layer_up"])
piping_layer = Clamp(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
piping_layer = CLAMP(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
if(href_list["layer_down"])
piping_layer = Clamp(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
piping_layer = CLAMP(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
return
/obj/machinery/pipedispenser/attackby(obj/item/W, mob/user, params)
+1 -1
View File
@@ -256,7 +256,7 @@
use_stored_power(50)
/obj/machinery/shieldwallgen/proc/use_stored_power(amount)
power = Clamp(power - amount, 0, maximum_stored_power)
power = CLAMP(power - amount, 0, maximum_stored_power)
update_activity()
/obj/machinery/shieldwallgen/proc/update_activity()
+2 -2
View File
@@ -121,7 +121,7 @@
settableTemperatureRange = cap * 30
efficiency = (cap + 1) * 10000
targetTemperature = Clamp(targetTemperature,
targetTemperature = CLAMP(targetTemperature,
max(settableTemperatureMedian - settableTemperatureRange, TCMB),
settableTemperatureMedian + settableTemperatureRange)
@@ -223,7 +223,7 @@
target= text2num(target) + T0C
. = TRUE
if(.)
targetTemperature = Clamp(round(target),
targetTemperature = CLAMP(round(target),
max(settableTemperatureMedian - settableTemperatureRange, TCMB),
settableTemperatureMedian + settableTemperatureRange)
if("eject")
+1 -1
View File
@@ -205,7 +205,7 @@
/obj/machinery/syndicatebomb/proc/settings(mob/user)
var/new_timer = input(user, "Please set the timer.", "Timer", "[timer_set]") as num
if(in_range(src, user) && isliving(user)) //No running off and setting bombs from across the station
timer_set = Clamp(new_timer, minimum_timer, maximum_timer)
timer_set = CLAMP(new_timer, minimum_timer, maximum_timer)
loc.visible_message("<span class='notice'>[icon2html(src, viewers(src))] timer set for [timer_set] seconds.</span>")
if(alert(user,"Would you like to start the countdown now?",,"Yes","No") == "Yes" && in_range(src, user) && isliving(user))
if(defused || active)
+1 -1
View File
@@ -175,7 +175,7 @@
for(var/datum/data/vending_product/machine_content in machine)
if(refill.charges[charge_type] == 0)
break
var/restock = Ceiling(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges)
var/restock = CEILING(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges, 1)
if(restock > refill.charges[charge_type])
restock = refill.charges[charge_type]
machine_content.amount += restock
+3 -3
View File
@@ -188,7 +188,7 @@
return queue.len
/obj/machinery/mecha_part_fabricator/proc/remove_from_queue(index)
if(!isnum(index) || !IsInteger(index) || !istype(queue) || (index<1 || index>queue.len))
if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>queue.len))
return FALSE
queue.Cut(index,++index)
return TRUE
@@ -375,8 +375,8 @@
if(href_list["queue_move"] && href_list["index"])
var/index = afilter.getNum("index")
var/new_index = index + afilter.getNum("queue_move")
if(isnum(index) && isnum(new_index) && IsInteger(index) && IsInteger(new_index))
if(IsInRange(new_index,1,queue.len))
if(isnum(index) && isnum(new_index) && ISINTEGER(index) && ISINTEGER(new_index))
if(ISINRANGE(new_index,1,queue.len))
queue.Swap(index,new_index)
return update_queue_on_page()
if(href_list["clear_queue"])
+1 -1
View File
@@ -94,7 +94,7 @@
/obj/mecha/working/ripley/mining/Initialize()
. = ..()
if(cell)
cell.charge = Floor(cell.charge * 0.25) //Starts at very low charge
cell.charge = FLOOR(cell.charge * 0.25, 1) //Starts at very low charge
if(prob(70)) //Maybe add a drill
if(prob(15)) //Possible diamond drill... Feeling lucky?
var/obj/item/mecha_parts/mecha_equipment/drill/diamonddrill/D = new
+5
View File
@@ -27,8 +27,13 @@
aSignal.name = "[name] core"
aSignal.code = rand(1,100)
<<<<<<< HEAD
aSignal.frequency = rand(1200, 1599)
if(IsMultiple(aSignal.frequency, 2))//signaller frequencies are always uneven!
=======
aSignal.frequency = rand(MIN_FREE_FREQ, MAX_FREE_FREQ)
if(ISMULTIPLE(aSignal.frequency, 2))//signaller frequencies are always uneven!
>>>>>>> 25080ff... defines math (#33498)
aSignal.frequency++
if(new_lifespan)
+1 -1
View File
@@ -187,7 +187,7 @@
/obj/effect/chrono_field/update_icon()
var/ttk_frame = 1 - (tickstokill / initial(tickstokill))
ttk_frame = Clamp(Ceiling(ttk_frame * CHRONO_FRAME_COUNT), 1, CHRONO_FRAME_COUNT)
ttk_frame = CLAMP(CEILING(ttk_frame * CHRONO_FRAME_COUNT, 1), 1, CHRONO_FRAME_COUNT)
if(ttk_frame != RPpos)
RPpos = ttk_frame
mob_underlay.icon_state = "frame[RPpos]"
+1 -1
View File
@@ -69,7 +69,7 @@
if(powered) //so it doesn't show charge if it's unpowered
if(cell)
var/ratio = cell.charge / cell.maxcharge
ratio = Ceiling(ratio*4) * 25
ratio = CEILING(ratio*4, 1) * 25
add_overlay("[initial(icon_state)]-charge[ratio]")
/obj/item/defibrillator/CheckParts(list/parts_list)
@@ -169,7 +169,7 @@
// Negative numbers will subtract
/obj/item/device/lightreplacer/proc/AddUses(amount = 1)
uses = Clamp(uses + amount, 0, max_uses)
uses = CLAMP(uses + amount, 0, max_uses)
/obj/item/device/lightreplacer/proc/AddShards(amount = 1, user)
bulb_shards += amount
@@ -228,7 +228,7 @@ effective or pretty fucking useless.
charge = max(0,charge - 25)//Quick decrease in light
else
charge = min(max_charge,charge + 50) //Charge in the dark
animate(user,alpha = Clamp(255 - charge,0,255),time = 10)
animate(user,alpha = CLAMP(255 - charge,0,255),time = 10)
/obj/item/device/jammer
+1 -1
View File
@@ -166,7 +166,7 @@
/obj/item/dice/proc/diceroll(mob/user)
result = rand(1, sides)
if(rigged && result != rigged)
if(prob(Clamp(1/(sides - 1) * 100, 25, 80)))
if(prob(CLAMP(1/(sides - 1) * 100, 25, 80)))
result = rigged
var/fake_result = rand(1, sides)//Daredevil isn't as good as he used to be
var/comment = ""
+2 -2
View File
@@ -87,7 +87,7 @@
return
var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num
if(user.get_active_held_item() == src)
newtime = Clamp(newtime, 10, 60000)
newtime = CLAMP(newtime, 10, 60000)
det_time = newtime
to_chat(user, "Timer set for [det_time] seconds.")
@@ -204,7 +204,7 @@
/obj/item/grenade/plastic/c4/attack_self(mob/user)
var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num
if(user.get_active_held_item() == src)
newtime = Clamp(newtime, 10, 60000)
newtime = CLAMP(newtime, 10, 60000)
timer = newtime
to_chat(user, "Timer set for [timer] seconds.")
+3 -3
View File
@@ -75,7 +75,7 @@
drowse()
return
if(bloodthirst < HIS_GRACE_CONSUME_OWNER)
adjust_bloodthirst(1 + Floor(LAZYLEN(contents) * 0.5)) //Maybe adjust this?
adjust_bloodthirst(1 + FLOOR(LAZYLEN(contents) * 0.5, 1)) //Maybe adjust this?
else
adjust_bloodthirst(1) //don't cool off rapidly once we're at the point where His Grace consumes all.
var/mob/living/master = get_atom_on_turf(src, /mob/living)
@@ -164,9 +164,9 @@
/obj/item/his_grace/proc/adjust_bloodthirst(amt)
prev_bloodthirst = bloodthirst
if(prev_bloodthirst < HIS_GRACE_CONSUME_OWNER)
bloodthirst = Clamp(bloodthirst + amt, HIS_GRACE_SATIATED, HIS_GRACE_CONSUME_OWNER)
bloodthirst = CLAMP(bloodthirst + amt, HIS_GRACE_SATIATED, HIS_GRACE_CONSUME_OWNER)
else
bloodthirst = Clamp(bloodthirst + amt, HIS_GRACE_CONSUME_OWNER, HIS_GRACE_FALL_ASLEEP)
bloodthirst = CLAMP(bloodthirst + amt, HIS_GRACE_CONSUME_OWNER, HIS_GRACE_FALL_ASLEEP)
update_stats()
/obj/item/his_grace/proc/update_stats()
+2 -2
View File
@@ -198,8 +198,8 @@
return target
var/x_o = (target.x - starting.x)
var/y_o = (target.y - starting.y)
var/new_x = Clamp((starting.x + (x_o * range_multiplier)), 0, world.maxx)
var/new_y = Clamp((starting.y + (y_o * range_multiplier)), 0, world.maxy)
var/new_x = CLAMP((starting.x + (x_o * range_multiplier)), 0, world.maxx)
var/new_y = CLAMP((starting.y + (y_o * range_multiplier)), 0, world.maxy)
var/turf/newtarget = locate(new_x, new_y, starting.z)
return newtarget
+2 -2
View File
@@ -616,7 +616,7 @@
continue
usage += projectile_tick_speed_ecost
usage += (tracked[I] * projectile_damage_tick_ecost_coefficient)
energy = Clamp(energy - usage, 0, maxenergy)
energy = CLAMP(energy - usage, 0, maxenergy)
if(energy <= 0)
deactivate_field()
visible_message("<span class='warning'>[src] blinks \"ENERGY DEPLETED\".</span>")
@@ -626,7 +626,7 @@
if(iscyborg(host.loc))
host = host.loc
else
energy = Clamp(energy + energy_recharge, 0, maxenergy)
energy = CLAMP(energy + energy_recharge, 0, maxenergy)
return
if((host.cell.charge >= (host.cell.maxcharge * cyborg_cell_critical_percentage)) && (energy < maxenergy))
host.cell.use(energy_recharge*energy_recharge_cyborg_drain_coefficient)
+3 -3
View File
@@ -35,14 +35,14 @@
if(TH.force_wielded > initial(TH.force_wielded))
to_chat(user, "<span class='warning'>[TH] has already been refined before. It cannot be sharpened further!</span>")
return
TH.force_wielded = Clamp(TH.force_wielded + increment, 0, max)//wieldforce is increased since normal force wont stay
TH.force_wielded = CLAMP(TH.force_wielded + increment, 0, max)//wieldforce is increased since normal force wont stay
if(I.force > initial(I.force))
to_chat(user, "<span class='warning'>[I] has already been refined before. It cannot be sharpened further!</span>")
return
user.visible_message("<span class='notice'>[user] sharpens [I] with [src]!</span>", "<span class='notice'>You sharpen [I], making it much more deadly than before.</span>")
I.sharpness = IS_SHARP_ACCURATE
I.force = Clamp(I.force + increment, 0, max)
I.throwforce = Clamp(I.throwforce + increment, 0, max)
I.force = CLAMP(I.force + increment, 0, max)
I.throwforce = CLAMP(I.throwforce + increment, 0, max)
I.name = "[prefix] [I.name]"
name = "worn out [name]"
desc = "[desc] At least, it used to."
+2 -2
View File
@@ -37,9 +37,9 @@
/obj/item/stack/proc/update_weight()
if(amount <= (max_amount * (1/3)))
w_class = Clamp(full_w_class-2, WEIGHT_CLASS_TINY, full_w_class)
w_class = CLAMP(full_w_class-2, WEIGHT_CLASS_TINY, full_w_class)
else if (amount <= (max_amount * (2/3)))
w_class = Clamp(full_w_class-1, WEIGHT_CLASS_TINY, full_w_class)
w_class = CLAMP(full_w_class-1, WEIGHT_CLASS_TINY, full_w_class)
else
w_class = full_w_class
+1 -1
View File
@@ -194,7 +194,7 @@
pressure = text2num(pressure)
. = TRUE
if(.)
distribute_pressure = Clamp(round(pressure), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE)
distribute_pressure = CLAMP(round(pressure), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE)
/obj/item/tank/remove_air(amount)
return air_contents.remove(amount)
@@ -1,3 +1,4 @@
<<<<<<< HEAD
#define WELDER_FUEL_BURN_INTERVAL 13
/obj/item/weldingtool
name = "welding tool"
@@ -336,4 +337,350 @@
item_state = "brasswelder"
/obj/item/weldingtool/experimental/process()
..()
if(get_fuel() < max_fuel && nextrefueltick < world.time)
nextrefueltick = world.time + 10
reagents.add_reagent("welding_fuel", 1)
=======
#define WELDER_FUEL_BURN_INTERVAL 13
/obj/item/weldingtool
name = "welding tool"
desc = "A standard edition welder provided by Nanotrasen."
icon = 'icons/obj/tools.dmi'
icon_state = "welder"
item_state = "welder"
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
flags_1 = CONDUCT_1
slot_flags = SLOT_BELT
force = 3
throwforce = 5
hitsound = "swing_hit"
usesound = 'sound/items/welder.ogg'
var/acti_sound = 'sound/items/welderactivate.ogg'
var/deac_sound = 'sound/items/welderdeactivate.ogg'
throw_speed = 3
throw_range = 5
w_class = WEIGHT_CLASS_SMALL
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 100, acid = 30)
resistance_flags = FIRE_PROOF
materials = list(MAT_METAL=70, MAT_GLASS=30)
var/welding = 0 //Whether or not the welding tool is off(0), on(1) or currently welding(2)
var/status = TRUE //Whether the welder is secured or unsecured (able to attach rods to it to make a flamethrower)
var/max_fuel = 20 //The max amount of fuel the welder can hold
var/change_icons = 1
var/can_off_process = 0
var/light_intensity = 2 //how powerful the emitted light is when used.
var/burned_fuel_for = 0 //when fuel was last removed
heat = 3800
toolspeed = 1
/obj/item/weldingtool/Initialize()
. = ..()
create_reagents(max_fuel)
reagents.add_reagent("welding_fuel", max_fuel)
update_icon()
/obj/item/weldingtool/proc/update_torch()
if(welding)
add_overlay("[initial(icon_state)]-on")
item_state = "[initial(item_state)]1"
else
item_state = "[initial(item_state)]"
/obj/item/weldingtool/update_icon()
cut_overlays()
if(change_icons)
var/ratio = get_fuel() / max_fuel
ratio = CEILING(ratio*4, 1) * 25
add_overlay("[initial(icon_state)][ratio]")
update_torch()
return
/obj/item/weldingtool/process()
switch(welding)
if(0)
force = 3
damtype = "brute"
update_icon()
if(!can_off_process)
STOP_PROCESSING(SSobj, src)
return
//Welders left on now use up fuel, but lets not have them run out quite that fast
if(1)
force = 15
damtype = "fire"
++burned_fuel_for
if(burned_fuel_for >= WELDER_FUEL_BURN_INTERVAL)
remove_fuel(1)
update_icon()
//This is to start fires. process() is only called if the welder is on.
open_flame()
/obj/item/weldingtool/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] welds [user.p_their()] every orifice closed! It looks like [user.p_theyre()] trying to commit suicide!</span>")
return (FIRELOSS)
/obj/item/weldingtool/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/screwdriver))
flamethrower_screwdriver(I, user)
else if(istype(I, /obj/item/stack/rods))
flamethrower_rods(I, user)
else
. = ..()
update_icon()
/obj/item/weldingtool/proc/explode()
var/turf/T = get_turf(loc)
var/plasmaAmount = reagents.get_reagent_amount("plasma")
dyn_explosion(T, plasmaAmount/5)//20 plasma in a standard welder has a 4 power explosion. no breaches, but enough to kill/dismember holder
qdel(src)
/obj/item/weldingtool/attack(mob/living/carbon/human/H, mob/user)
if(!istype(H))
return ..()
var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected))
if(affecting && affecting.status == BODYPART_ROBOTIC && user.a_intent != INTENT_HARM)
if(src.remove_fuel(1))
playsound(loc, usesound, 50, 1)
if(user == H)
user.visible_message("<span class='notice'>[user] starts to fix some of the dents on [H]'s [affecting.name].</span>", "<span class='notice'>You start fixing some of the dents on [H]'s [affecting.name].</span>")
if(!do_mob(user, H, 50))
return
item_heal_robotic(H, user, 15, 0)
else
return ..()
/obj/item/weldingtool/afterattack(atom/O, mob/user, proximity)
if(!proximity)
return
if(!status && istype(O, /obj/item/reagent_containers) && O.is_open_container())
reagents.trans_to(O, reagents.total_volume)
to_chat(user, "<span class='notice'>You empty [src]'s fuel tank into [O].</span>")
update_icon()
if(welding)
remove_fuel(1)
var/turf/location = get_turf(user)
location.hotspot_expose(700, 50, 1)
if(get_fuel() <= 0)
set_light(0)
if(isliving(O))
var/mob/living/L = O
if(L.IgniteMob())
message_admins("[key_name_admin(user)] set [key_name_admin(L)] on fire")
log_game("[key_name(user)] set [key_name(L)] on fire")
/obj/item/weldingtool/attack_self(mob/user)
if(src.reagents.has_reagent("plasma"))
message_admins("[key_name_admin(user)] activated a rigged welder.")
explode()
switched_on(user)
if(welding)
set_light(light_intensity)
update_icon()
//Returns the amount of fuel in the welder
/obj/item/weldingtool/proc/get_fuel()
return reagents.get_reagent_amount("welding_fuel")
//Removes fuel from the welding tool. If a mob is passed, it will try to flash the mob's eyes. This should probably be renamed to use()
/obj/item/weldingtool/proc/remove_fuel(amount = 1, mob/living/M = null)
if(!welding || !check_fuel())
return 0
if(amount)
burned_fuel_for = 0
if(get_fuel() >= amount)
reagents.remove_reagent("welding_fuel", amount)
check_fuel()
if(M)
M.flash_act(light_intensity)
return TRUE
else
if(M)
to_chat(M, "<span class='warning'>You need more welding fuel to complete this task!</span>")
return FALSE
//Turns off the welder if there is no more fuel (does this really need to be its own proc?)
/obj/item/weldingtool/proc/check_fuel(mob/user)
if(get_fuel() <= 0 && welding)
switched_on(user)
update_icon()
//mob icon update
if(ismob(loc))
var/mob/M = loc
M.update_inv_hands(0)
return 0
return 1
//Switches the welder on
/obj/item/weldingtool/proc/switched_on(mob/user)
if(!status)
to_chat(user, "<span class='warning'>[src] can't be turned on while unsecured!</span>")
return
welding = !welding
if(welding)
if(get_fuel() >= 1)
to_chat(user, "<span class='notice'>You switch [src] on.</span>")
playsound(loc, acti_sound, 50, 1)
force = 15
damtype = "fire"
hitsound = 'sound/items/welder.ogg'
update_icon()
START_PROCESSING(SSobj, src)
else
to_chat(user, "<span class='warning'>You need more fuel!</span>")
switched_off(user)
else
to_chat(user, "<span class='notice'>You switch [src] off.</span>")
playsound(loc, deac_sound, 50, 1)
switched_off(user)
//Switches the welder off
/obj/item/weldingtool/proc/switched_off(mob/user)
welding = 0
set_light(0)
force = 3
damtype = "brute"
hitsound = "swing_hit"
update_icon()
/obj/item/weldingtool/examine(mob/user)
..()
to_chat(user, "It contains [get_fuel()] unit\s of fuel out of [max_fuel].")
/obj/item/weldingtool/is_hot()
return welding * heat
//Returns whether or not the welding tool is currently on.
/obj/item/weldingtool/proc/isOn()
return welding
/obj/item/weldingtool/proc/flamethrower_screwdriver(obj/item/I, mob/user)
if(welding)
to_chat(user, "<span class='warning'>Turn it off first!</span>")
return
status = !status
if(status)
to_chat(user, "<span class='notice'>You resecure [src] and close the fuel tank.</span>")
container_type = NONE
else
to_chat(user, "<span class='notice'>[src] can now be attached, modified, and refuelled.</span>")
container_type = OPENCONTAINER_1
add_fingerprint(user)
/obj/item/weldingtool/proc/flamethrower_rods(obj/item/I, mob/user)
if(!status)
var/obj/item/stack/rods/R = I
if (R.use(1))
var/obj/item/flamethrower/F = new /obj/item/flamethrower(user.loc)
if(!remove_item_from_storage(F))
user.transferItemToLoc(src, F, TRUE)
F.weldtool = src
add_fingerprint(user)
to_chat(user, "<span class='notice'>You add a rod to a welder, starting to build a flamethrower.</span>")
user.put_in_hands(F)
else
to_chat(user, "<span class='warning'>You need one rod to start building a flamethrower!</span>")
/obj/item/weldingtool/ignition_effect(atom/A, mob/user)
if(welding && remove_fuel(1, user))
. = "<span class='notice'>[user] casually lights [A] with [src], what a badass.</span>"
else
. = ""
/obj/item/weldingtool/largetank
name = "industrial welding tool"
desc = "A slightly larger welder with a larger tank."
icon_state = "indwelder"
max_fuel = 40
materials = list(MAT_GLASS=60)
/obj/item/weldingtool/largetank/cyborg
name = "integrated welding tool"
desc = "An advanced welder designed to be used in robotic systems."
toolspeed = 0.5
/obj/item/weldingtool/largetank/flamethrower_screwdriver()
return
/obj/item/weldingtool/mini
name = "emergency welding tool"
desc = "A miniature welder used during emergencies."
icon_state = "miniwelder"
max_fuel = 10
w_class = WEIGHT_CLASS_TINY
materials = list(MAT_METAL=30, MAT_GLASS=10)
change_icons = 0
/obj/item/weldingtool/mini/flamethrower_screwdriver()
return
/obj/item/weldingtool/abductor
name = "alien welding tool"
desc = "An alien welding tool. Whatever fuel it uses, it never runs out."
icon = 'icons/obj/abductor.dmi'
icon_state = "welder"
toolspeed = 0.1
light_intensity = 0
change_icons = 0
/obj/item/weldingtool/abductor/process()
if(get_fuel() <= max_fuel)
reagents.add_reagent("welding_fuel", 1)
..()
/obj/item/weldingtool/hugetank
name = "upgraded industrial welding tool"
desc = "An upgraded welder based of the industrial welder."
icon_state = "upindwelder"
item_state = "upindwelder"
max_fuel = 80
materials = list(MAT_METAL=70, MAT_GLASS=120)
/obj/item/weldingtool/experimental
name = "experimental welding tool"
desc = "An experimental welder capable of self-fuel generation and less harmful to the eyes."
icon_state = "exwelder"
item_state = "exwelder"
max_fuel = 40
materials = list(MAT_METAL=70, MAT_GLASS=120)
var/last_gen = 0
change_icons = 0
can_off_process = 1
light_intensity = 1
toolspeed = 0.5
var/nextrefueltick = 0
/obj/item/weldingtool/experimental/brass
name = "brass welding tool"
desc = "A brass welder that seems to constantly refuel itself. It is faintly warm to the touch."
resistance_flags = FIRE_PROOF | ACID_PROOF
icon_state = "brasswelder"
item_state = "brasswelder"
/obj/item/weldingtool/experimental/process()
..()
if(get_fuel() < max_fuel && nextrefueltick < world.time)
+1 -1
View File
@@ -198,7 +198,7 @@ GLOBAL_DATUM_INIT(acid_overlay, /mutable_appearance, mutable_appearance('icons/e
if(T.intact && level == 1) //fire can't damage things hidden below the floor.
return
if(exposed_temperature && !(resistance_flags & FIRE_PROOF))
take_damage(Clamp(0.02 * exposed_temperature, 0, 20), BURN, "fire", 0)
take_damage(CLAMP(0.02 * exposed_temperature, 0, 20), BURN, "fire", 0)
if(!(resistance_flags & ON_FIRE) && (resistance_flags & FLAMMABLE))
resistance_flags |= ON_FIRE
SSfire_burning.processing[src] = src
+1 -1
View File
@@ -129,7 +129,7 @@
if(burn_time_remaining() < MAXIMUM_BURN_TIMER)
flame_expiry_timer = world.time + MAXIMUM_BURN_TIMER
else
fuel_added = Clamp(fuel_added + amount, 0, MAXIMUM_BURN_TIMER)
fuel_added = CLAMP(fuel_added + amount, 0, MAXIMUM_BURN_TIMER)
/obj/structure/fireplace/proc/burn_time_remaining()
if(lit)
+1 -1
View File
@@ -30,7 +30,7 @@
return
var/ratio = obj_integrity / max_integrity
ratio = Ceiling(ratio*4) * 25
ratio = CEILING(ratio*4, 1) * 25
if(smooth)
queue_smooth(src)
+2 -2
View File
@@ -67,7 +67,7 @@
resistance_flags |= INDESTRUCTIBLE
/obj/structure/lattice/clockwork/ratvar_act()
if(IsOdd(x+y))
if(ISODD(x+y))
icon = 'icons/obj/smooth_structures/lattice_clockwork_large.dmi'
pixel_x = -9
pixel_y = -9
@@ -124,7 +124,7 @@
resistance_flags |= INDESTRUCTIBLE
/obj/structure/lattice/catwalk/clockwork/ratvar_act()
if(IsOdd(x+y))
if(ISODD(x+y))
icon = 'icons/obj/smooth_structures/catwalk_clockwork_large.dmi'
pixel_x = -9
pixel_y = -9
+1 -1
View File
@@ -119,7 +119,7 @@
else
cur_oct[cur_note] = text2num(ni)
if(user.dizziness > 0 && prob(user.dizziness / 2))
cur_note = Clamp(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7)
cur_note = CLAMP(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7)
if(user.dizziness > 0 && prob(user.dizziness / 5))
if(prob(30))
cur_acc[cur_note] = "#"
+12 -21
View File
@@ -165,7 +165,7 @@
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!isnull(new_angle))
setAngle(NORM_ROT(new_angle))
setAngle(SIMPLIFY_DEGREES(new_angle))
return TRUE
/obj/structure/reflector/AltClick(mob/user)
@@ -197,16 +197,12 @@
anchored = TRUE
/obj/structure/reflector/single/auto_reflect(obj/item/projectile/P, pdir, turf/ploc, pangle)
var/incidence = get_angle_of_incidence(rotation_angle, P.Angle)
var/incidence_norm = get_angle_of_incidence(rotation_angle, P.Angle, FALSE)
if((incidence_norm > -90) && (incidence_norm < 90))
var/incidence = GET_ANGLE_OF_INCIDENCE(rotation_angle, P.Angle)
var/norm_inc = WRAP(incidence, -90, 90)
var/new_angle = WRAP(rotation_angle + norm_inc, 180, -180)
if(ISINRANGE_EX(norm_inc, -90, 90))
return FALSE
var/new_angle_s = rotation_angle + incidence
while(new_angle_s > 180) // Translate to regular projectile degrees
new_angle_s -= 360
while(new_angle_s < -180)
new_angle_s += 360
P.Angle = new_angle_s
P.Angle = new_angle
return ..()
//DOUBLE
@@ -228,17 +224,12 @@
anchored = TRUE
/obj/structure/reflector/double/auto_reflect(obj/item/projectile/P, pdir, turf/ploc, pangle)
var/incidence = get_angle_of_incidence(rotation_angle, P.Angle)
var/incidence_norm = get_angle_of_incidence(rotation_angle, P.Angle, FALSE)
var/invert = ((incidence_norm > -90) && (incidence_norm < 90))
var/new_angle_s = rotation_angle + incidence
if(invert)
new_angle_s += 180
while(new_angle_s > 180) // Translate to regular projectile degrees
new_angle_s -= 360
while(new_angle_s < -180)
new_angle_s += 360
P.Angle = new_angle_s
var/incidence = GET_ANGLE_OF_INCIDENCE(rotation_angle, P.Angle)
var/norm_inc = WRAP(incidence, -90, 90)
var/new_angle = WRAP(rotation_angle + norm_inc, 180, -180)
if(ISINRANGE_EX(norm_inc, -90, 90))
new_angle += 180
P.Angle = new_angle
return ..()
//BOX
+2 -2
View File
@@ -134,8 +134,8 @@
if(!click_params || !click_params["icon-x"] || !click_params["icon-y"])
return
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
I.pixel_x = Clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2)
I.pixel_y = Clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2)
I.pixel_x = CLAMP(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2)
I.pixel_y = CLAMP(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2)
return 1
else
return ..()
+1 -1
View File
@@ -380,7 +380,7 @@
return
var/ratio = obj_integrity / max_integrity
ratio = Ceiling(ratio*4) * 25
ratio = CEILING(ratio*4, 1) * 25
if(smooth)
queue_smooth(src)
@@ -188,7 +188,7 @@
break
var/list/L = list(45)
if(IsOdd(dir2angle(dir))) // We're going at an angle and we want thick angled tunnels.
if(ISODD(dir2angle(dir))) // We're going at an angle and we want thick angled tunnels.
L += -45
// Expand the edges of our tunnel
+1 -1
View File
@@ -54,7 +54,7 @@
var/turf/p_turf = get_turf(P)
var/face_direction = get_dir(src, p_turf)
var/face_angle = dir2angle(face_direction)
var/incidence_s = get_angle_of_incidence(face_angle, P.Angle)
var/incidence_s = WRAP(GET_ANGLE_OF_INCIDENCE(face_angle, P.Angle), -90, 90)
var/new_angle = face_angle + incidence_s
var/new_angle_s = new_angle
while(new_angle_s > 180) // Translate to regular projectile degrees