v = 10 = +50% damage
v = 9 = +40% damage
v = 8 = +30% damage
v = 7 = +20% damage
v = 6 = +10% damage
v = 5 = -50% damage
v = 4 = -40% damage
v = 3 = - 30% damage
v = 2 = - 20% damage
v = 1 = -10% damage
The "easy" way would be rescaling the variable to be 5 = +50%, -5 = -50%, and have a 0. Since, however, that would require more attention with how you manipulate the variable that may or may not be possible or easily difficult...
dmg = (100+a.mat*4-b.mdf*3); if v[x] >= 6 and v[x] <= 10; (1+((v-5)/10))*dmg; elsif v[x] >= 1 and v[x] <= 5; (1-(v/10))*dmg; end
[128 characters first draft]
So this
1. stores the base output for easy calling and space-saving (it saves like 10 characters of space)
2. checks if the variable is 6~10, since i'm not sure what you want if the variable is greater than 10
3. returns appropriate value-- 1~5 for 6~10 is simply -5 then divide by 10.
4. checks if the variable is 1~5, since again i'm not sure what you want if the variable is less than 1 or greater than 5.
5. returns appropriate value-- 1 - (v/10) is pretty easy.
that's too long though so...
reduce variable lengths as much as possible, remove some spaces.
M=(100+a.mat*4-b.mdf*3);if v[x]>=6 and v[x]<=10;(1+((v-5)/10))*M;elsif v[x]>=1 and v[x]<=5;(1-(v/10))*M;end
still 107 characters.
Removing most of the unlisted cases (variable is greater than 10 or between 5 and 6),
M=(100+a.mat*4-b.mdf*3);if v[x]>=6;(1+((v-5)/10))*M;elsif v[x]>=1;(1-(v/10))*M;end
(82 characters)
In this case you can actually sub out the "elsif v[x] >=1" for just "else" if you want to further reduce this (73 characters if you do); but that means if the variable is less than 0 the damage will start increasing.