Time to talk about the elemental system.
When I was asking about social situations a wee bit back, Shark Bait
mentioned color theory and the color wheel.
Today, this concept got me thinking about a potential new type of elemental system: an elemental wheel. Here is a color wheel, which I will use as a reference:
Fig. 1
Notice in figure 1 that it is black in the center, then becomes more colourful towards the outside. This shows two important concepts in my idea: elemental vs non elemental (black vs coloured) and different types of elementals (the different hues).
Your character's defense or attack can only hold any one point on this circle, which I will refer to using polar coordinates, since the make sense here and will make the math easier.
A quick refresher on polar coordinates if you have forgotten (skip if you remember how they work):
Any polar coordinate has two values. θ (the Greek letter theta), and r. θ is the angle, and r is the radius. A point is defined as r units away from the origin (the center of the circle) and and angle θ around the circle. θ = 0 is to the right from the center, π/4 is up, π is left, and 3π/4 is down. (Remember π radians is 180°, so 2π = 360°, and the math to convert is simple knowing that). When writing a polar coordinate, r goes first: (r,θ).
Done with math reminder.
A weapon or armour's elemental attribute is defined as a single point on the circle (r,θ), where r is how elemental it is (as opposed to non-elemental) and θ is what kind of elemental.
As I said, a character's elemental attribute is just one point, so it would be defined as the sum of all equipped elementals, using vector addition, with the final sum truncated to remain within the circle.
Valid values for θ are between 0 (inclusive) and 2π (exclusive), and r is between 0 and 1 (inclusive on both).
When attacking, effective element will be attack - defense, again vector subtraction.
Potential damage is the number after the attack and defense numbers have been calculated.
Raw elemental damage = raw damage * attacker's element radius
Raw nonelemental damage = raw damage * (1 - attacker's element radius)
Final damage = elemental damage (calculated below) + raw non elemental damage.
Elemental damage = raw elemental damage * effective element radius * abs(θ from the effective element - θ from the defender's element) / π.
EXCEPT when θ1 = θ2, in which case elemental damage = (effective elemental radius - 1) * raw elemental damage.
The except clause makes absorbing elements possible if you are being hit by your own exact element.
This formula might still need refonement, but I like it thus far.
This formula does account for the situation if an attacker hits someone on the opposite side of the wheel, it will do double damage.
I think this provides a more innovative solution of defending, being weak to, or absorbing elements. Let's define a few examples.
Lightning will be
violet on the wheel, fire is
red on the wheel, ice is
cyan, and water is
blue. In all these examples, we are dealing with pure elementals (i.e., no non-elemental component to worry about).
If lightning were to hit fire for a potential damage of 100, how much damage would actually be done?
Lightning's coordinate is (1,5π/8).
Fire's coordinate is (1,π).
Vector subtraction to get the radius is done by:
(the 1s and 2s here should be subscripts)
r = sqrt( ((r1 * cos(θ1)) - (r2*cos(θ2)))^2 + ((r1 * sin(θ1)) - (r2 * sin(θ2)))^2 )
θ = arctan( ((r1 * sin(θ1)) - (r2 * sin(θ2))) / ((r1 * cos(θ1)) - (r2*cos(θ2))))
Where r1 and θ1 is the attacker's coordinate on the circle, and r2 and θ2 is the defender's.
Plugging in the values yields an answer of r = 1.11 and θ = ~ 4.1. Finally plugging into the damage formula will give a damage of 76, unless I made an error.
And I am tired of doing all the math by hand, so I am going to write a program to do it for me before doing any more examples.