NPC Constructor with Attributes

Alright, thanks to the people helping me so far this is what I have, :3
using UnityEngine;
using System.Collections;

public class NPCs
{
   	public NPC[] npcList;
    public int npcId;

    void createNPC()
    {
		npcId = npcId + 1;
		npcList[npcId].maxHealth = 100;
    	npcList[npcId].CurrentHealth = npcList[npcId].maxHealth;
		npcList[npcId].expReward = 50;
    }

    public class NPC
    {
      	public int currentHealth {get; set;}
		public int maxHealth {get; set;}
		public int expReward {get; set;}
    }
}

Thanks a bunch to the guys helping me out, this is the only thing that has had me stumped this bad in awhile, now I’m just trying to figure out how to add a gameObject to the npcList, I guess. because, even though I have all of the stats for each NPC set up, I don’t have them linked to an actual in game object… So now how would I go about that. Do NOT tell me to drag it onto one, because this project is about NOT using the editor.

Hey, not gonna write entire script, but you could do something like this with classes to be able to access the “NPCS” array (list) with an ID, and then access sub variables like health, rank, level. And even go further down like:
- NPCS[ID].health.current -= DamageTaken();
//So look it up :slight_smile:
You could even add a function to the NPCS class that would have a built in method of applying damage!

 Import System.Generic.Collection // ??? something like this
public NPCS : List.<NPCList> = new List.<NPCList>(); 

class NPCList {
    var health : Stat;
    var rank : int;
    function NPCList(health : Stat, rank : int){
       this health = health;
       this.rank = rank;
    }
}
class Stat {
    var current : int;
    var max : int;
    function Stat(current : int, max = int){
        this.current = current;
        this.max = max;
    }
}
// SOMEWHERE IN CODE
NPCS.add(NPCList(Stat(100,100),10);