Walk around a coordinate in circular order to a distance of N

For my development purpose, I need to work on all the 2D coordinates (in whole number) around [0,0] from 0 to N distance. For example, with N=1, I need

N0: [0, 0] N1: [-1, -1] [0, -1] [1, -1] [1, 0] [1, 1] [0, 1] [-1, 1] [-1, 0] 

The order is important. I want to walk these values in a circular way, starting from 0, incrementing the distance each round.

I first created two for-loops, from -N to N on each axes, but the resulting order is the one as you read a book: from top left to bottom right.

Here’s the order I aim (the first coordinate to walk on each circle is not important):

walking order

Here’s a first algorithm I tried, in pseudo code

int totalSize = (2*N+1, 2)*(2*N+1, 2) Vector2[] coordinates = new Vector2[totalSize] int index = 0 coordinates[index++] = new Vector2(0, 0) for (int d = 1; d <= N; d++) {     for (int x = -d; x <= d; x++) {         coordinates[index++] = new Vector2(x, -d)         coordinates[index++] = new Vector2(x, d)     }     for (int y = -d+1; y <= d-1; y++) {         coordinates[index++] = new Vector2(-d, y)         coordinates[index++] = new Vector2(d, y)     } } for (int i=0; i<coordinates.Length; i++) {     print(coordinates[i]) } 

But:

  • It seems too cumbersome. I don’t like the creation of a scructure that retains the coordinates. And 4 for-loops seems not optimized.

  • The order of the circles is ok, but the order inside each circle is not the one I described.

  • I have the feeling trigonometry can help me, but I can’t see how to implement it on discrete values

Any idea?

What are the rules/recommendations around changing someone’s spell casting stat?

Each magic class seems to have a stat associated with it (Int, Wis, or Cha), used to determine stats such as spell save difficulty class, or the power of certain abilities that the class has.

I think sorcerers and warlocks use Charisma. I understand how Charisma might translate to power for most warlocks (as they would be able to strike a pact with their patron and convince it that they are on track with their task more easily), but what if they made a pact with someone who doesn’t care about how their servants present themselves, but has faith in those with a high intelligence (or wisdom).

If you wanted to create a sorcerer or warlock who’s character traits make them bad at social situations, but great at their craft (or the other way around), then I’d expect this would be done by requesting to use your preferred stat instead of Charisma for your spell casting modifier, spell save difficulty class, and any other Charisma calculation that’s directly part of your class abilities (or possibly JUST your spell casting modifier and spell save DC if you wanted to make a more mixed character). How would various dungeon masters respond to this sort of request, and how would you recommend someone respond to that sort of request if they were a dungeon master?

Basically:

  • Are there any rules that allow players to change the stat that represents someone’s spell casting ability? (They don’t necessarily have to be official)
  • Does the ability to do so unbalance the game in any way? (This is about changing the magic stat for a (few) specific character(s), not everyone of a class)

(…also, why would charisma be important to a sorcerer?)

rolling around running numbers

I’m numbering generated files with two digits 00-99 and I want to retain the last 50. The algorithm should tell me the number of the current file that I’m about to save and which of the previous files to remove.

If I scale it down to a toy version with one digits, here’s how I want it to behave.

  1. As long as there are fewer than 5 files, we can just add files. This is represented in the first block below.
  2. Once there are 5 previous files, the oldest one should be deleted. This is trivial as long as we haven’t reached the maximum number, here 9. This is represented in the second block below.
  3. Once the highest numbers has been reached, the numbering should roll around, and here is where things get tricky. See the third block below.
__prev__    __curr__   __drop__   <no files>     0         null 0              1         null 0 1            2         null 0 1 2          3         null 0 1 2 3        4         null  0 1 2 3 4      5          0  1 2 3 4 5      6          1 2 3 4 5 6      7          2 3 4 5 6 7      8          3 4 5 6 7 8      9          4  5 6 7 8 9      0          5 6 7 8 9 0      1          6 7 8 9 0 1      2          7 8 9 0 1 2      3          8 9 0 1 2 3      4          9 

