## Window handle is invalid

I’m trying to implement an input listener for FNA (modern version of XNA). Since FNA does not supply any sort of way to listen to native input this has to be done through the windows API and native calls. This is how I set this up:

``public KeyboardListener(GameWindow window) {     var procedurePointer = Marshal.GetFunctionPointerForDelegate<WindowProcedure>(Procedure);     procedure = new IntPtr(SetWindowLongPtr(window.Handle, GWL_WNDPROC, procedurePointer.ToInt64()));     if (procedure == IntPtr.Zero)     {         var error = GetLastError();         throw error switch         {             ERROR_INVALID_WINDOW_HANDLE => new InvalidOperationException("Invalid window handle"),             _ => new InvalidOperationException(\$  "Unknown error message '0x{error:X4}'")         };     } }  // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptra#parameters private const int GWL_WNDPROC = -4;  // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern int SetWindowLongPtr(IntPtr hWnd, int nIndex, long dwNewLong);  [DllImport("Kernel32.dll", CharSet = CharSet.Unicode)] private static extern uint GetLastError(); ``

I construct the keyboard listener during the `Initialize` method of `Game`:

``class MyGame : Game {     protected override void Initialize() {         new KeyboardListener(Window);     } } ``

This is the method call that reports the error: `SetWindowLongPtr(window.Handle, GWL_WNDPROC, procedurePointer.ToInt64())` and it throws `"Invalid window handle"`. It’s worth noting that the example code I saw converted the pointers to `Int32` instead of `Int64`, but I am on a 64 bit machine so the pointers can not fit in 32 bits.

### What I’ve tried & figured out so far…

• Debugging tells me that both `window.Handle` and `procedurePointer` are non-null and at least point to something.
• I have tried to initialize it earlier or later, but that doesn’t seem to make a difference.
• Other native methods such as `SDL2.SDL.SDL_MinimizeWindow(Window.Handle)` work perfectly fine and don’t complain about the window handle.

## How to handle falling down stairs?

It is well-established in fiction — as in real life — that falling down a flight of stairs is dangerous. A significant tumble can seriously injure or kill a person. "Pushed down a flight of stairs" is by now a hackneyed modus operandi in crime dramas. Recognizing that D&D is not a physics simulation, how should a DM model that danger?

Under normal falling rules, "[a] fall from a great height" deals 1d6 damage per 10 feet fallen. (PHB p. 183.) That wording seems to presume a freefall ending in a single, hard impact. Falling down stairs is at least arguably different: it doesn’t involve the same velocity, but it might involve a lot more bludgeoning.

Do the normal falling rules cover falling down stairs? Are there any alternative rules in published 5E materials? If it helps, our table does use the optional falling rules from Xanathar’s Guide to Everything, although so far we haven’t treated those rules as answering this question.

## Is there a standard way to handle spells that have *willing creatures* as targets but no ruling for unwilling ones?

Some spells allow to target willing creatures and specify what unwilling ones should do (usually, a saving throw) to avoid the magical effect (see Scatter, for example).

Other spells use wording such as "up to $$X$$ willing creatures", "You touch a willing creature" and similar, but they do not have any rules for not willing ones.

Is there any standard/common way to handle spells belonging to the latter case? Or does the magical effect simply take place?

Most of these spell are buffs, hence usually the targets are willing creatures. Down below I report a couple of example situations in which a creature may want to avoid the spell’s effect.

Catnap

You make a calming gesture, and up to three willing creatures of your choice that you can see within range fall unconscious for the spell’s duration. The spell ends on a target early if it takes damage or someone uses an action to shake or slap it awake. […]

The party is fighting a group of 3 ogres and they are heavily injured, they want to run away from combat: the bard casts Catnap and the ogres fall unconscious even they are not willing to do so.

Water Walk

This spell grants the ability to move across any liquid surface–such as water, acid, mud, snow, quicksand, or lava […]. Up to ten willing creatures you can see within range gain this ability for the duration.

If you target a creature submerged in a liquid, the spell carries the target to the surface of the liquid at a rate of 60 feet per round.

A group of enemies cast Water Breathing for fleeing under water from the party. The wizard casts Water Walk to force them to emerge from the water: now they are easy targets for the ranger.

## How to handle degrees of success in roll under systems

I’m working on an RPG system that uses 2d6 roll under Skill for resolutions. On paper this system looks really good so far, but I have one major issue: Degrees of Success, especially when it comes to Contest (Skill vs Skill) resolutions.

