Add NPC owner consts + fix syntaxes

This commit is contained in:
Vortrex
2022-06-14 06:30:20 -05:00
parent f9d462bc07
commit ac1de36123

View File

@@ -19,19 +19,28 @@ const VRR_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case se
const VRR_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive) const VRR_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive)
const VRR_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive) const VRR_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive)
// NPC Owner Types
const VRR_NPC_OWNER_NONE = 0; // Not owned
const VRR_NPC_OWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const VRR_NPC_OWNER_JOB = 2; // Owned by a job
const VRR_NPC_OWNER_CLAN = 3; // Owned by a clan
const VRR_NPC_OWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const VRR_NPC_OWNER_PUBLIC = 5; // Public NPC. Anybody can do stuff with it.
const VRR_NPC_OWNER_BIZ = 6; // Owned by a business
// =========================================================================== // ===========================================================================
class NPCData { class NPCData {
constructor(dbAssoc = false) { constructor(dbAssoc = false) {
this.databaseId = 0; this.databaseId = 0;
this.serverId = 0; this.serverId = 0;
this.firstName = "John"; this.name = "NPC";
this.lastName = "Doe";
this.middleName = "Q";
this.skin = 0; this.skin = 0;
this.cash = 0; this.cash = 0;
this.spawnPosition = toVector3(0.0, 0.0, 0.0); this.position = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0; this.rotation = toVector3(0.0, 0.0, 0.0);
this.scale = toVector3(1.0, 1.0, 1.0);
this.heading = 0.0;
this.clan = 0; this.clan = 0;
this.isWorking = false; this.isWorking = false;
this.jobUniform = this.skin; this.jobUniform = this.skin;
@@ -40,13 +49,19 @@ class NPCData {
this.weapons = []; this.weapons = [];
this.interior = 0; this.interior = 0;
this.dimension = 0; this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0; this.walkStyle = 0;
this.fightStyle = 0; this.fightStyle = 0;
this.health = 100; this.health = 100;
this.armour = 100; this.armour = 100;
this.currentAction = VRR_NPCACTION_NONE; this.currentAction = VRR_NPC_ACTION_NONE;
this.triggers = []; this.triggers = [];
this.typeFlags = 0;
this.heedThreats = false;
this.threats = 0;
this.invincible = false;
this.animationName = "";
this.ownerType = VRR_NPC_OWNER_NONE;
this.ownerId = 0;
this.bodyParts = { this.bodyParts = {
hair: [0, 0], hair: [0, 0],
@@ -68,29 +83,33 @@ class NPCData {
rightFoot: [0, 0], rightFoot: [0, 0],
}; };
this.triggers = [];
if (dbAssoc) { if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_id"]); this.databaseId = toInteger(dbAssoc["npc_id"]);
this.serverId = toInteger(dbAssoc["npc_server"]); this.serverId = toInteger(dbAssoc["npc_server"]);
this.firstName = dbAssoc["npc_name_first"]; this.name = dbAssoc["npc_name"];
this.lastName = dbAssoc["npc_name_last"];
this.middleName = dbAssoc["npc_name_middle"] || "";
this.skin = toInteger(dbAssoc["npc_skin"]); this.skin = toInteger(dbAssoc["npc_skin"]);
this.cash = toInteger(dbAssoc["npc_cash"]); this.cash = toInteger(dbAssoc["npc_cash"]);
this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"])); this.position = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.spawnHeading = toFloat(dbAssoc["npc_angle"]); this.rotation = toVector3(toFloat(dbAssoc["npc_rot_x"]), toFloat(dbAssoc["npc_rot_y"]), toFloat(dbAssoc["npc_rot_z"]));
this.scale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.heading = toFloat(dbAssoc["npc_rot_z"]);
this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]); this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]);
this.clan = toInteger(dbAssoc["npc_clan"]); this.rank = toInteger(dbAssoc["npc_rank"]);
this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]); this.title = toInteger(dbAssoc["npc_title"]);
this.clanRank = toInteger(dbAssoc["npc_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["npc_clan_title"]);
this.job = toInteger(dbAssoc["npc_job"]); this.job = toInteger(dbAssoc["npc_job"]);
this.interior = toInteger(dbAssoc["npc_int"]); this.interior = toInteger(dbAssoc["npc_int"]);
this.dimension = toInteger(dbAssoc["npc_vw"]); this.dimension = toInteger(dbAssoc["npc_vw"]);
this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]); this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]);
this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]); this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]);
this.health = toInteger(dbAssoc["npc_health"]); this.health = toInteger(dbAssoc["npc_health"]);
this.armour = toInteger(dbAssoc["npc_armour"]); this.armour = toInteger(dbAssoc["npc_armour"]);
this.typeFlags = toInteger(dbAssoc["npc_type_flags"]);
this.heedThreats = intToBool(dbAssoc["npc_headthreats"]);
this.threats = toInteger(dbAssoc["npc_threats"]);
this.invincible = intToBool(dbAssoc["npc_invincible"]);
this.animationName = intToBool(dbAssoc["npc_animation"]);
this.bodyParts = { this.bodyParts = {
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0], hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
@@ -596,28 +615,28 @@ function getNPCInfoCommand(command, params, client) {
let ownerName = "Nobody"; let ownerName = "Nobody";
let ownerType = "None"; let ownerType = "None";
switch (npcData.ownerType) { switch (npcData.ownerType) {
case VRR_NPCOWNER_CLAN: case VRR_NPC_OWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name; ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name;
ownerType = "clan"; ownerType = "clan";
break; break;
case VRR_NPCOWNER_JOB: case VRR_NPC_OWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(npcData.ownerId)).name; ownerName = getJobData(getJobIdFromDatabaseId(npcData.ownerId)).name;
ownerType = "job"; ownerType = "job";
break; break;
case VRR_NPCOWNER_PLAYER: case VRR_NPC_OWNER_PLAYER:
let subAccountData = loadSubAccountFromId(npcData.ownerId); let subAccountData = loadSubAccountFromId(npcData.ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`; ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
ownerType = "player"; ownerType = "player";
break; break;
case VRR_NPCOWNER_BIZ: case VRR_NPC_OWNER_BIZ:
ownerName = getBusinessData(getBusinessIdFromDatabaseId(npcData.ownerId)).name; ownerName = getBusinessData(getBusinessIdFromDatabaseId(npcData.ownerId)).name;
ownerType = "business"; ownerType = "business";
break; break;
case VRR_NPCOWNER_PUBLIC: case VRR_NPC_OWNER_PUBLIC:
ownerName = "Nobody"; ownerName = "Nobody";
ownerType = "public"; ownerType = "public";
break; break;