Restructure (unfinished)

This commit is contained in:
Vortrex
2022-03-12 05:20:14 -06:00
parent 2dc6d65a50
commit ef4a2877d0
51 changed files with 2314 additions and 2524 deletions

View File

@@ -7,6 +7,179 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// NPC Trigger Condition Match Types
const VRR_NPC_COND_MATCH_NONE = 0; // None (invalid)
const VRR_NPC_COND_MATCH_EQ = 1; // Must be equal to
const VRR_NPC_COND_MATCH_GT = 2; // Must be greater than
const VRR_NPC_COND_MATCH_LT = 3; // Must be less than
const VRR_NPC_COND_MATCH_GTEQ = 4; // Must be greater than or equal to
const VRR_NPC_COND_MATCH_LTEQ = 5; // Must be less than or equal to
const VRR_NPC_COND_MATCH_CONTAINS = 6; // Must contain string (case insensitive)
const VRR_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case sensitive)
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)
// ===========================================================================
class NPCData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.serverId = 0;
this.firstName = "John";
this.lastName = "Doe";
this.middleName = "Q";
this.skin = 0;
this.cash = 0;
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.clan = 0;
this.isWorking = false;
this.jobUniform = this.skin;
this.lastJobVehicle = null;
this.job = 0;
this.weapons = [];
this.interior = 0;
this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0;
this.fightStyle = 0;
this.health = 100;
this.armour = 100;
this.currentAction = VRR_NPCACTION_NONE;
this.triggers = [];
this.bodyParts = {
hair: [0,0],
head: [0,0],
upper: [0,0],
lower: [0,0],
};
this.bodyProps = {
hair: [0,0],
eyes: [0,0],
head: [0,0],
leftHand: [0,0],
rightHand: [0,0],
leftWrist: [0,0],
rightWrist: [0,0],
hip: [0,0],
leftFoot: [0,0],
rightFoot: [0,0],
};
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_id"]);
this.serverId = toInteger(dbAssoc["npc_server"]);
this.firstName = dbAssoc["npc_name_first"];
this.lastName = dbAssoc["npc_name_last"];
this.middleName = dbAssoc["npc_name_middle"] || "";
this.skin = toInteger(dbAssoc["npc_skin"]);
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.spawnHeading = toFloat(dbAssoc["npc_angle"]);
this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]);
this.clan = toInteger(dbAssoc["npc_clan"]);
this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]);
this.clanRank = toInteger(dbAssoc["npc_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["npc_clan_title"]);
this.job = toInteger(dbAssoc["npc_job"]);
this.interior = toInteger(dbAssoc["npc_int"]);
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.fightStyle = toInteger(dbAssoc["npc_fightstyle"]);
this.health = toInteger(dbAssoc["npc_health"]);
this.armour = toInteger(dbAssoc["npc_armour"]);
this.bodyParts = {
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
head: [toInteger(dbAssoc["npc_hd_part_head_model"]) || 0, toInteger(dbAssoc["npc_hd_part_head_texture"]) || 0],
upper: [toInteger(dbAssoc["npc_hd_part_upper_model"]) || 0, toInteger(dbAssoc["npc_hd_part_upper_texture"]) || 0],
lower: [toInteger(dbAssoc["npc_hd_part_lower_model"]) || 0, toInteger(dbAssoc["npc_hd_part_lower_texture"]) || 0],
};
this.bodyProps = {
hair: [toInteger(dbAssoc["npc_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hair_texture"]) || 0],
eyes: [toInteger(dbAssoc["npc_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_eyes_texture"]) || 0],
head: [toInteger(dbAssoc["npc_hd_prop_head_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_head_texture"]) || 0],
leftHand: [toInteger(dbAssoc["npc_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_lefthand_texture"]) || 0],
rightHand: [toInteger(dbAssoc["npc_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_righthand_texture"]) || 0],
leftWrist: [toInteger(dbAssoc["npc_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftwrist_texture"]) || 0],
rightWrist: [toInteger(dbAssoc["npc_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightwrist_texture"]) || 0],
hip: [toInteger(dbAssoc["npc_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hip_texture"]) || 0],
leftFoot: [toInteger(dbAssoc["npc_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftfoot_texture"]) || 0],
rightFoot: [toInteger(dbAssoc["npc_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightfoot_texture"]) || 0],
};
}
}
};
// ===========================================================================
class NPCTriggerData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.npcId = 0;
this.index = 0;
this.npc = 0;
this.npcIndex = -1;
this.triggerType = 0;
this.conditions = [];
this.responses = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_id"]);
this.npc = toInteger(dbAssoc["npc_trig_npc"]);
this.triggerType = toInteger(dbAssoc["npc_trig_type"]);
}
}
};
// ===========================================================================
class NPCTriggerConditionData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
this.triggerIndex = 0;
this.conditionType = 0;
this.conditionValue = false;
this.matchType = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]);
this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]);
this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]);
this.conditionValue = toInteger(dbAssoc["npc_trig_cond_val"]);
this.matchType = toInteger(dbAssoc["npc_trig_cond_val"]);
}
}
};
// ===========================================================================
class NPCTriggerResponseData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
this.triggerIndex = 0;
this.responseType = 0;
this.responseValue = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]);
this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]);
this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]);
this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]);
}
}
};
// ===========================================================================
function initNPCScript() {
getServerData().npcs = loadNPCsFromDatabase();
setAllNPCDataIndexes();