Some pseudocode to illustrate my progress:

if length(prev) < 5    curr = length(prev)    drop = null  else  if 9 not in prev    curr = (1+max(prev)) mod(10)    drop = curr-5  if 9 in prev 

… and this is where I’m stuck. I’ve experimented with subtracting 10 from each element in prev.

I’m sure it’s trivial and that It’ll hit me when I least expect it. I also have a nagging feeling I’ll find an expression that generalizes both cases (with and without max in prev).

Drawing outlines around 2D objects OpenGL

I am trying to draw an outline around any arbitrary object using OpenGL and shaders with a different color than the original object, while also retaining compatibility with alpha values <1. I am currently trying to get this working with just a rectangle. I tried using points to determine x, y, width, and height, but these would then fail to be transformed by view and projection matrices. Using triangles renders a regular rectangle, but I can’t figure out how to create an outline around it. While I am making a 2D engine, being able to transform into 3D (ex: spinning the object on all 3 axes while retaining the outline, but not actually rendering 3D objects) is important to me.

Here is my current vertex array:

float vertices[8] = {     0.5f,  0.5f,     0.5f, -0.5f,    -0.5f, -0.5f,    -0.5f,  0.5f }; 

Here is my vertex shader:

#version 330 core  layout (location = 0) in vec2 inPos;  uniform mat4 transform; uniform mat4 view; uniform mat4 projection;  uniform vec4 vsColor; uniform float vsOutline; uniform vec4 vsOutlineColor;  out VS_OUT {     vec4 color;     vec4 outlineColor;     float outlineWidth; } vs_out;  void main() {     gl_Position = projection * view * transform * vec4(inPos, 0.0, 1.0);     vs_out.color = vsColor;     vs_out.outlineColor = vsOutlineColor;     vs_out.outlineWidth = vsOutline; } 

Here is my geometry shader, which currently just acts as a passthrough:

#version 330 core  layout (triangles) in; layout (triangle_strip, max_vertices = 3) out;  out vec4 fsColor;  in VS_OUT {     vec4 color;     vec4 outlineColor;     float outlineWidth; } gs_in[];  void main() {     // Draw main triangle (passthrough)     fsColor = gs_in[0].color;     gl_Position = gl_in[0].gl_Position;     EmitVertex();     gl_Position = gl_in[1].gl_Position;     EmitVertex();     gl_Position = gl_in[2].gl_Position;     EmitVertex();      // ===UNKNOWN===     // Outline the object (WIP)     fsColor = gs_in[0].outlineColor;      EndPrimitive(); } 

Finally, here is my fragment shader:

#version 330 core  in vec4 fsColor;  out vec4 fragColor;  void main() {     fragColor = fsColor;      if (fragColor.a == 0) discard; } 

I am unsure if I need to do outlining in the geometry or fragment shader. I would like to have an implementation that could work with non-regular shapes (such as sprites), but that is not required at this time. However, it does have to work with other shapes such as circles and triangles.

Here is an image of the current state of my engine, with the pink rectangle needing to be outlined: engine screenshot

The box texture shows how objects may be transformed in the game, as well as the necessity of alpha compatibility.

Syntax error around converting timestamps to time

I am writing a function that requires some comparison between the difference date and time parts of the timestamp data type. However it keeps running into syntax errors and I cannot find out what is going on. I looked into this post and keep having alternating errors like

psql:ERROR: operator does not exist: time without time zone >= timestamp with time zone and

plpgsql: No function matches the given name and argument types. You might need to add explicit type casts

Can anyone enlighten me what is wrong and what could be a direction I can head towards?