### Status Quo

Your character’s Attribute + Skill (e.g. Charisma + Persuasion) form a Target Number that’s between 2 and 12. You roll 2d6, sum them, and the sum has to be equal to or lower than the Target Number. Rolling a 1 has a special positive meaning, rolling a 6 has a special negative meaning. Additionally, 2 ones are always a success, 2 sixes are always a failure, regardless of Skill.

### The problem

Imagine 2 parties contesting each other:

• Character A has a Target Number of 5 (pretty bad), and character B has a Target Number of 10 (pretty good).
• Character A rolls a 5 and succeeds. Character B and rolls a 6 and succeeds.
• Character B has the better Degree of Success, as the margin between the player’s roll and the character’s Skill is bigger than for Character A.

If you say that lower is better, a character with Target Number 2 (very, very bad), who rolled a 2, will always have a better Degree of Success over a character with a Target Number 12 (very, very good), who rolled a 3.

### Naive solution

My approach was to subtract the rolled number from the character’s Skill. You have a Target Number of 6 and rolled a 4? `6-4=2`. You have a Target Number of 11 and rolled a 3? `11-3=8`. It works, but I’m worried that this resolution will be too slow for actual play – we all know these sessions that last for hours and nobody is able to count straight anymore.

The best solution would allow a player to determine the Degree of Success/Failure in the same step to see if the character succeeded or not.

### Other systems

Other systems that handle Degrees of Success for rolling under mechanics:

• Call of Cthulhu: You have certain threesholds (half your skill, 1/5 your skill) at which you score an increased Degree of Success. – very coarse when you only have 2d6 instead of a 1d100 (but could work)
• Unknown Armies: Basically like Black Jack–you roll under your Skill threshold, but as high as possible. Doubles (11, 22, 33) are criticals. – sadly doesn’t work, as ones and sixes have a special meaning. Flipping the meaning (6 is good, 1 is bad) also is iffy, as it’s flipping the understanding, that you have to roll under a threshold.
• ???

What other systems or resolution systems are there, that tackle this problem?

## Handle multiple simultaneous requests Mysql

sorry for this noob question. I do have an application which expects about 5000 users accessing it simultaneously, my current database is running on RDS and for each request, a query is called, it takes about 30 milliseconds to be executed.

The main caveat is when we open multiple connections the CPU database spikes to 100% and the app starts to getting timeout error.

What solution would be possible to handle so many requests?

Architecture:

• 3 EC2 db.r5.16xlarge(db.t3.large) running behind a load balancer
• 1 RDS (db.t3.2xlarge) MySql 5.7

## How do you handle random encounters if the GM isn’t supposed to roll dice?

I’m trying to deal with random encounters in DW. If my players are in a town, and suddenly decide to go into a random building how do I decide if the NPCs in there like the PCs? In D&D I’d just roll for a reaction and take it from there. Here I feel like I need to decide if the NPCs want to get along with PCs, and frankly I’m not sure what the NPCs think.

Sometimes I just think a roll of the die is exactly I want for my NPCs.

## Best way to get handle on the Ticks properties

There are a lot of questions already on `Ticks`. However I did not find a better way to handle ticks place, size etc.

I have a simple example where I want have some handle on the ticks position and size. I found the undocumented functionality `ChartingScaledTicks` from some of the previous questions in this forum which I think gives a great handle to tick-size. But when comes to choosing the Major/Minor ticks position I could not so far use it. And the problem is I do not know where I will get more information on this (apart from typing `?ChartingScaledTicks`).

Lets take the following example where I want to set my Major ticks on even-places like `600,800,...` etc.

``ListLinePlot[Table[{x,x},{x,500,2000,100}],              Frame -> True,              FrameStyle -> BlackFrame,              FrameTicks->{{Charting`ScaledTicks[{Identity,Identity},TicksLength->{.05,.02}],None},              {Charting`ScaledTicks[{Identity,Identity},TicksLength->{.05,.02}][400,2000,8],None}} ``

]

After playing a bit, I am able to show the Major ticks on x-axis appearing on even-100-places, the minor ticks are gone. I am sure that I am missing something for the minor ticks in the `ChartingScaledTicks` options but I dont know what should I do to make them reappear. Here is an example where y-axis is automatically taking Major ticks, in the x-axis I try to force Major ticks appear at even-hundred places.

