I have no Idea how to calculate the faces for my programily generated mesh

So I am making a programily generating cave program and I have all the vertices but I have no idea how to solve for the faces of my mesh. My code:

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class MapGen : MonoBehaviour {     Mesh mesh;      int[] triangles;      public int xSize = 20;     public int zSize = 20;     public int ySize = 20;     [Range(0f, 4.5f)]     public float SurfaceLevel = 3.5f;     Vector3[] interest;     Vector3 old = new Vector3(0, 0, 0);     public bool ShowAlg = false;     [Header("Slows down the scene veiw dramaticly when in play mode!")]     public bool ShowVert = true;      // Start is called before the first frame update     void Start()     {         mesh = new Mesh();         GetComponent<MeshFilter>().mesh = mesh;          CreateShape();         SolveFaces();         UpdateMesh();     }     void CreateShape()     {         interest = new Vector3[(xSize + 1) * (zSize + 1) * (ySize + 1)];          float seed = Random.Range(0.2f, 0.5f);         Debug.Log(seed);          for (int x = 0; x <= ySize; x++)         {             for (int i = 0, y = 0; y <= zSize; y++)             {                 for (int z = 0; z <= xSize; z++)                 {                     float ypn = (Mathf.PerlinNoise(x * seed, z * seed) * 2f);                     float xpn = (Mathf.PerlinNoise(y * seed, z * seed) * 2f);                     float zpn = (Mathf.PerlinNoise(x * seed, y * seed) * 2f);                      if (ypn + xpn + zpn >= SurfaceLevel)                     {                         interest[i] = new Vector3(x, y, z);                     }                      i++;                 }             }         }     }      void SolveFaces()     {         triangles = new int[xSize * ySize * zSize * 9];      }     void UpdateMesh()     {         mesh.Clear();          mesh.vertices = interest;         mesh.triangles = triangles;           mesh.RecalculateNormals();         MeshCollider meshc = gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;         meshc.sharedMesh = mesh;      }     private void OnDrawGizmos()     {         if (interest == null)             return;         for (int i = 0; i < interest.Length; i++)         {             if (ShowVert == true)             {                 Gizmos.color = new Color (0.286f, 0.486f, 0.812f);                 Gizmos.DrawSphere(interest[i], 0.2f);             }             if(ShowAlg == true)             {                 Gizmos.color = Color.green;                 Gizmos.DrawLine(old, interest[i]);                 old = interest[i];               }         }     } } 

This script is placed on a empty Game Object with a Mesh Filter, Renderer, and a collider. Note they do nothing without the faces. I have set it up so the face array goes on the triangles variable and missing part of the script should go in the SolveFaces() function. Thanks in advance.

Bluetooth LE with Secure Connection and static passkey: This is a bad idea, right?

I am currently looking into how to protect a BLE connection from active attacks (man-in-the-middle) if one of the devices neither has a display nor a keyboard.

Lemberg Solutions suggests this:

Alternatively, the passcode can be shipped together with the devices (on paper or as part of an online purchase), and the user should then manually input it to each separate device.

This can only mean that one device (device A) (most likely one without a keyboard and without a display) has a passkey embedded in the device somewhere. So it is static. This static passkey is also used by the other device (device B) (e.g. entered using keyboard input, via camera, …). The same passkey will be used every time BLE pairing is established with device A.

Am I understanding their suggestion correctly?

My understanding of Secure Connections with passkey is, that each device does the following for each bit of the passkey:

  • create a nonce
  • calculate a confirmation value using: nonce, passkey[i], SK
  • exchange the confirmation values with the other device (send own, receive other)
  • exchange the nonces (send own, receive other)
  • check that the confirmation value of the other device is correct If one of the checks fails, the connection is dropped.

In the case of a man-in-the-middle attack, the attacker can figure out the passkey by “brute-forcing” each bit. After all, there are only two possibilities for each bit.

This is not harmful for the current connection, because the attacker is “too late” to use the passkey. And it is not harmful if a different passkey is used for the next connection. But this is fatal if another connection is made using the same passkey (which is going to happen if a static passkey is used).

So, after the attacker listened to the pairing attempt, she interrupts the connection (e.g. right after the last set of nonces was transmitted). Now she only has to wait until the next connection attempt is made. She can now hijack the whole connection.

Is my assessment of this situation correct and the static passkey is a bad idea or am I overlooking something?

First time DM – Is it a good idea to use stock photos / images?

I don’t think I’m particularly good at detailed poetic descriptions and I’m worried my imagination could be a bit on the slow side.

I was thinking I could use something like a quick and dirty powerpoint presentation showing some concept art / stock photos of various locations and NPC. Not only for the players but also for me to figure out what to describe if I get stuck.

Is this a good or bad idea?

Is giving my character amnesia about it’s backstory a bad idea?

During my first campaign as a player I had a issue with my DM regarding the background I gave to my character. It was my first time creating a background for my character and I loved doing it, so much that my backstory became quite big. (I gave my DM a short summary to make his life easier).

While I loved creating a backstory, I wasn’t too comfortable with going all in with roleplaying. For this reason I added a piece in my backstory where my character was cursed, couldn’t remember where he was from and he was now wandering around looking for answers. I just wasn’t ready to dive straight into roleplaying this backstory and wanted to learn RP step by step.

A couple sessions after I handed over my backstory, my DM briefly mentioned his dislike towards my backstory. He did this in a single comment, away from all the other players which went along the line of “Who gives their player amensia, what kind of person does that?” At that time I didn’t know how to respond and not too long after that we stopped playing anyway, but the comment still makes me wonder if it really is a bad thing to do?

So, is giving your player amnesia about their backstory a bad thing to do to your DM? Or is it something just my DM had issue with?

Is it a bad idea to only start enforcing rules late in a campaign?

I’m a pretty new DM. My players are almost at session 20 in my first campaign and it’s going great.

One of my players has been using a monk. I wasn’t familiar with the class, so I’d usually just ask them to explain what their features did. Problem is, I recently made a monk character myself, and realized my player has been doing some things wrong.

They aren’t that bad, just things like using loading-property weapons for Extra Attack, doing Martial Arts as a bonus action whenever they want (not just after an Attack action), and counting all their monk weapon attacks as magical (not just unarmed strikes).

For the past couple of sessions, I’ve started correcting my player, but they’ve asked: “Why can’t I do that now? I’ve done it before.”

It was honestly my mistake that I allowed it before. Is it too late to change my ruling? I don’t like countering my player so often, so I’m considering adding house rules for stuff I allowed before I knew any better.

(I haven’t actually asked my player if this is even a problem for them yet, but I’d rather catch it early)

Is this a good idea for an NPC

So I have an idea for a NPC who is a traveling merchant who appears when a player character says they need something which makes the players see this as a cheap way to avoid towns. Then the NPC shows up again and again no matter where they are with items that have prices that can never go down. So if a player would to get angry and attack the merchant they would discover its a Lich hiring monsters to put them in dugeons to get loot from warriors to sell them using disguise self. Now once the lich is attack its up to the DM to decide to have the lich attack the players or just tell them not to test them and sometimes hire them for quests and the players could even solely get the quests from the lich. Do you guys think this has potential, now if you want to use this idea in a campaign go ahead and use it, just tell me how the players react to it and how it is use in the story.

I am trying to make a homebrew campaign. I have been trying to brainstorm the idea for the start. Is this good enough?

The player’s characters were hired by Tulmund Bilsh, a silk merchant from Alablast, a diverse town which also happens to be the player character’s home town, to help escort him and his goods to a primarily human city, Vern, and will pay the players once the journey has been completed.

They begin in a tavern in a small swamp village named Stillwater, where they plan to rest and stay the night. Right before they hit the hay, though, the village is attacked by a tribe of lizardfolk, and Tulmund disappears during the attack. With enough questioning of the locals, the players will find out that lizardfolk in this region are nearing extinction, and they lurk in the ruins of a once proud city, the only building intact being a temple.

Assuming the players still want their pay, they will assault the temple, and fight their way through brainwashed villagers, strange constructs and a few lizardfolk sprinkled in. They find a multitude of cells along their way, but all of them empty or containing corpses, none of which are that of the silk merchant’s. They finally fight their way into a large room with an altar at the center, with a strange blue orb sitting on a pedestal. They find the silk merchant being forced to his knees, facing towards the orb by two brainwashed villagers as a blue mist begins to emit from the orb and make it’s way towards the merchant, this is presumably the way the lizardfolk brainwash people. A robed lizardfolk stands behind the altar, chanting and the players will engage combat with two constructs, some lizardfolk and some other brainwashed people.

If the players take out the ones holding Tulmund, the orb is taken off the pedestal or interrupt the robed lizardfolk, Tulmund will not be brainwashed. If the orb is taken off the pedestal, the altar will open and a shadowy aberration will begin to rise from the altar and the players will have to get 13+ on a wisdom saving throw or be inflicted with Crown of Madness.

Yes, I am aware that this is a sloppy mess and does require more finer details, but this is the general idea I had to start out my campaign without it being a basic “you start in a tavern” kind of deal.

Is changing concetration rules for 1h+ buff spells a bad idea? (5E DnD)

I have noticed that many long duration (1h+) spells in 5E DnD have concentration, effectively meaning caster cannot cast other concentration spells while using such a spell (or end the spell). For example Barkskin and Alter Self. This seems to make many “buff” spells much less useful, possibly to the point they will never be used except very in special circumstances.

I have played and DMed since early red-box basic, and I get that 5E with it’s bounded accuracy is not like 3.5E where the Wizard would buff up party with 4-5 spells before they go to work for the day. However it still seems weird that now you would almost never do that or any concentration buffs in 5E. I get that with reaction spells you may not need buffs as much – but I liked the strategy and planning of selecting buffs.

I am thinking of a house-rule something like this:

Besides Concentration, there is Subconscious Concentration, which works the same (only one subconscious spell at a time, which can be lost if concentration would) – but it would allow you to have 1 Concentration and 1 Subconscious Concentration spell at the same time.

Generally longer lasting (1h+? 10 min?) non-damaging utility spells would be Subconscious Concentration instead of Concentration*. This way the Druid could use Barkskin and still cast concentration combat spells and have fun in a fight. However, you would not have a stack of expected standard buffs on the party either, since only one utility spell could be subconsciously concentrated on at a time, which I think would make for interesting choices.

*Obviously I would have to evaluate spells for subconscious mechanic individually.

I admit I am on the fence re Magic Weapon since it is damage causing – but I like idea of wizard buffing fighter with a magic weapon as they hunt that Werewolf, while still being able to cast a spell or two during the fight. On the other hand I think scrying would probably stay regular concentration because…it feels right.

Is this a good / bad / unbalancing idea? What are some Pros and Cons? Any suggestions for improvement on this house-rule?

Is a global nonce a bad idea?

I’m trying to build a central system that will delegate certain functionality and serve me some nice things when dealing with AJAX calls. Basically, I want to dumb the whole charade of checking parameters, making sure they’re alright, making sure the user has the right capabilities, etc. into one single system.

There is a problem with nonces however. To my understanding and just reading through it, a nonce is supposed to simply protect against CSRF. It’s a simple mechanism of generating an unique string based on who the user is, the action & the time.

Problem is that, the nonce has to always be localized to the script that’s going to pass it as the security argument when making an AJAX call. This means that the back-end cannot know how the nonce is called beforehand.

If I do:

<?php //Set Your Nonce $  ajax_nonce = wp_create_nonce( "wpdocs-special-string" ); ?>  <script type="text/javascript"> jQuery(document).ready(function($  ){     var data = {         action: 'wpdocs_action',         security: '<?php echo $  ajax_nonce; ?>',         wpdocs_string: 'Hello World!'     };     $  .post(ajaxurl, data, function(response) {         alert("Response: " + response);     }); }); </script> 

which is equivalent to wp_localize_script with the nonce as a parameter, the script will only know the generated string, not the name of the nonce which is wpdocs-special-string, therefore, my system cannot do check_ajax_referer( 'wpdocs-special-string').

What exactly would be wrong with generating a global nonce so that every AJAX request will be checked against that nonce?

Input mask on email field a good idea?

A colleague of mine is arguing that we should use an input mask for email fields.

Personally I don’t think it is necessary. For phone numbers I can understand since a phone number can be written in different ways.

However everybody knows how to write an email address. Is it really useful to use a mask (and all the trouble it can get you with multiple devices)? Will people forget the @ if we don’t provide the mask? I don’t think so.

If the user enters an invalid email address we already use inline error (on blur) so what is the point. What do you guys think?