create or replace function riders_available_at_date_time(specified timestamp) returns table(riderId integer) as     $  $       begin         select F.riderId         from FullTimeRiders F         where specified::date between F.startDate and F.startDate+27         and exists (             select 1             from MWSWorkDays M join ShiftsInformation S on (S.shiftNumber = M.shift)             where M.riderId = F.riderId             and (specified::time without time zone between to_timestamp(to_char(firstStartHour, '99'), 'HH24')                 and to_timestamp(to_char(firstEndHour, '99'), 'HH24')) or                 (specified::time without time zone between to_timestamp(to_char(secondStartHour, '99'), 'HH24') and                     to_timestamp(to_char(secondEndHour, '99'), 'HH24'))                   )           union         select riderId         from PartTimeWorkingHourIntervals P         where specified between calculate_start_date(P.dayIndex, P.startDate)+P.startHour             and calculate_start_date(P.dayIndex, P.startDate) + P.endHour;     end;     $  $   language plpgsql;   create or replace function calculate_start_date(index int, starting date) returns date as     $  $       declare         position integer;     begin         select extract(dow from starting::date) into position;         index = (index - position)%7;         return starting + index;     end;     $  $   language plpgsql; 

Is the Ixalan Vampire’s Bloodthirst ability balanced around being used on downed enemy combatants?

For reference…

Bloodthirst

You can drain blood and life energy from a willing creature, or one that is grappled by you, incapacitated, or restrained. Make a melee attack against the target. If you hit, you deal 1 piercing damage and 1d6 necrotic damage. The target’s hit point maximum is reduced by an amount equal to the necrotic damage taken, and you regain hit points equal to that amount. The reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0.

I’m a DM. I have a player who states that RAW, he can use this ability on knocked out (downed) enemy combatants at the end of combat for a 2d6 heal per combatant (and potentially 4d6 if they succeed their final death save on their turn). It’s his intention that with party teamwork, a large majority (if not all) of the combatants will be knocked out, allowing for fairly substantial free post-combat healing.

While RAW this seems to be the case, to me it doesn’t seem balanced. What are the opinions of other DM’s about the balance of this ability with this in mind?

How do I continue a smooth stroke around a corner in zBrush?

I have been trying to create a series of smooth lines down the outside of a bell shape, around the lip, and then back up the inside. The problem is that I can’t seem to accomplish this in a single brush stroke, and every time I’ve tried to join up multiple strokes, the join always looks really obvious.

enter image description here

Is there any way to “pause” a stroke so that you can rotate your view, and then resume it smoothly? Or is there any other way in general to go about something like this?

If a character casts Fog Cloud around themselves before moving away from an enemy, do they provoke an opportunity attack?

Our party was forced to brawl against a group of orcs in order to gain their respect to speak with their chieftain (long story, we had very good reason for doing this). It then became a battle royale.

Our wizard was at low health and next to our paladin, and had the idea to cast fog cloud to capture himself and the paladin within it so he could leave combat. He cast the spell, and then came down to the debate of whether the paladin would get an opportunity attack even though she was blinded.

The wizard was in threat range, but does an effect that causes an area to become heavily obscured cause the Paladin to lose threat range and the wizard be able to successfully flee to another area of the ring?

Or does the paladin still have threat range and attack the wizard, even with fog cloud covering both of them?

I looked over the rules for 15 minutes after this situation, but nothing came up. It was ruled in-game that it was fine to make an opportunity attack with disadvantage, but that just doesn’t feel right. She might have heard the wizard stepping away, but the fog cloud was already in place. By the D&D rules, would the paladin have been able to make the opportunity attack or not?

How to remediate a CVE or find a work around before the patch is released?

I was going through set of security vulnerabilities reported in Oracle Critical Patch Update. I want to find out the standard process followed by developers/security people to mitigate these kind of vulnerabilities before the patch is released. So to ask direct questions..

What is the standard set of steps I should follow to mitigate a security vulnerability before patch is released?

Even after the patch is released, how to find out the severity of the impact of any CVE on my system to determine if application of the patch is really worth the efforts?

I know there is a severity index mentioned on the Oracle and CVE portals for each CVE. However, how do I really check how badly my overall system, which includes multiple servers and multiple web services, is impacted?

Finally, do guide me if I am going in the wrong direction here and point out the right way to deal with CVEs. Thanks!