How do I set position and size of Major ticks

## How to handle damage in decisive attack when one party is unaware?

How do you handle decisive damage in cases where one party is totally unaware that they are being attacked and the other person has time to prepare?

The problem is that a prepared ambusher will not have had any withering attacks to increase their initiative prior to the ambush decisive attack. And it does not make a lot of sense to ambush someone with only your join battle initiative.

I’m looking for a reference to the rules explaining this situation, or a solution you have tried. personally all I could find in the book is that if you ambush someone they have a lower defence depending on whether or not they are in combat or totally unaware that they are in danger.

Just to make it clear what I’m trying to solve I’ll give two cases that came up in a game:

1. Someone (a mortal) is sneaking up on a exalted that is sleeping and trying to kill that person. This is very unlikely (or maybe I don’t want it to) to outright kill the exalted, but how much damage does the mortal actually do?
2. In a form of duel one party say, I’ll stand still and give you a first free shot. Do your best to hurt me. This is assuming there is only ever going to be one strike. This came up when someone wanted to test an armor.

## How can I handle a PC wanting to be a “twist” villain?

My group has been following a premade campaign that has a decentralized plot structure that relies mainly on adventurers "finding their own adventure". This means that while the campaign provides ample worldbuilding information and premade side-quests, the campaign has no clearly defined antagonist or central plotlines. Normally, in a group focused on exploration and combat this wouldn’t be a big deal, however in my group there’s been a general feeling of dissatisfaction at the current lack of plot progression, as well as the lack of a main antagonistic force.

In order to help develop a centralized plot, one of my players recently came up with the idea of his PC secretly acting as a twist villain. The basic premise is that they would conduct certain actions between sessions in secret (i.e. assassinating certain NPCs, instigating strife between factions, etc.), such that the other players would have mysteries to uncover, as well as a means of driving change in an otherwise stagnant story.

In order to prevent the player from gaining an unfair amount of agency and spotlight, the following would be enforced:

• The PC will not become "the BBEG". That is to say, they will never become the primary antagonistic force in the story. They will never work fully in opposition to the other PCs, but will follow goals that the other PCs may view as acts of evil.
• The PC’s villainous acts will serve to develop a larger storyline. The PC will only be privy to information pertaining to their own actions; the player of said PC will not be aware of the overall direction of the story.
• The player has agreed to relinquish control of their character to me (the GM) in the event that cooperation between them and the rest of the party becomes impossible.

I’ve heard that PVP generally has a negative connotation and I have some concerns with the idea of a player having an elevated degree of control in the storyline, mostly related to spotlight issues. However twist villains appeal to me and I think that the other players will appreciate the resulting narrative shift.

RPG.SE has a vast array of experiences and I’m certain that this scenario has occurred before. I’m hoping to draw on that experience to help answer the following question: how can I handle a PC wanting to be a twist villain?

• What steps can I take to ensure that this doesn’t come across as an act of favoritism?
• How can I prevent this from turning into an instance of "My Guy" syndrome?
• Are there any pitfalls of this choice that I may want to avoid?

Preferably, I’m interested in answers that ensure that the mystery surrounding the villains identity is preserved, while reducing any potential in-real-life strife.

Contextual points to consider:

• The group has historically responded well to story-driven adventures. Roleplaying abilities are generally strong and players expect the presence of heightened drama.
• When we started this campaign, we were aware that the campaign was more open-ended than others we’ve played in the past. It was selected as an experiment of sorts; needless to say the experiment has proven somewhat unsuccessful and everyone involved is aligned on the fact that the campaign requires a stronger storytelling backbone in order to remain interesting.
• Session Zero has already occurred and this sort of behavior was never fully discussed. Players are aware that their PC’s goals will not always fully align, and that PVP may occur, but we haven’t discussed the possibility of players being fully villainous.
• Players are aware that they may receive more or less narrative attention based on their choices and the direction of the story.

## How to handle wrong application of Spells?

So I am a DM for 2 sessions now (Including a training-montage’esque session 0, so 3 in total) and my group is completely new to DnD. Our Paladin has the Detect Good and Evil spell, and apparently uses it rather as a "Detect if there is something dangerous ahead"-Spell, for example to identify a bunch of herbs which were advertised as antidote.

Now for my question: Should I rather push them into reading the spell description again and advise against using the spell in such a manner, or would it be better practice if I just let them waste the spell like that, until they eventually learn it by themselves?